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
I
q
q
I
\omegak
k
In order to determine the linear coefficient
(ak,bk)
p
q
p
n
The basic model:
(1)
qi=akIi+bk,\foralli\in\omegak
(2)
qi=pi-ni
in which:
qi
ith
pi
ith
ni
ith
Ii
ith
(ak,bk)
\omegak
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
I
\nablaq=a\nablaI
Subtract (1) and (2) to get formula (3);At the same time, define a cost function (4):
(3)
ni=pi-akIi-bk
(4)
E(ak,bk)=\sumi{\epsilon{\omega}k
in which
\epsilon
ak
\omegak
k
And the cost function's solution is:
(5)
ak=
| |||||||||
(6)
bk=\bar{pk
in which
\muk
2 | |
\sigma | |
k |
I
\omegak
\left|\omega\right|
\omegak
\bar{p}k=
1 | |
\left|\omega\right| |
\sum | |
i\epsilon\omegak |
pi
p
\omegak
After obtaining the linear coefficients
(ak,bk)
qi
By definition, the algorithm can be written as:
input: filtering input image
p
I
r
\epsilon
output: filtering output
q
1.
meanI
fmean(I)
meanp
fmean(p)
corrI
fmean(I.*I)
corrIp
fmean(I.*p)
2.
varI
corrI-meanI.*meanI
covIp
corrIp-meanI.*meanp
3.
a
covIp./(varI+\epsilon)
b
meanp-a.*meanI
4.
meana
fmean(a)
meanb
fmean(b)
5.
q
meana.*I+meanb
fmean
When the guidance image
I
p
Specifically, a “flat patch” or a “high variance patch” can be specified by the parameter
\epsilon
\epsilon
\epsilon
2 | |
\sigma | |
r |
\epsilon
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
q=aI+b
I
q