M-File Help: istereo | View code for istereo |
Stereo matching
d = istereo(left, right, H, range, options) is a disparity image computed from the epipolar aligned stereo pair: the left image left (HxW) and the right image right (HxW). d (HxW) is the disparity and the value at each pixel is the horizontal shift of the corresponding pixel in IML as observed in IMR. That is, the disparity d=d(v,u) means that the pixel at right(v,u-d) is the same world point as the pixel at left(v,u).
H is the half size of the matching window, which can be a scalar for NxN or a 2-vector [N,M] for an NxM window.
range is the disparity search range, which can be a scalar for disparities in the range 0 to range, or a 2-vector [DMIN DMAX] for searches in the range DMIN to DMAX.
[d,sim] = istereo(iml, imr, w, range, options) as above but returns sim which is the same size as d and the elements are the peak matching score for the corresponding elements of d. For the default matching metric ZNCC this varies between -1 (very bad) to +1 (perfect).
[d,sim,dsi] = istereo(iml, imr, w, range, options) as above but returns dsi which is the disparity space image (HxWxN) where N=DMAX-DMIN+1. The I'th plane is the similarity of iml to imr shifted to the left by DMIN+I-1.
[d,sim,p] = istereo(iml, imr, w, range, options) if the 'interp' option is given then disparity is estimated to sub-pixel precision using quadratic interpolation. In this case d is the interpolated disparity and p is a structure with elements A, B, dx. The interpolation polynomial is s = Adˆ2 + Bd + C where s is the similarity score and d is disparity relative to the integer disparity at which s is maximum. p.A and p.B are matrices the same size as d whose elements are the per pixel values of the interpolation polynomial coefficients. p.dx is the peak of the polynomial with respect to the integer disparity at which s is maximum (in the range -0.5 to +0.5).
'metric', M | string that specifies the similarity metric to use which is one of 'zncc' (default), 'ncc', 'ssd' or 'sad'. |
'interp' | enable subpixel interpolation and D contains non-integer values (default false) |
Load the left and right images
L = iread('rocks2-l.png', 'reduce', 2); R = iread('rocks2-r.png', 'reduce', 2);
then compute stereo disparity and display it
d = istereo(L, R, [40, 90], 3); idisp(d);
© 1990-2012 Peter Corke.