資源簡介
雙目立體視覺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
- 上一篇:雙目立體視覺快速NCC算法 matlab
- 下一篇:配電網遍歷算法.docx
評論
共有 條評論