代码拉取完成,页面将自动刷新
同步操作将从 luofl/Depth-Estimation-Matlab 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
function [Disp_Img intmed] = dynamic_prog_stereo(L,R);
%L = imread('tsukuba_l.ppm');
%R = imread('tsukuba_r.ppm');
L = rgb2gray(L);%left image
R = rgb2gray(R);%right image
[si1 si2] = size(L);%size of left image
%%find cost matrix
sigma = 2;
c_o = 1;
D_Image = zeros(si1,si2);
disp('dynamic programming part')
%disp('building cost matrix first')
L1 = padarray(L,[1 1],'both');
R1 = padarray(R,[1 1],'both');
Disp_Img = zeros(size(L));
intmed = [];
for i=2:size(L1,1)-1
rw = i
cost_mat = [];
for j=2:size(L1,2)-1
clm=j;
leftpixel = L1(i-1:i+1,j-1:j+1);
%leftpix = L(i,j);
[match_score] = match_cost(leftpixel,rw,clm,R1);
cost_mat = vertcat(cost_mat,match_score);
end
[M D] = Build_cost(cost_mat);
%intmed = cat(3,intmed,M);
[list_y] = Back_track(M);
Disp_Img(i-1,:) = list_y;
end
% for i=1:size(Disp_Img,1)
% for j=1:size(Disp_Img,2)
% if Disp_Img(i,j)>15
% Disp_Img(i,j)=15;
% end
% end
% end
figure,imshow(abs(Disp_Img),[])
title('disparitymap with patch size 3x3 and SSD')
%imwrite(Disp_Img,'dispMap.tif')
for i=1:size(Disp_Img,1)
for j=1:size(Disp_Img,2)
depthMap(i,j) = 1/Disp_Img(i,j);
end
end
figure,imshow(depthMap,[])
title('depthmap')
%imwrite(depthMap,'depthMap.tif')
% size(cost_mat)
% Cum_M = zeros(size(cost_mat));
% Cum_M(1,:) = cost_mat(1,:);
% M = zeros(size(cost_mat));
% %% cost matrix c(l-1,r) + beta , c(l-1,r-1)+cost_mat(l,r) , c(l,r-1)+beta
%
% size(Cum_M)
% disp('cumulative cost matrix created')
% disp('applying dynamic programming')
% figure,imshow(cost_mat)
% figure,imshow(Cum_M,[])
% figure,imshow(M,[])
% [list_y] = optimal_path(M);
%figure,imshow(list_y,[])
% size(list_y)
%list_y
% for i=1:si1
% for j=1:si2
% dispImg(i,j) = list_y(i*j);
% end
% end
% figure,imshow(dispImg,[])
% figure,imagesc(D_Image)
% title('disarity Image')
% figure,imshow(D_Image,[min(min(D_Image)) max(max(D_Image))])
% title('disarity Image2')
% [siz1 siz2] = size(D_Image);
% l = si1;
% m = si2;
% dispr = zeros(size(D_Image));
% for l=2:siz1
% for m=2:siz2
%
%
% A = [(dispr(l-1,m-1)+D_Image(l,m)) (dispr(l-1,m)+c_o) (dispr(l,m-1)+c_o)];
% [rl cl] = min(A);
% dispr(l,m)=rl;
% end
% end
% size(dispr)
% imshow(dispr)
%
%size(D_Image)
% cost_mat = zeros(size(match_mat));
% cost_mat(1,1) = match_mat(1,1);
% for i=2:si1
% for j=2:si2
% cost_mat(i,j) =
%
%
% disparityImage = zeros(si1,si2);
% disparityImage(1,1) =
% while l~=0 && m~=0
%
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。