Main Content

estimateStereoRectification

Uncalibrated stereo rectification

Since R2022b

Description

[tform1,tform2] = estimateStereoRectification(F,inlierPoints1,inlierPoints2,imageSize) returns projective transformations for rectifying stereo images. This function does not require intrinsic or extrinsic camera parameters.

example

Examples

collapse all

Load the stereo images and feature points which are already matched.

I1 = imread("yellowstone_left.png");
I2 = imread("yellowstone_right.png");
load yellowstone_inlier_points;

Display point correspondences. Notice that the matching points are in different rows, indicating that the stereo pair is not rectified.

showMatchedFeatures(I1,I2,inlier_points1,inlier_points2,"montage");
title("Original Images and Matching Feature Points");

Figure contains an axes object. The hidden axes object with title Original Images and Matching Feature Points contains 4 objects of type image, line. One or more of the lines displays its values using only markers

Calculate the fundamental matrix from the corresponding points.

f = estimateFundamentalMatrix(inlier_points1,inlier_points2, ...
    "Method","Norm8Point");

Calculate the rectification transformations.

[tform1,tform2] = estimateStereoRectification(f,inlier_points1,...
    inlier_points2,size(I2));

Rectify the stereo images using projective transformations tform1 and tform2.

[I1Rect,I2Rect] = rectifyStereoImages(I1,I2,tform1,tform2);

Display the stereo anaglyph, which can also be viewed with 3-D glasses.

figure
imshow(stereoAnaglyph(I1Rect,I2Rect))

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Fundamental matrix for the stereo images, specified as a 3-by-3 matrix. The fundamental matrix satisfies this criteria for P1, a point in image 1, and P2, a corresponding point in image 2:

[P2,1] * F * [P1,1]' = 0

Data Types: single | double

Coordinates of points in image 1, specified as an M-by-2 matrix of M number of [x y] coordinates, or as one of the point feature objects described in Point Feature Types.

Coordinates of corresponding points in image 2, specified as an M-by-2 matrix of M number of [x y] coordinates, or as one of the point feature objects described in Point Feature Types.

Size of image 2, specified as a numeric vector in the format returned by the size function.

Output Arguments

collapse all

Projective transformation 1 describing the projective transformations for input image 1, returned as a projtform2d object.

Projective transformation 2 describing the projective transformations for input image 2, returned as a projtform2d object.

Tips

  • Applying the output uncalibrated rectification of tform1 (or tform2) to image 1 (or image 2) can result in an undesired distortion if an epipole exists within the image. You can check for an epipole within an image by applying the isEpipoleInImage function.

References

[1] Hartley, Richard, and Andrew Zisserman. Multiple View Geometry in Computer Vision. 2nd ed. Cambridge, UK ; New York: Cambridge University Press, 2003.

[2] Pollefeys, M., Koch, R., and Van Gool, L.. A Simple and Efficient Rectification Method for General Motion. Proceedings of the Seventh IEEE International Conference on Computer Vision. Volume 1, pages 496-501. 1999. DOI:10.1109/ICCV.1999.791262.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2022b

expand all