is the disparity obtained is sufficient for 3d recontruction?

1 view (last 30 days)
please help..
  1. is my disparity obtained is correct?
  2. is my progran sufficient for 3d reconstruction intended for machine vision?
  3. how can i increase the accuracy?
  4. how can i generate x,y,z coordinates and 3d reconstruction from this?
data = video.ImageDataTypeConverter;
conv= video.ColorSpaceConverter('Conversion','RGB to intensity');
lftsingle = step(data,imread('TSUL.png'))
lftgray= step(conv,lftsingle);
rgtsingle = step(data,imread('TSUR.png'));
rgtgray = step(conv,rgtsingle);
figure(1);
imshow(lftsingle), title('left image');
figure(2), clf;
imshow(rgtsingle), title('right image');
figure(3), clf;
imshow(rgtgray), title('gray Right image');
figure(4), clf;
imshow(lftgray), title('gray left image');
figure(5), clf;
imshow(cat(3,rgtgray,lftgray,lftgray)),axis image;
title('merged image');
D = zeros(size(lftgray), 'single');
d = zeros(size(lftgray), 'single');
D2 = zeros(size(lftgray), 'single');
d3 = zeros(size(lftgray), 'single');
D4 = zeros(size(lftgray), 'single');
d4 = zeros(size(lftgray), 'single');
disparity = zeros(size(lftgray), 'single');
Z= zeros(size(lftgray), 'single');
N=size(lftgray,1)
M=size(lftgray,2)
% finding disparity without shifting
for m=1:N
for n=1:M
d(m,n)=lftgray(m,n)-rgtgray(m,n);
d(m,n)=abs(d(m,n));
end
end
%shifting to right
for m=1:N
for n=1:M
D2(m,n)=lftgray(m,mod((n-1),N)+1);
end
end
%finding disparity
for m=1:N
for n=1:M
d3(m,n)=D2(m,n)-rgtgray(m,n);
d3(m,n)=abs(d3(m,n));
end
end
%shifting to left
for m=1:N
for n=1:M
D4(m,n)=rgtgray(m,mod((n-1),N)+1);
end
end
%finding disparity
for m=1:N
for n=1:M
d4(m,n)=D4(m,n)-lftgray(m,n);
d4(m,n)=abs(d4(m,n));
end
end
%finding minimum of disparity
for m=1:N
for n=1:M
disp(m,n)=min(min(d(m,n),d3(m,n)),d4(m,n));
end
end
figure(6)
imshow(disp)
K = [409.4433 0 204.1225 ;0 416.0865 146.4133;0 0 1.0000];
%generating z coordinate Z=focal length*((1+stereobasline)/disparity))
for m=1:N
for n=1:M
Z(m,n)=(1+.567)/disp(m,n);
end
end
%for m=1:N
% for n=1:M
% image=rgtgray(m,n,z(m,n));
% end
%end
%3dimage=image
%figure(7)
%a=meshgrid(5)
%mesh(a)
  15 Comments
David Young
David Young on 18 Oct 2011
Yes, there is a gradient-based family of algorithms. You have to divide the temporal gradient by the spatial gradient and adopt a way to address the aperture problem. It's not sensible to try to set out details here - the approach is in textbooks and Wikipedia (look up Horn-Schunck method for example), and there is code on the file exchange (e.g contribution 41349).
Keta shah
Keta shah on 22 Mar 2013
how to sove this error which was generated during the run of above code..
Undefined variable "video" or function "video.ImageDataTypeConverter".
Error in t1 (line 1) data = video.ImageDataTypeConverter;

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!