1 / 4
文档名称:

模板匹配算法.doc

格式:doc   大小:26KB   页数:4页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

模板匹配算法.doc

上传人:taoapp 2022/3/15 文件大小:26 KB

下载得到文件列表

模板匹配算法.doc

文档介绍

文档介绍:function [I_SSD,I_NCC,Idata]=template_matching(T,I,IdataIn)
% TEMPLATE_MATCHING is a cpu efficient function which calcu0,50);
% % Get a small volume as template
% T=I(20:30,20:30,20:30);
% % Calculate SDD between template and image
% I_SSD=template_matching(T,I);
% % Find maximum correspondence
% [x,y,z]=ind2sub(size(I_SSD),find(I_SSD==max(I_SSD(:))));
% disp(x);
% disp(y);
% disp(z);
%
% Function is written by University of Twente (February 2011)
if(nargin<3), IdataIn=[]; end
% Convert images to double
T=double(T); I=double(I);
if(size(T,3)==3)
% Color Image detected
[I_SSD,I_NCC,Idata]=template_matching_color(T,I,IdataIn);
else
% Grayscale image or 3D volume
[I_SSD,I_NCC,Idata]=template_matching_gray(T,I,IdataIn);
end
function [I_SSD,I_NCC,Idata]=template_matching_color(T,I,IdataIn)
if(isempty(IdataIn)), =[]; =[]; =[]; end
% Splite color image, and do template matching on R,G and B image
[I_SSD_R,I_NCC_R,]=template_matching_gray(T(:,:,1),I(:,:,1),);
[I_SSD_G,I_NCC_G,]=template_matching_gray(T(:,:,2),I(:,:,2),);
[I_SSD_B,I_NCC_B,]=template_matching_gray(T(:,:,3),I(:,:,3),);
% Combine the results
I_SSD=(I_SSD_R+I_SSD_G+I_SSD_B)/3;
I_NCC=(I_NCC_R+I_NCC_G+I_NCC_B)/3;
function [I_SSD,I_NCC,Idata]=template_matching_gray(T,I,