# Birchfield–Tomasi dissimilarity

In computer vision, the Birchfield–Tomasi dissimilarity is a pixelwise image dissimilarity measure that is robust with respect to sampling effects. In the comparison of two image elements, it fits the intensity of one pixel to the linearly interpolated intensity around a corresponding pixel on the other image. It is used as a dissimilarity measure in stereo matching, where one-dimensional search for correspondences is performed to recover a dense disparity map from a stereo image pair.

## Description

When performing pixelwise image matching, the measure of dissimilarity between pairs of pixels from different images is affected by differences in image acquisition such as illumination bias and noise. Even when assuming no difference in these aspects between an image pair, additional inconsistencies are introduced by the pixel sampling process, because each pixel is a sample obtained integrating the continuous light signal over a finite region of space, and two pixels matching the same feature of the image content may correspond to slightly different regions of the real object that can reflect light differently and can be subject to partial occlusion, depth discontinuity, or different lens defocus, thus generating different intensity signals.
The Birchfield–Tomasi measure compensates for the sampling effect by considering the linear interpolation of the samples. Pixel similarity is then determined by finding the best match between the intensity of a pixel sample in one image and the interpolated function in an interval around a location in the other image.
Considering the stereo matching problem for a rectified stereo pair, where the search for correspondences is performed in one dimension, given two columns $x_{l}$ and $x_{r}$ along the same scanline for the left and right image respectively, it is possible to define two symmetric functions
    ${\begin{aligned}d_{l}(x_{l},x_{r})&=\min _{x_{r}-{\frac {1}{2}}\leq x\leq x_{r}+{\frac {1}{2}}}\left|I_{l}(x_{l})-{\hat {I}}_{r}(x)\right|\\d_{r}(x_{l},x_{r})&=\min _{x_{l}-{\frac {1}{2}}\leq x\leq x_{l}+{\frac {1}{2}}}\left|{\hat {I}}_{l}(x)-I_{r}(x_{r})\right|\end{aligned}}$
where ${\hat {I}}_{l}$ and ${\hat {I}}_{r}$ are the linear interpolation functions of the left and right image intensity $I_{l}$ and $I_{r}$ along the scanline. The Birchfield–Tomasi dissimilarity can then be defined as
    $d(x_{l},x_{r})=\min \left\{d_{l}(x_{l},x_{r}),d_{r}(x_{l},x_{r})\right\}.$
In practice the measure can be computed with only a small and constant overhead with respect to the calculation of the simple intensity difference, because it is not necessary to reconstruct the interpolant function. Given that the interpolant is linear within each unit interval centred around a pixel, its minimum is located in one of its extremities. Therefore, $d_{l}(x_{l},x_{r})$ can be written as
    $d_{l}(x_{l},x_{r})=\max \left\{0,I_{l}(x_{l})-I_{max},I_{min}-I_{l}(x_{l})\right\}$
where
    ${\begin{aligned}I_{max}&=\max \left\{I_{r}(x_{r}),I_{r}^{+}(x_{r}),I_{r}^{-}(x_{r})\right\}\\I_{min}&=\min \left\{I_{r}(x_{r}),I_{r}^{+}(x_{r}),I_{r}^{-}(x_{r})\right\}\end{aligned}}$
denoting with $I_{r}^{+}(x_{r})$ and $I_{r}^{-}(x_{r})$ the values of the interpolated intensities at the rightmost and leftmost extremities of a one-pixel interval centred around $x_{r}$
    ${\begin{aligned}I_{r}^{+}(x_{r})&={\frac {1}{2}}\left(I_{r}(x_{r})+I_{r}(x_{r}+1)\right)\\I_{r}^{-}(x_{r})&={\frac {1}{2}}\left(I_{r}(x_{r}-1)+I_{r}(x_{r})\right).\end{aligned}}$
The other function $d_{r}(x_{l},x_{r})$ can be similarly rewritten, completing the expression for $d$.