getsubpixcrnrs

PURPOSE ^

GETSUBPIXCRNRS retruns the subpixel positions of the chessboard corners.

SYNOPSIS ^

function [gridout,win,nobadpts]=getsubpixcrnrs(img,crnrpts,grid)

DESCRIPTION ^

GETSUBPIXCRNRS retruns the subpixel positions of the chessboard corners.
 
 GETSUBPIXCRNRS relies on the subpixel corner finder by 
 Jean-Yves Bouguet. The addition it introduces is the adaptive selection
 of the window size.
 
 GETSUBPIXCRNRS also chooses a subset of the grid if certain corners do 
 converge using Bouget's code.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [gridout,win,nobadpts]=getsubpixcrnrs(img,crnrpts,grid)
0002 %GETSUBPIXCRNRS retruns the subpixel positions of the chessboard corners.
0003 %
0004 % GETSUBPIXCRNRS relies on the subpixel corner finder by
0005 % Jean-Yves Bouguet. The addition it introduces is the adaptive selection
0006 % of the window size.
0007 %
0008 % GETSUBPIXCRNRS also chooses a subset of the grid if certain corners do
0009 % converge using Bouget's code.
0010 
0011 % reshape into row vector
0012 gridx=grid(:,:,1);
0013 gridy=grid(:,:,2);
0014 indcs=find(gridx)';
0015 
0016 gridpts=gridx(indcs);
0017 gridpts=[gridpts;gridy(indcs)];
0018 
0019 gridout=zeros(size(grid));
0020 bad=false(size(grid,1),size(grid,2));
0021 
0022 win=Inf;
0023 
0024 % get smallest window size first
0025 for cntr=1:size(gridpts,2)
0026     ctwin=round(getwin(img,gridpts(:,cntr),crnrpts)/2);
0027     % get smallest win size
0028     if ctwin<win && ctwin>2
0029         win=ctwin;
0030     end
0031 end
0032 
0033 
0034 for x=1:size(grid,1)
0035     for y=1:size(grid,2)
0036         currentpt=squeeze(grid(x,y,:));
0037         [subpxpt,goodpt,badpt]=subpixcrnr(currentpt,img,win,win); % adjust for x and y
0038         gridout(x,y,:)=subpxpt;
0039         bad(x,y)=badpt;
0040     end
0041 end
0042 
0043 
0044 [badptsx,badptsy]=find(bad);
0045 nobadpts=length(badptsx);
0046 gridout=getgoodsubrect(gridout,badptsx,badptsy);
0047

Generated on Sun 04-Apr-2010 17:13:59 by m2html © 2005