• 大小: 236KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: Matlab
  • 标签: Census  matlab  

资源简介

双目立体视觉Census算法 matlab

资源截图

代码片段和文件信息

clear all;
close all;
clc;

left=double(imread(‘left.bmp‘));
right=double(imread(‘right.bmp‘));
[m n]=size(left);
w=4;                                     %模板半径
depth=59;                                %最大偏移距离,同样也是最大深度距离
TL=cell(mn);                            %存储左右图像每个点Census变换后的字符串
TR=cell(mn);

for i=1+w:m-w                             %对左图进行Census变换
    for j=1+w:n-w
        lwin=left(i-w:i+wj-w:j+w);
        tL=cell(2*w+12*w+1);
        a=left(ij);
        b=sum(sum(lwin))/(2*w+1)/(2*w+1);
        t=0;
        for p=1:2*w+1                     %生成字符串矩阵
            for q=1:2*w+1
               t=t+abs(lwin(pq)-b);
            end
        end
        t=t/(2*w+1)/(2*w+1);
        
        c=‘1‘;
        for p=1:2*w+1                    
            for q=1:2*w+1
                if (lwin(pq)>=a)&(abs(lwin(pq)-b)<=t)
                   tL{pq}=‘00‘;
                elseif (lwin(pq)>=a)&(abs(lwin(pq)-b)>t)
                   tL{pq}=‘01‘;
                elseif (lwin(pq)                  tL{pq}=‘10‘;
                elseif (lwin(pq)t)
                   tL{pq}=‘11‘;
                end
                c=strcat(ctL(pq));
            end
        end
         
        
               
        TL(ij)=c;
    end
     
    
end    

   e=1
   
for i=1+w:m-w                             %对右图进行Census变换
    for j=1+w:n-w
        rwin=right(i-w:i+wj-w:j+w);
        tL=cell(2*w+12*w+1);
        a=right(ij);
        b=sum(sum(rwin))/(2*w+1)/(2*w+1);
        t=0;
        for p=1:2*w+1                    %生成字符串矩阵
            for q=1:2*w+1
               t=t+abs(rwin(pq)-b);
            end
        end
        t=t/(2*w+1)/(2*w+1);
        
        c=‘1‘;
        for p=1:2*w+1                    
            for q=1:2*w+1
                if (rwin(pq)>=a)&(abs(rwin(pq)-b)<=t)
                   tR{pq}=‘00‘;
                elseif (rwin(pq)>=a)&(abs(rwin(pq)-b)>t)
                   tR{pq}=‘01‘;
                elseif (rwin(pq)                  tR{pq}=‘10‘;
                elseif (rwin(pq)t)
                   tR{pq}=‘11‘;
                end
              c=strcat(ctR(pq)); 
            end
        end
               
        TR(ij)=c;
    end
    
end    

     
     e=2       
  
Cl=zeros(mndepth);
Cr=zeros(mndepth);
imagel=zeros(mn);
imager=zeros(mn);
image=zeros(mn);
e=ones(2*w+12*w+1);

                                             %求左海明距离
                    
  for k=1:depth 
       d=zeros(mn);

      for p=1+w:m-w
          for q=1+w+depth:n-w
              c=sum(abs(TL{pq}-TR{pq-k}));
              d(pq)=c;
          end
      end
     
      ccc=conv2(d(1+w:m-w1+w+depth:n-w)e‘valid‘);
           
      for  p=1:m-4*w
         for q=1:n-4*w-depth
            Cl(p+2*wq+2*w+depthk)=ccc(pq);
         en

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3340  2015-12-11 17:10  Census\Census.m

     文件     170578  2015-08-19 15:15  Census\left.bmp

     文件     170578  2015-08-19 15:15  Census\right.bmp

     目录          0  2017-01-21 15:44  Census

----------- ---------  ---------- -----  ----

               344496                    4


评论

共有 条评论