1

I'm trying to implement the homogeneous transformation from the disparity image to the virtual disparity image, following the paper of Suganuma et. al. "An Obstacle Extraction Method Using Virtual Disparity Image". After doing the matrix computations described in the paper, I reach a global homogeneous transformation matrix that describes just a translation of -27.7 in the direction v, which makes sense.

Now, to make this transformation, I implemented a loop in MATLAB:

virtual_disparity=zeros(size(disparityMap));

%Homogeneous vector of a point of the disparityMap U=[u/d v/d 1/d 1]' (4x1)
U = zeros(4,1);
U_v = zeros(4,1);
for i=1:size(disparityMap,1)    %Rows-->y
    for j=1:size(disparityMap,2)    %Cols-->x
        d = disparityMap(i, j); % (i,j)-->(cols,rows)-->(y,x)
        U = [j/d i/d 1/d 1]'; % [u/d v/d 1/d 1]'
        U_v = B*U; % B is the whole homogeneous transform
        U_v = U_v./U_v(4);
        u_v_x = U_v(1);   %u_v_j
        u_v_y = U_v(2);   %u_v_i
        if((u_v_x>1) && (u_v_x<=size(virtual_disparity, 2)) && (u_v_y>1) && (u_v_y<=size(virtual_disparity, 1)))
            virtual_disparity(round(u_v_y), round(u_v_x)) = disparityMap(i, j);
        end
    end
end

Now, the problem is that the virtual disparity that I get doesn't make any sense, since it doesn't even corresponds with the transformation described in B, which, as I said is:

1.0000    0    0.0000         0
0    1.0000    0.0000  -27.7003
0         0    1.0000         0
0         0         0    1.0000

These are the disparity and the virtual disparity respectively:

Disparity Map: disparity map

Virtual Disparity: virtual disparity

I've been rechecking all day long and I don't find the error.

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
agregorio
  • 91
  • 1
  • 11
  • I never heard about "virtual disparity", so I admint this is a try, but I am thinking about homogenous coordinates. I think your transformation B has to be applied to a 3D-like homogeneous coordinate which should be like '[X,Y, Z, 1]' and not the "already normalized form" [X/Z, Y/Z, 1, 1/Z] (as you see if you normalize "before doing anything else" the last value cannot be 1). If I am talking about completely different, please be kind and explain this to me: I am courious! – marcoresk Oct 01 '16 at 16:44
  • @marcoresk I'm not normalizing it, since I do not divide the last element, which remains 1: `U = [j/d i/d 1/d 1]';`It is just that the method uses this coordinates, which incorporates info from the image pixel and the disparity (inversely proportional to the distance. I allready found what is wrong, which is related, but in the final coordinates. Thanks anyway. I have to go, I will post the answer today ;) – agregorio Oct 01 '16 at 16:51

1 Answers1

0

Finally, a colleage helped me and we found whats wrong. I was suposing that the final coordinates U_v would be given in the form [u v 0 1]', which actually doesn't make much sense. Actually they were given, as the input coordinates in the form [u/d v/d 1/d 1]'. So, instead of normalizing them dividing by the element 4, as I was doing, I must divide them by the element 3 (1/d). To sum up, it was just an error in the line:

U_v = U_v./U_v(4);

Which must be substituted by:

U_v = U_v./U_v(3);

Now the image, although is a little bit more sparse than I thought, it's similar to the one of the paper: Correct virtual disparity image

agregorio
  • 91
  • 1
  • 11