![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
Go to the source code of this file.
Data Structures | |
struct | L_Bilateral |
Typedefs | |
typedef struct L_Bilateral | L_BILATERAL |
Contains the following struct struct L_Bilateral For a tutorial introduction to bilateral filters, which apply a gaussian blur to smooth parts of the image while preserving edges, see http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.pdf We give an implementation of a bilateral filtering algorithm given in: "Real-Time O(1) Bilateral Filtering," by Yang, Tan and Ahuja, CVPR 2009 which is at: http://vision.ai.uiuc.edu/~qyang6/publications/cvpr-09-qingxiong-yang.pdf This is based on an earlier algorithm by Sylvain Paris and Frédo Durand: http://people.csail.mit.edu/sparis/publi/2006/eccv/ Paris_06_Fast_Approximation.pdf The kernel of the filter is a product of a spatial gaussian and a monotonically decreasing function of the difference in intensity between the source pixel and the neighboring pixel. The intensity part of the filter gives higher influence for pixels with intensities that are near to the source pixel, and the spatial part of the filter gives higher weight to pixels that are near the source pixel. This combination smooths in relatively uniform regions, while maintaining edges. The advantage of the appoach of Yang et al is that it is separable, so the computation time is linear in the gaussian filter size. Furthermore, it is possible to do much of the computation as a reduced scale, which gives a good approximation to the full resolution version but greatly speeds it up. The bilateral filtered value at x is: sum[y in N(x)]: spatial(|y - x|) * range(|I(x) - I(y)|) * I(y) I'(x) = -------------------------------------------------------------- sum[y in N(x)]: spatial(|y - x|) * range(|I(x) - I(y)|) where I() is the input image, I'() is the filtered image, N(x) is the set of pixels around x in the filter support, and spatial() and range() are gaussian functions: spatial(x) = exp(-x^2 / (2 * s_s^2)) range(x) = exp(-x^2 / (2 * s_r^2)) and s_s and s_r and the standard deviations of the two gaussians. Yang et al use a separable approximation to this, by defining a set of related but separable functions J(k,x), that we call Principal Bilateral Components (PBC): sum[y in N(x)]: spatial(|y - x|) * range(|k - I(y)|) * I(y) J(k,x) = ----------------------------------------------------------- sum[y in N(x)]: spatial(|y - x|) * range(|k - I(y)|) which are computed quickly for a set of n values k[p], p = 0 ... n-1. Then each output pixel is found using a linear interpolation: I'(x) = (1 - q) * J(k[p],x) + q * J(k[p+1],x) where J(k[p],x) and J(k[p+1],x) are PBC for which k[p] <= I(x) and k[p+1] >= I(x), and q = (I(x) - k[p]) / (k[p+1] - k[p]). We can also subsample I(x), create subsampled versions of J(k,x), which are then interpolated between for I'(x). We generate 'pixsc', by optionally downscaling the input image (using area mapping by the factor 'reduction'), and then adding a mirrored border to avoid boundary cases. This is then used to compute 'ncomps' PBCs. The 'spatial_stdev' is also downscaled by 'reduction'. The size of the 'spatial' array is 4 * (reduced 'spatial_stdev') + 1. The size of the 'range' array is 256.
Definition in file bilateral.h.