📄 iseffil.m
字号:
function [x, y, color]=iseffil(startpoint,direction,pathlength,plotting)% [x y] = iseffil(startpoint,direction,pathlength) [f]% gives coordinates of the edge cntourpoint % by scanning a line which start at startpoint in the given direction% with pathlength. Possible directions are:% dir=0 -> horizontal% dir=2 -> vertical% dir=1 -> under +45 degrees (in the first quadrant)% dir=3 -> under -45 degrees (in the second quadrant)%% color = 0 -> no edge% color = 1 -> 'white' line% color =-1 -> 'blach' line%% A given line is processed in ascending x-values if possible.% So if x doesn't change it processed in ascending y-values.% The global matrix BEELD contains the pixelgrayvalues.%% Plotting indicates whether the scanning lines are plotted.%% 21 april 1999% Walter Verdonck,% All the software included in this package is presented as is.% It may be distributed freely. The author can, however, not be% held responsible for any problems whatever.% % Designed by Johan Baeten, Walter Verdonck% Last updated: 29-03-2000% Johan.baeten@mech.kuleuven.ac.beglobal Bglobal FITHANDLESglobal UICTRHANDLESglobal XSIZEglobal YSIZEglobal MAINFIGglobal FILECHANGEDglobal BEELDB=0.5;xstart=startpoint(1);ystart=startpoint(2);if direction==0 yend=ystart; if (xstart+pathlength-1)>=XSIZE xend=XSIZE; else xend=xstart+pathlength-1; end data=BEELD(ystart,xstart:xend);elseif direction==2 xend=xstart; if (ystart+pathlength-1)>=YSIZE yend=YSIZE; else yend=ystart+pathlength-1; end data=(BEELD(ystart:yend,xstart))'; elseif direction==1 xend=xstart+pathlength-1; yend=ystart+pathlength-1; if xend>XSIZE yend=yend-(xend-XSIZE); xend=XSIZE; end if yend>YSIZE xend=xend-(yend-YSIZE); yend=YSIZE; end for i=0:(xend-xstart) data(i+1)=BEELD(ystart+i,xstart+i); endelseif direction==3 xend=xstart+pathlength-1; yend=ystart-pathlength+1; if xend>XSIZE yend=yend+(xend-XSIZE); xend=XSIZE; end if yend<1 xend=xend+(yend-1); yend=1; end for i=0:(xend-xstart) data(i+1)=BEELD(ystart-i,xstart+i); endendif plotting line([xstart,xend],[ystart,yend]);endj=length(data);if min(data) > 170 color = 1;elseif max(data) < 100 color = (-1);else color = 0;endif ~color % de eigenlijke iseffilter met zijn recursieve betrekking yld(1)=data(1); yrd(j)=data(j); for i=2:j yld(i)=(1-B)*data(i)+B*yld(i-1); end for i=1:(j-1) yrd(j-i)=(1-B)*data(j-i)+B*yrd(j-i+1); end for i=3:(j-3) d1(i)=yrd(i+1)-yld(i-1); d2(i)=yrd(i+1)+yld(i-1)-2*data(i); end [yt i]=max(abs(d1(1:j-3))); if i < (j-3) if d2(i-1)*d2(i)<0 xr=i-1-abs(d2(i))/(abs(d2(i-1))+abs(d2(i))); else xr=i-1+abs(d2(i))/(abs(d2(i+1))+abs(d2(i))); end else xr=i-1; end if direction==0 x=xstart+xr; y=ystart; elseif direction==2 y=ystart+xr; x=xstart; elseif direction==1 x=xstart+xr; y=ystart+xr; elseif direction==3 x=xstart+xr; y=ystart-xr; end else x=0;y=0;end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -