This filter performs pixel-wise 2D block-matching between a pair of image. This is especially useful in the case of stereo pairs in epipolar geometry, where displacements corresponding to differences of elevation occur in the horizontal direction only (in that case, the exploration along the vertical direction can be disabled). Please note that only integer pixel displacement are explored. For finer results, consider up-sampling the input images or use the SubPixelDisparityImageFilter.

The block-matching metric itself is defined by a template functor on neighborhood iterators. A wide range of block-matching criterions can be implemented this way, but the default functor performs a simple SSD (Sum of Square Distances). The radius of the blocks can be set using the SetRadius() method. The filter will try to minimize the metric value by default. Setting the minimize flag to off using the MinimizeOff() method will make the filter try to maximize the metric.

This filter has three outputs: the first is the metric image, which contains the metric optimum value corresponding to the estimated displacement. The second and last outputs are the horizontal and vertical disparity maps, which can be retrieved using the GetHorizontalDisparityOutput() and GetVerticalDisparityOutput() methods. They contain the horizontal and vertical local displacement between the two input images (displacement is given in pixels, from left image to right image).

Masks are not mandatory. A mask allows indicating pixels validity in either left or right image. Left and right masks can be used independently. If masks are used, only pixels whose mask values are strictly positive will be considered for disparity matching. The other will exhibit a null metric value and a disparity corresponding to the minimum allowed disparity.

The disparity exploration can also be reduced thanks to initial disparity maps. The user can provide initial disparity estimate (using the same image type and size as the output disparities), or global disparity values. Then an exploration radius indicates the disparity range to be explored around the initial estimate (global minimum and maximum values are still in use).