normxcorr2_demo.m in ncc.rar


The normalized cross correlation (NCC) implemented in C++ and Matlab...Original Link
    Sponsored links

			
			templateSize = 11; % square template

imgWidth = 320; % rectangular image
imgHeight = 240; 

template = rand(templateSize); % template with random entries
img = rand(imgHeight, imgWidth); % similarly for the image

% randomly embed the template inside the img
embedX = round(rand*(imgWidth-templateSize-1)+1);
embedY = round(rand*(imgHeight-templateSize-1)+1);
img( embedY:embedY+templateSize-1, embedX:embedX+templateSize-1 ) = template;

% display the input for normxcorr2
H = figure(1); clf;
set(H,'name','Can you find the template?');
subplot(1,2,1);
imagesc(img);
axis('image'); title('image');
subplot(1,2,2);
imagesc(template);
axis('image'); title('template');
colormap(gray);

% perform NCC
% choose 'same' as the output shape -- ie. zero-pad the output so 
% that it's the same size as the original image
% this is not necessary, but is used for display
ncc = normxcorr2_mex(template, img, 'same');

% display the ncc
H = figure(2); clf;
set(H,'name','NCC can!');
imagesc(ncc);
axis('image'); title('normalized cross correlation');
colormap(gray);

% output where there template was embedded (centered)
fprintf('template was embedded at (%i,%i)\n', embedY+ceil((templateSize-1)/2), embedX+ceil((templateSize-1)/2));

% compute, then output where ncc 'found' the template (the highest score,
% which in this case is +1, since there is no noise)
[t mi] = max(ncc);
[t mj] = max(t);
mi = mi(mj);
fprintf('ncc found it at (%i,%i)\n', mi, mj);
			click here to download the whole source code package.

			
			


Project Files

    Sponsored links
NameSizeDate
 cv.h130.28 kB18-08-05 11:04
 cvabsdiff.cpp23.17 kB18-08-05 11:04
 cvalloc.cpp4.41 kB18-08-05 11:04
 cvarithm.cpp102.01 kB18-08-05 11:04
 cvarray.cpp91.94 kB18-08-05 11:04
 cvcompat.h29.95 kB18-08-05 11:04
 cvconvert.cpp70.63 kB18-08-05 11:04
 cvcopy.cpp42.68 kB18-08-05 11:04
 cvdatastructs.cpp94.75 kB18-08-05 11:04
 cvdxt.cpp97.92 kB18-08-05 11:04
 cverror.cpp16.40 kB18-08-05 11:04
 cverror.h9.88 kB18-08-05 11:04
 cvmathfuncs.cpp60.98 kB18-08-05 11:04
 cvtables.cpp15.13 kB18-08-05 11:04
 cvtemplmatch.cpp70.33 kB18-08-05 11:04
 cvtypes.h46.97 kB18-08-05 11:04
 _cv.h11.32 kB18-08-05 11:04
 _cvarr.h5.63 kB18-08-05 11:04
 _cvdatastructs.h16.36 kB18-08-05 11:04
 _cverror.h3.44 kB18-08-05 11:04
 _cvfuncn.h14.59 kB18-08-05 11:04
 _cvmatrix.h10.79 kB18-08-05 11:04
 _cvoptions.h3.68 kB18-08-05 11:04
 _cvtables.h2.75 kB18-08-05 11:04
 _cvutils.h16.12 kB18-08-05 11:04
 _ipcv.h60.97 kB18-08-05 11:04
 _optcv.h28.74 kB18-08-05 11:04
 linuxBuildReadme.txt52.00 B18-08-05 11:15
 Makefile114.00 B20-12-05 19:28
 normxcorr2_demo.m1.46 kB21-12-05 22:19
 normxcorr2_mex.cpp3.03 kB21-12-05 21:50
 normxcorr2_mex.dll140.00 kB21-12-05 21:50
 normxcorr2_mex.m1.66 kB20-12-05 18:58
 normxcorr2_mex.mexglx314.83 kB21-12-05 22:38
 normxcorr2_mex.mexsol419.14 kB21-12-05 22:38
 normxcorr2_mex.mexw64197.50 kB17-01-08 08:33
 README.txt1.25 kB17-06-05 10:03
 sunBuildReadme.txt744.00 B20-12-05 19:24
 mexFunction.def224.00 B19-04-05 10:11
 mpisearchmex.dsp6.35 kB20-12-05 19:13
 mpisearchmex.dsw547.00 B19-04-05 10:11
 mpisearchmex.ncb257.00 kB20-12-05 19:31
 mpisearchmex.opt47.50 kB20-12-05 19:31
 mpisearchmex.plg3.65 kB20-12-05 19:31
 mpisearchmex.sln913.00 B04-07-05 11:11
 mpisearchmex.suo8.00 kB04-07-05 11:11
 mpisearchmex.vcproj14.95 kB04-07-05 11:11
 <Release>0.00 B20-12-05 15:38
 <cv_src>0.00 B20-12-05 15:38
 <windows>0.00 B20-12-05 19:32
 <ncc>0.00 B01-04-09 12:33
...

Related Items

    Sponsored links