• 大小: 2KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: C/C++
  • 标签: 块匹配  

资源简介

本代码运行于matlab环境,用C语言编写,是基于单独两帧的块匹配算法

资源截图

代码片段和文件信息

      
clear all
%tic
I=imread(‘m3.bmp‘);%%%%%3与18%%%%%%
J=imread(‘m18.bmp‘);
A=rgb2gray(I);
B=rgb2gray(J);
imshow(A);
figure imshow(B);
[mn]=size(A);
dx=6;
dy=6;
block1=B(10:5410:54);
block2=B(10:54n-55:n-11);
block3=B(m-55:m-1110:54);
block4=B(m-55:m-11n-55:n-11);
for i=-dx:dx
    for j=-dy:dy
        rblock1=A(10+i:54+i10+j:54+j);
         DB1=abs(block1-rblock1);
         SAD1(i+dx+1j+dy+1)=sum(sum(DB1));
         
        rblock2=A(10+i:54+in-55+j:n-11+j);
         DB2=abs(block2-rblock2);
         SAD2(i+dx+1j+dy+1)=sum(sum(DB2));
         
        rblock3=A(m-55+i:m-11+i10+j:54+j);
         DB3=abs(block3-rblock3);
         SAD3(i+dx+1j+dy+1)=sum(sum(DB3));
         
        rblock4=A(m-55+i:m-11+in-55+j:n-11+j);
         DB4=abs(block4-rblock4);
         SAD4(i+dx+1j+dy+1)=sum(sum(DB4));
    end
end

           min(min(SAD1));
           [rr1cc1]=find(SAD1==min(min(SAD1)));
           r1=rr1-dx-1;
           c1=cc1-dy-1;
           min(min(SAD2));
           [rr2cc2]=find(SAD2==min(min(SAD2)));
           r2=rr2-dx-1;
           c2=cc2-dy-1;
           min(min(SAD3));
           [rr3cc3]=find(SAD3==min(min(SAD3)));
      

评论

共有 条评论

相关资源