is the disparity obtained is sufficient for 3d recontruction?
Show older comments
please help..
- is my disparity obtained is correct?
- is my progran sufficient for 3d reconstruction intended for machine vision?
- how can i increase the accuracy?
- 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
neenu jose
on 15 Oct 2011
David Young
on 15 Oct 2011
I don't understand how this computes disparity at all. Perhaps if you explain the algorithm you are implementing, and focus on one question, it might be possible to help.
neenu jose
on 16 Oct 2011
David Young
on 16 Oct 2011
I think you are computing image differences, not disparities. See <http://en.wikipedia.org/wiki/Binocular_disparity binocular disparity in Wikipedia> for a definition, and also suggestions of algorithms.
neenu jose
on 17 Oct 2011
David Young
on 17 Oct 2011
Sure - I think the new Computer Vision Toolbox may well have material that helps, though I'm not yet familiar with it, and there is certainly stuff on the file exchange. For example, if you search under my contributions, you'll find a couple of programs that measure disparity in different ways - but lots of other people have also written such programs, and you may need to experiment to find the one best suited to your needs. When you're searching, note that finding optic flow is essentially the same problem.
neenu jose
on 17 Oct 2011
neenu jose
on 17 Oct 2011
Sean de Wolski
on 17 Oct 2011
imsubtract
neenu jose
on 17 Oct 2011
Sean de Wolski
on 17 Oct 2011
No. It subtracts intensities. It answers:
"could you please tel me how to subtract the intensities and gradient information of the 2 images?"
David Young
on 17 Oct 2011
The disparity is, roughly, the amount of shift that gives the minimum difference. It's not the difference itself.
neenu jose
on 18 Oct 2011
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
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;
Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!