A guided filter is an edge-preserving smoothing image filter.
As with a bilateral filter, it can filter out noise or texture while retaining sharp edges.
[1][2] Compared to the bilateral filter, the guided image filter has two advantages: bilateral filters have high computational complexity, while the guided image filter uses simpler calculations with linear computational complexity.
Bilateral filters sometimes include unwanted gradient reversal artifacts and cause image distortion.
The guided image filter is based on linear combination, making the output image consistent with the gradient direction of the guidance image, preventing gradient reversal.
One key assumption of the guided filter is that the relation between guidance
is a linear transformation of
In order to determine the linear coefficient
, constraints from the filtering input
in which: The reason to use a linear combination is that the boundary of an object is related to its gradient.
The local linear model ensures that
Subtract (1) and (2) to get formula (3);At the same time, define a cost function (4): (3)
in which And the cost function's solution is: (5)
in which After obtaining the linear coefficients
is provided by the following algorithm: By definition, the algorithm can be written as: input: filtering input image
is a mean filter with a wide variety of O(N) time methods.
The guided filter removes noise in the input image while preserving clear edges.
Specifically, a “flat patch” or a “high variance patch” can be specified by the parameter
Patches with variance much lower than the parameter
will be smoothed, and those with variances much higher than
The role of the range variance
in the bilateral filter is similar to
Both of them define the edge/high variance patches that should be kept and noise/flat patches that should be smoothed.” When using the bilateral filter to filter an image, artifacts may appear on the edges.
This is because of the pixel value's abrupt change on the edge.
These artifacts are inherent and hard to avoid, because edges appear in all kinds of pictures.
The guided filter performs better in avoiding gradient reversal.
Moreover, in some cases, it can be ensured that gradient reversal does not occur.
Due to the local linear model of
, it is possible to transfer the structure from the guidance
This property enables some special filtering-based applications, such as feathering, matting and dehazing.