is the disparity obtained is sufficient for 3d recontruction?

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

is finding disparity with min value of disparity without shift,shifting to right , left is enough?
is the disparity obtained sufficient?
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.
1.convert to gray scale.
2.place right image above left and find difference
3.shift one image to right and find difference
4.shift to left and find difference
(these 3 are the disparity values without shift,with shift)
5.store minimum value of disparity
6.show disparity.
is the figure 'disp'obtained not the disparity???
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.
can i get existing matlab algoritms and programs?
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.
ya here i have found the differences,i thought minimum value of difference after shifting into right and left.i thought disparity means thw minimum difference in co ordinates after shifting
could you please tel me how to subtract the intensities and gradient information of the 2 images??
do i get the disparity matrix direcdtly by this subtraction??
so imsubtract gives me the disparity matrix directly??
No. It subtracts intensities. It answers:
"could you please tel me how to subtract the intensities and gradient information of the 2 images?"
The disparity is, roughly, the amount of shift that gives the minimum difference. It's not the difference itself.
ive read that subtracting intensities and gradient information gives disparity...
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).
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)

Asked:

on 6 Oct 2011

Community Treasure Hunt

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

Start Hunting!