Pixel-wise Block-Matching
Brief Description
Performs block-matching to estimate pixel-wise disparities between two images.
Tags
Stereo
Long Description
This application allows one to performs block-matching to estimate pixel-wise disparities for a pair of images in epipolar geometry.
This application is part of the stereovision pipeline. It can be used after having computed epipolar grids (with StereoRectificationGridGenerator) and resampled each input image into epipolar geometry (with GridBasedImageResampling).
The application searches locally for the displacement between a reference image and a secondary image. The correspondence is evaluated for each pixel, based on a pair of local neighborhood windows. The displacement evaluated can be 1D (along lines) or 2D. Parameters allow setting the minimum and maximum disparities to search (both for horizontal and vertical directions). A winner-take-all approach is used to select the best match. There are different metrics implemented to evaluate the match between two local windows:
* SSD : Sum of Squared Distances
* NCC : Normalized Cross-Correlation
* Lp : Lp pseudo norm
Once the best integer disparity is found, an optional step of sub-pixel disparity estimation can be performed, with various algorithms (triangular interpolation, parabollic interpolation, dichotimic search). As post-processing, there is an optional step of median filtering on the disparities. One can chose input masks (related to the left and right input image) of pixels for which the disparity should be investigated. Additionally, two criteria can be optionally used to disable disparity investigation for some pixel: a no-data value, and a threshold on the local variance. This allows one to speed-up computation by avoiding to investigate disparities that will not be reliable anyway. For efficiency reasons, if the image of optimal metric values is desired, it will be concatenated to the output image (which will then have three bands : horizontal disparity, vertical disparity and metric value). One can split these images afterward.
Parameters
Input and output data (io): This group of parameters allows setting the input and output images.
Left input image (io.inleft): The left input image (reference).
It should have the same size and same physical space as the right input. This image can be generated by GridBasedImageResampling
Right input image (io.inright): The right input (secondary).
It should have the same size and same physical space as the left input. This image can be generated by GridBasedImageResampling
The output disparity map (io.out): An image containing the estimated disparities as well as the metric values if the option is used. If no metric is output and no sub-pixel interpolation is done, pixel type canbe a signed integer. In the other cases, floating point pixel is advised.
The output mask corresponding to all criterions (io.outmask): An output mask image corresponding to all citerions (see masking parameters). Only required if variance threshold or nodata criterions are set. Output pixel type is unsigned 8bit by default.
Flag to output optimal metric values as well (io.outmetric): If enabled, the output image will have a third component with metric optimal values
Image masking parameters (mask): This group of parameters allows determining the masking parameters to prevent disparities estimation for some pixels of the left image
Mask to discard left pixels (mask.inleft): This parameter allows providing a custom mask for the left image. Block matching will be only perform on pixels inside the mask (non-zero values).
Mask to discard right pixels (mask.inright): This parameter allows providing a custom mask for the right image. Block matching will be perform only on pixels inside the mask (non-zero values).
Discard pixels with no-data value (mask.nodata): This parameter allows discarding pixels whose value is equal to the user-defined no-data value.
Discard pixels with low local variance (mask.variancet): This parameter allows discarding pixels whose local variance is too small (the size of the neighborhood is given by the radius parameter)
Block matching parameters (bm): This group of parameters allow tuning the block-matching behaviour
Block-matching metric (bm.metric): Metric to evaluate matching between two local windows.
Sum of Squared Distances (ssd): Sum of squared distances between pixels value in the metric window
Normalized Cross-Correlation (ncc): Normalized Cross-Correlation between the left and right windows
Lp pseudo-norm (lp): Lp pseudo-norm between the left and right windows.
p value (bm.metric.lp.p): Value of the p parameter in Lp pseudo-norm (must be positive).
Radius of blocks (bm.radius): The radius (in pixels) of blocks in Block-Matching
Minimum horizontal disparity (bm.minhd): Minimum horizontal disparity to explore (can be negative)
Maximum horizontal disparity (bm.maxhd): Maximum horizontal disparity to explore (can be negative)
Minimum vertical disparity (bm.minvd): Minimum vertical disparity to explore (can be negative)
Maximum vertical disparity (bm.maxvd): Maximum vertical disparity to explore (can be negative)
Sub-pixel interpolation (bm.subpixel): Estimate disparities with sub-pixel precision
None (none): No sub-pixel search
Parabolic fit (parabolic): The metric values closest to the best match are used in order to fit a parabola to the local extremum of the metric surface. The peak position of this parabola is output.
Triangular fit (triangular): The metric values closest to the best match are used in order to fit a triangular peak to the local extremum of the metric surface. The peak position of this triangle is output.
Dichotomy search (dichotomy): An iterative dichotomic search is performed to find the best sub-pixel position. The window in the right image is resampled at sub-pixel positions to estimate the match.
Computation step (bm.step): Location step between computed disparities. Disparities will be computed every 'step' pixels in the left image (step for both rows and columns). For instance, a value of 1 corresponds to the classic dense disparity map.
X start index (bm.startx): X start index of the subsampled grid (wrt the input image grid). See parameter bm.step
Y start index (bm.starty): Y start index of the subsampled grid (wrt the input image grid). See parameter bm.step
Median filtering of disparity map (medianfilter): Use a median filter to get a smooth disparity map
Radius (bm.medianfilter.radius): Radius (in pixels) for median filter
Incoherence threshold (bm.medianfilter.incoherence): Incoherence threshold between original and filtered disparity
Initial disparities (bm.initdisp):
None (none): No initial disparity used
Uniform initial disparity (uniform): Use an uniform initial disparity estimate
Horizontal initial disparity (bm.initdisp.uniform.hdisp): Value of the uniform horizontal disparity initial estimate (in pixels)
Vertical initial disparity (bm.initdisp.uniform.vdisp): Value of the uniform vertical disparity initial estimate (in pixels)
Horizontal exploration radius (bm.initdisp.uniform.hrad): Horizontal exploration radius around the initial disparity estimate (in pixels)
Vertical exploration radius (bm.initdisp.uniform.vrad): Vertical exploration radius around the initial disparity estimate (in pixels)
Initial disparity maps (maps): Use initial disparity maps to define the exploration area. This area in the right image is centered on the current position shifted by the initial disparity estimate, and has a given exploration radius in horizontal and vertical directions.
Horizontal initial disparity map (bm.initdisp.maps.hmap): Map of the initial horizontal disparities
Vertical initial disparity map (bm.initdisp.maps.vmap): Map of the initial vertical disparities
Horizontal exploration radius (bm.initdisp.maps.hrad): Horizontal exploration radius around the initial disparity estimate (in pixels)
Vertical exploration radius (bm.initdisp.maps.vrad): Vertical exploration radius around the initial disparity estimate (in pixels)
Available RAM (Mb) (ram): Available memory for processing (in MB)
Load otb application from xml file (inxml): Load otb application from xml file
Save otb application to xml file (outxml): Save otb application to xml file
Limitations
None
Authors
OTB-Team
See also
[1] StereoRectificationGridGenerator
[2] GridBasedImageResampling
Example of use
io.inleft: StereoFixed.png
io.inright: StereoMoving.png
bm.minhd: -10
bm.maxhd: 10
mask.variancet: 10
io.out: MyDisparity.tif
otbcli_BlockMatching -io.inleft StereoFixed.png -io.inright StereoMoving.png -bm.minhd -10 -bm.maxhd 10 -mask.variancet 10 -io.out MyDisparity.tif