数字图像处理算法整理(7)
发布时间:2021-06-07
发布时间:2021-06-07
数字图像处
5.图像匹配
D=imread('C:\Users\Administrator\Desktop\zhengqiji.jpg'); B=imread('C:\Users\Administrator\Desktop\zhengqiji1.jpg'); D=rgb2gray(D); B=rgb2gray(B) [M,N]=size(D); [m,n]=size(B); D1=D(1:m,1:n); inital1=10000000000;
-----用原图像和小图像中矩阵的灰度值相减,后的累加和判断相似程度,找到匹配点---- for i=1:M-m+1 for j=1:N-n+1
D1=D(i:i+m-1,j:j+n-1); inital2=sum(sum(abs(D1-B)));
if inital1>inital2 inital1=inital2; ANSWER1=i; ANSWER2=j; end end end
-------------------------在原图像中显示方框,表示出小图像位置--------- data = imread('C:\Users\Administrator\Desktop\zhengqiji.jpg'); pointAll = [ANSWER1,ANSWER2]; windSize = [m,n];
[state,results]=draw_rect(data,pointAll,windSize); return;
-----------------------------方框显示函数------------------------(不用
上一篇:中国现代文学名词解释