



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、function I_SSD,I_NCC,Idata=template_matching(T,I,IdataIn)% TEMPLATE_MATCHING is a cpu efficient function which calculates matching % score images between template and an (color) 2D or 3D image.% It calculates:% - The sum of squared difference (SSD Block Matching), robust template% matching.% - The n
2、ormalized cross correlation (NCC), independent of illumination,% only dependent on texture% The user can combine the two images, to get template matching which% works robust with his application. % Both measures are implemented using FFT based correlation.% I_SSD,I_NCC,Idata=template_matching(T,I,Id
3、ata)% inputs,% T : Image Template, can be grayscale or color 2D or 3D.% I : Color image, can be grayscale or color 2D or 3D.% (optional)% Idata : Storage of temporary variables from the image I, to allow % faster search for multiple templates in the same image.% outputs,% I_SSD: The sum of squared d
4、ifference 2D/3D image. The SSD sign is% reversed and normalized to range 0 1 % I_NCC: The normalized cross correlation 2D/3D image. The values% range between 0 and 1% Idata : Storage of temporary variables from the image I, to allow % faster search for multiple templates in the same image.% Example
5、2D,% % Find maximum response% I = im2double(imread(lena.jpg);% % Template of Eye Lena% T=I(124:140,124:140,:);% % Calculate SSD and NCC between Template and Image% I_SSD,I_NCC=template_matching(T,I);% % Find maximum correspondence in I_SDD image% x,y=find(I_SSD=max(I_SSD(:);% % Show result% figure,
6、% subplot(2,2,1), imshow(I); hold on; plot(y,x,r*); title(Result)% subplot(2,2,2), imshow(T); title(The eye template);% subplot(2,2,3), imshow(I_SSD); title(SSD Matching);% subplot(2,2,4), imshow(I_NCC); title(Normalized-CC);% Example 3D,% % Make some random data% I=rand(50,60,50);% % Get a small vo
7、lume 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 D.Kroon University of Twente (February 2011) i
8、f(nargin1) % Normalized cross correlation STD if(isempty(IdataIn) Idata.LocalSumI= local_sum(I,T_size); else Idata.LocalSumI=IdataIn.LocalSumI; end % Standard deviation if(isempty(IdataIn) Idata.stdI=sqrt(max(Idata.LocalQSumI-(Idata.LocalSumI.2)/numel(T),0) ); else Idata.stdI=IdataIn.stdI; end stdT=
9、sqrt(numel(T)-1)*std(T(:); % Mean compensation meanIT=Idata.LocalSumI*sum(T(:)/numel(T); I_NCC= 0.5+(Icorr-meanIT)./ (2*stdT*max(Idata.stdI,stdT/1e5); % Remove padding I_NCC=unpadarray(I_NCC,size(I);end function T=rot90_3D(T)T=flipdim(flipdim(flipdim(T,1),2),3); function B=unpadarray(A,Bsize)Bstart=
10、ceil(size(A)-Bsize)/2)+1;Bend=Bstart+Bsize-1;if(ndims(A)=2) B=A(Bstart(1):Bend(1),Bstart(2):Bend(2);elseif(ndims(A)=3) B=A(Bstart(1):Bend(1),Bstart(2):Bend(2),Bstart(3):Bend(3);end function local_sum_I= local_sum(I,T_size)% Add padding to the imageB = padarray(I,T_size); % Calculate for each pixel t
11、he sum of the region around it,% with the region the size of the template.if(length(T_size)=2) % 2D localsum s = cumsum(B,1); c = s(1+T_size(1):end-1,:)-s(1:end-T_size(1)-1,:); s = cumsum(c,2); local_sum_I= s(:,1+T_size(2):end-1)-s(:,1:end-T_size(2)-1);else % 3D Localsum s = cumsum(B,1); c = s(1+T_size(1):end-1,:,:)-s(1:end
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年中国全自动圆筒机行业市场发展前景及发展趋势与投资战略研究报告
- 2022-2027年中国林业及木材加工行业发展监测及投资战略研究报告
- 2024-2030年中国互联网卫星制造行业市场竞争格局及投资前景展望报告
- “健康运动活力无限”青少年健康运动俱乐部商业计划书
- 2020-2025年中国肉夹馍行业市场前景预测及投资战略研究报告
- 培训课件内容反馈
- 中国印刷用纸行业市场深度调查及发展前景研究预测报告
- 村级妇联培训课件
- 少儿财商培训课件
- 2024年全球及中国一次性使用负压引流敷料行业头部企业市场占有率及排名调研报告
- 四川省宜宾县2024届语文八下期末联考试题含解析
- 医务人员手卫生规范培训课件预防医院感染的手卫生措施
- 电缆敷设专项施工方案
- 儿童下支气管肺炎护理查房课件
- 仓库搬迁安全须知培训培训课件
- 机车高压电器-高压连接器
- 【课件】Unit+1Reading+and+thinking说课课件人教版必修第二册
- ic封装公司运营管理方案
- 软件项目管理 复习题(附参考答案)
- 有机电子学课件
- 我国煤机装备制造业发展现状与展望
评论
0/150
提交评论