bilateral_filter
bilateral_filter
1. 1. 1. algrithm_introduction
1.1 1.1 1.1 gaussian_linear_filter
1.1.1 1.1.1 1.1.1 guassian_function
The Gaussian Linear Filter functin is the basic filter function at spacial denoising, though not function well at edge preserving. To apply, we need to do a set of steps.
First of all, I want to introduce the gaussian function, as follow.
G σ ( x ) = e x p − x 2 2 σ 2 (1.1.1.1) G_{\sigma}(x) = exp^{- \frac{x^2}{2\sigma^2}} \tag{1.1.1.1} Gσ(x)=exp−2σ2x2(1.1.1.1)
maybe the unvisible expression is too difficult to understand, so we can plot gaussian function on MATLAB, code is given.
In the gragh, we can learn that guassian function empower a much larger value to the center part of the gragh, while empower a much smaller value to the surrouding areas.
f i g . 1.1.1.1 fig. 1.1.1.1 fig.1.1.1.1 The right figure is guassian function plot on 2-dimension, the left fighre is guassian function plot on 3-dimension. The parameter σ \sigma σ of gaussian function in left pic is σ = 0.2 , 0.4 , 0.6 , 0.8 \sigma = 0.2, 0.4, 0.6, 0.8 σ=0.2,0.4,0.6,0.8. The parameter σ \sigma σ of guassian function in right pic is σ = 2 \sigma = 2 σ=2.
%% plot 2-dimension gaussian-function
x = [-5: 0.1: 5];
gaussian = @(x, sigma) exp((-x.^2) ./ (2*sigma^2));
y = zeros(size(x));
figure(1);
for i = 1: 4
y = gaussian(x, 0.2 * i);
subplot(2, 2, i);
plot(x, y);
end
%% plot 3-dimension gaussian-function
x = [-5: 0.1: 5];
map = zeros(size(x, 2), size(x, 2));
figure(2);
for i = 1: size(x, 2)
for j = 1: size(x, 2)
map(i, j) = x(i)^2 + x(j)^2;
end
end
mesh(x, x, gaussian(map, 2));
1.1.2 1.1.2 1.1.2 apply guassian function to filter
It is avaliable to get the empower map through guassian function, then we can apply it to a filter to carry some computational photogragh task like denoising. Here we gave the filter epxpression as follow.
G σ ( f ) ( x ) = 1 Z ∑ y G σ ( x − y ) f ( y ) (1.1.2.1) G_{\sigma}(f)(x) = \frac{1}{Z}\sum_{y}{G_{\sigma}(x - y)f(y)} \tag{1.1.2.1} Gσ(f)(x)=Z1y∑Gσ(x−y)f(y)(1.1.2.1)
In this function Z = ∑ y G σ ( y ) Z = \sum_{y}G_{\sigma}(y) Z=∑yGσ(y), always we standlize all value in f ( y ) f(y) f(y) to make Z = 1 Z = 1 Z=1.
To understand expression 1.1.2.1 1.1.2.1 1.1.2.1 , I want to have the aid of some concept in coputational photogragh. If we see x x x as target pixel, which have some noise in it. To denoise it, we can reference the surrounding pixels to repower the value to pixel x x x. Moreover, we often apply surrounding pixels in a squre.
Suspend v a l m , n val_{m, n} valm,n is value matrix of pixel x x x's surrounding pixels, G m , n G_{m, n} Gm,n is gaussian function matrix. Sum of G m , n G_{m, n} Gm,n equals 1 1 1.Apply G m , n G_{m, n} Gm,n to v a l m , n val_{m, n} valm,n, output the denoising temp martrix. After a series of steps, we can get the value of pixel x x x. Details as follow.
G u a s s i a n ( x ) m , n = v a l m , n . ∗ G m , n Guassian(x)_{m, n} = val_{m,n} .*G_{m, n} Guassian(x)m,n=v