getcrnrpts

PURPOSE ^

GETCRNRPTS is a function that uses the mean and standard deviation images to adaptively obtain local maxima in an image.

SYNOPSIS ^

function crnrpts=getcrnrpts(imgh,mimg,stdv,th,debug)

DESCRIPTION ^

 GETCRNRPTS is a function that uses the mean and standard deviation images to adaptively obtain local maxima in an image.
 
 GETCRNRPTS can be applied on the Harris transform to obtain the Harris
 corner points.
 
 USAGE:
     crnrpts=getcrnrpts(imgh,mimg,stdv,th);
 
 INPUTS:
     imgh: Harris transform of image
 
     mimg,stdv: output from ADAPTSTATS
 
     th: parameter to adjust thresholding
 
 OUTPUTS:
     crnrpts: 2xN array with coordinates of corner points

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function crnrpts=getcrnrpts(imgh,mimg,stdv,th,debug)
0002 % GETCRNRPTS is a function that uses the mean and standard deviation images to adaptively obtain local maxima in an image.
0003 %
0004 % GETCRNRPTS can be applied on the Harris transform to obtain the Harris
0005 % corner points.
0006 %
0007 % USAGE:
0008 %     crnrpts=getcrnrpts(imgh,mimg,stdv,th);
0009 %
0010 % INPUTS:
0011 %     imgh: Harris transform of image
0012 %
0013 %     mimg,stdv: output from ADAPTSTATS
0014 %
0015 %     th: parameter to adjust thresholding
0016 %
0017 % OUTPUTS:
0018 %     crnrpts: 2xN array with coordinates of corner points
0019 
0020 % Check input
0021 if ~exist('debug','var') || isempty(debug)
0022     debug=0;
0023 end
0024 
0025 % adaptive thresholding
0026 imax=mimg+th*stdv;
0027 imax(imax>1)=1;
0028 imax(imax<0)=0;
0029 imghl=0*imgh;
0030 imghl(imgh>imax)=1;
0031 imghl=logical(imghl);
0032 imghlf=medfilt2(imghl);
0033 imghlf=medfilt2(imghlf);
0034 
0035 % get centroids of blobs as Harris corner points
0036 [imglfl,n]=bwlabel(imghlf);
0037 meanx=zeros(1,n);
0038 meany=zeros(1,n);
0039 cnt=zeros(1,n);
0040 
0041 
0042 [x,y,v]=find(imglfl);
0043 
0044 for cntr=1:size(x)
0045     meanx(v(cntr))=meanx(v(cntr))+x(cntr);
0046     meany(v(cntr))=meany(v(cntr))+y(cntr);
0047     cnt(v(cntr))=cnt(v(cntr))+1;
0048 end
0049 
0050 meanx=round(meanx./cnt);
0051 meany=round(meany./cnt);
0052 crnrpts=[meanx;meany];
0053 
0054 % debugging
0055 if debug
0056     close all;
0057     figure;imshow(imghl);
0058     figure;imshow(imghlf);
0059     pause;
0060 end

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