disparitySGM
Compute disparity map through semi-global matching
Syntax
Description
computes disparity map from a pair of rectified stereo images disparityMap = disparitySGM(I1,I2)I1 and
I2, by using semi-global matching (SGM) method. To know more about
rectifying stereo images, see Image Rectification.
[
additionally returns the actual values of the disparity range used to estimate disparity,
which may differ from those provided using the disparityMap,disparityRangeUsed] = disparitySGM(I1,I2)DisparityRange
name-value argument.
___ = disparitySGM(
specifies additional options using one or more name-value pair arguments along with any of
the previous syntaxes.I1,I2,Name,Value)
Examples
Input Arguments
Name-Value Arguments
Output Arguments
More About
Tips
Ensure accurate rectification — Imperfect rectification can significantly degrade the quality of the disparitySGM function results. Use the
rectifyStereoImagesfunction to rectify the input stereo image pairI1andI2, so that the corresponding points are on the same rows. Use thestereoAnaglyphfunction to inspect the rectification results by creating an anaglyph image.Apply post-processing — For better results, improve disparity maps by applying image processing operations such as median filtering (
medfilt2), hole filling (imfill), or bilateral filtering (imbilatfilt).Explore deep learning-based alternatives — For well-rectified, narrow-baseline stereo setups where classical SGM struggles with texture-less regions or repeated patterns, try
opticalFlowRAFTas a deep learning-based alternative. For more information on comparison between classical SGM and RAFT deep learning model, see Compare RAFT Optical Flow and Semi-Global Matching for Stereo Reconstruction.
Algorithms
References
[1] Hirschmuller, H. "Accurate and Efficient Stereo Processing by Semi-Global Matching and Mutual Information." In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 807-814. San Diego, CA: IEEE, 2005.


