GETWIN chooses an appropriate window size for the chessboard corner filter GETWIN chooses the window size depending on the spread of the points. It simply chooses a window size which does not include any other points. USAGE: win=getwin(img,pt,crnrpts) INPUTS: img: grayscale image (only used for size) pt: coordinates of pixel of interest crnrpts: 2xN array of all other points OUTPUTS: win: window size
0001 function win=getwin(img,pt,crnrpts) 0002 % GETWIN chooses an appropriate window size for the chessboard corner filter 0003 % 0004 % GETWIN chooses the window size depending on the spread of the points. It 0005 % simply chooses a window size which does not include any other points. 0006 % 0007 % USAGE: 0008 % win=getwin(img,pt,crnrpts) 0009 % 0010 % INPUTS: 0011 % img: grayscale image (only used for size) 0012 % 0013 % pt: coordinates of pixel of interest 0014 % 0015 % crnrpts: 2xN array of all other points 0016 % 0017 % OUTPUTS: 0018 % win: window size 0019 0020 0021 x=pt(1); 0022 y=pt(2); 0023 nearestpt=findnearest([x;y],crnrpts,1); 0024 win=max(abs(nearestpt-[x;y]))-2; 0025 0026 % check for borders 0027 if x-win<1 0028 win=x-1; 0029 end 0030 if x+win>size(img,1) 0031 win=size(img,1)-x; 0032 end 0033 if y-win<1 0034 win=y-1; 0035 end 0036 if y+win>size(img,2) 0037 win=size(img,2)-y; 0038 end