Guided filter

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

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]

Comparison

[edit | edit source]

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.

Definition

[edit | edit source]

One key assumption of the guided filter is that the relation between guidance I and the filtering output q is linear. Suppose that q is a linear transformation of I in a window ωk centered at the pixel k.

In order to determine the linear coefficient (ak,bk), constraints from the filtering input p are required. The output q is modeled as the input p with unwanted components n, such as noise/textures subtracted.

The basic model:

(1)  qi=akIi+bk,iωk

(2)  qi=pini

in which:

qi is the ith output pixel;
pi is the ith input pixel;
ni is the ith pixel of noise components;
Ii is the ith guidance image pixel;
(ak,bk) are some linear coefficients assumed to be constant in ωk.

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 q has an edge only if I has an edge, since q=aI.

Subtract (1) and (2) to get formula (3);At the same time, define a cost function (4):

(3)  ni=piakIibk

(4)  E(ak,bk)=iϵωk((akIi+bkpi)2+ϵak2)

in which

ϵ is a regularization parameter penalizing large ak;
ωk is a window centered at the pixel k.

And the cost function's solution is:

(5)  ak=1|ω|iϵωkIipiμkpk¯σk2+ϵ

(6)  bk=pk¯akμk

in which

μk and σk2 are the mean and variance of I in ωk;
|ω| is the number of pixels in ωk;
p¯k=1|ω|iϵωkpi is the mean of p in ωk.

After obtaining the linear coefficients (ak,bk), the filtering output qi is provided by the following algorithm:

Algorithm

[edit | edit source]

By definition, the algorithm can be written as:

Algorithm 1. Guided Filter

[edit | edit source]

input: filtering input image p ,guidance image I ,window radius r ,regularization ϵ

output: filtering output q

1.

meanI = fmean(I)
meanp = fmean(p)
corrI = fmean(I.*I)
corrIp = fmean(I.*p)

2.

varI = corrImeanI.*meanI
covIp = corrIpmeanI.*meanp

3.

a = covIp./(varI+ϵ)
b = meanpa.*meanI

4.

meana = fmean(a)
meanb = fmean(b)

5.

q = meana.*I+meanb

fmean is a mean filter with a wide variety of O(N) time methods.

Properties

[edit | edit source]

Edge-preserving filtering

[edit | edit source]

When the guidance image I is the same as the filtering input p. 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 ϵ of the guided filter. Patches with variance much lower than the parameter ϵ will be smoothed, and those with variances much higher than ϵ will be preserved. The role of the range variance σr2 in the bilateral filter is similar to ϵ in the guided filter. Both of them define the edge/high variance patches that should be kept and noise/flat patches that should be smoothed.”

Gradient-preserving filtering

[edit | edit source]

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.

Structure-transferring filtering

[edit | edit source]

Due to the local linear model of q=aI+b, it is possible to transfer the structure from the guidance I to the output q. This property enables some special filtering-based applications, such as feathering, matting and dehazing.

Implementations

[edit | edit source]

See also

[edit | edit source]

References

[edit | edit source]
  1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ Guided Image Filtering
  3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).