Image processing, 2006, lingrand@polytech.unice.fr
1
Filtering images restoration University of the Philippines - - - PowerPoint PPT Presentation
Filtering images restoration University of the Philippines - Diliman 2006 Diane Lingrand lingrand@polytech.unice.fr http://www.polytech.unice.fr/~lingrand 1 Image processing, 2006, lingrand@polytech.unice.fr Noise : causes and modeling
Image processing, 2006, lingrand@polytech.unice.fr
1
Image processing, 2006, lingrand@polytech.unice.fr
2
Image processing, 2006, lingrand@polytech.unice.fr
3
Image processing, 2006, lingrand@polytech.unice.fr
4
Image processing, 2006, lingrand@polytech.unice.fr
5
Image processing, 2006, lingrand@polytech.unice.fr
6 http://memory.loc.gov/ ammem/awlhtml/awlhome.html
Image processing, 2006, lingrand@polytech.unice.fr
7
– Under- or over-lighting – Sensors disturbance
– Distorsions (geometrical, intensity)
– Aliasing effect (out of validity bound of Nyquist-Shannon) – Objects for which the size is the same as the pixel size: salt and pepper noise
– Clouds in satellite images, …
– 256 grey levels: not really a limiting factor for human visual system -- or less
– Data loss, data corruption
Image processing, 2006, lingrand@polytech.unice.fr
8
image frequencies) => low-pass filtering
– Impulse noise: white Gaussian, exponential... – Salt and pepper noise
Image processing, 2006, lingrand@polytech.unice.fr
9
– Often expressed as a percentage p (0p1)
– method: int nextInt(int n) gives an integer in [0 n[, with uniform distribution – 2 methods :
and w*h/p others to be changed to WHITE
change pixel to WHITE, if 1 change it to BLACK
Image processing, 2006, lingrand@polytech.unice.fr
10
Original image Noisy salt and papper image with p(white) =p(black)=5%
Image processing, 2006, lingrand@polytech.unice.fr
11
Image processing, 2006, lingrand@polytech.unice.fr
12
– in Java : import java.util.Random; The public method double Random.nextGaussian() is a Gaussian random value with mean 0 and standard deviation 1 : to be multiplied by σ – in C/C++: use rand() from C system library
Image processing, 2006, lingrand@polytech.unice.fr
13
struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); srand(tv.tv_usec);
rand()/(RAND_MAX+1.0f);
b = rand()/(RAND_MAX+1.0f); if(b < epsilon) b = epsilon; c = rand()/(RAND_MAX+1.0f); a = -2.0 * Math::log(b); if(a < 0.0) a = 0.0; else a *= Math::cos(2.0 * Math::pi * c);
Image processing, 2006, lingrand@polytech.unice.fr
14
Original image Noisy image with a Gaussian noise (std dev 4)
Image processing, 2006, lingrand@polytech.unice.fr
15
Standard deviation = 8 Standard deviation = 16
Image processing, 2006, lingrand@polytech.unice.fr
16
Image processing, 2006, lingrand@polytech.unice.fr
17
– linear : convolution, Fourier Transform – non linear : no convolution, no Fourier Transform
– smoothing (blurring), contours strengthening (sharpening) …
Image processing, 2006, lingrand@polytech.unice.fr
18
Image processing, 2006, lingrand@polytech.unice.fr
19
i j
Image processing, 2006, lingrand@polytech.unice.fr
20
– ex:
1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9
Be careful if you make divisions with integers !
Image processing, 2006, lingrand@polytech.unice.fr
21
Image processing, 2006, lingrand@polytech.unice.fr
22
Kernel size = 3 Kernel size = 5
Image processing, 2006, lingrand@polytech.unice.fr
23
Kernel size = 3 Kernel size =5
Image processing, 2006, lingrand@polytech.unice.fr
24
– null mean – variance σ2
Image processing, 2006, lingrand@polytech.unice.fr
25
[ 1 2 1 ] [ 2 4 2 ] [ 1 2 1 ]
[1 1 2 2 2 1 1] [1 2 2 4 2 2 1] [2 2 4 8 4 2 2] [2 4 8 16 8 4 2] [2 2 4 8 4 2 2] [1 2 2 4 2 2 1] [1 1 2 2 2 1 1]
[ 1 1 2 1 1 ] [ 1 2 4 2 1] [ 2 4 8 4 2 ] [ 1 2 4 2 1] [ 1 1 2 1 1]
Image processing, 2006, lingrand@polytech.unice.fr
26
– Integer coefficient (faster computations) followed by a normalization step (division by the sum of coefficient) – Even more efficient: coefficient as powers of 2 – σ depends on the size of the kernel (p)
Image processing, 2006, lingrand@polytech.unice.fr
27
... ... ... 2q 1= 2q.e-p2/σ2 2q.e-p2/(2σ2) 2q.e-p2/(2σ2) ... ... ...
Image processing, 2006, lingrand@polytech.unice.fr
28
1 273 1 4 4 4 4 4 4 4 4 4 1 1 1 7 7 7 7 16 26 26 26 26 16 16 16 41
Image processing, 2006, lingrand@polytech.unice.fr
29
Kernel size = 3 Kernel size = 7
Image processing, 2006, lingrand@polytech.unice.fr
30
3 7
Image processing, 2006, lingrand@polytech.unice.fr
31
– Upper bound if the value is higher to that – Lower bound if the value is lower to that
Image processing, 2006, lingrand@polytech.unice.fr
32
Original image After conservative filtering
Image processing, 2006, lingrand@polytech.unice.fr
33
Original image After conservative filtering
Image processing, 2006, lingrand@polytech.unice.fr
34
255 140 88 110 93 67 63 255 255 88 110 93 67 63 0 ∈ [0 ; 255] 255 140 88 110 93 62 67 63 62 255 255 88 110 93 62 67 63 0 ∉ [62 ; 255]
Image processing, 2006, lingrand@polytech.unice.fr
35
⇒Need to sort values (ex: quick sort ?)
Image processing, 2006, lingrand@polytech.unice.fr
36
255 255 67 88 110 93 63 67 63 88 93 255 255 110 255 255 110 63 67 88 93 88 255 255 88 110 93 67 63 sorting median value
Image processing, 2006, lingrand@polytech.unice.fr
37
[1 1 1 1 1 1 1] [1 1 1 1 1 1 1] [1 1 1 1 1 1 1] [1 1 1 1 1 1 1] [1 1 1 1 1 1 1] [1 1 1 1 1 1 1] [1 1 1 1 1 1 1]
[0 0 0 1 0 0 0] [0 0 1 1 1 0 0] [0 1 1 1 1 1 0] [1 1 1 1 1 1 1] [0 1 1 1 1 1 0] [0 0 1 1 1 0 0] [0 0 0 1 0 0 0]
[0 0 0 1 0 0 0] [0 0 0 1 0 0 0] [0 0 0 1 0 0 0] [1 1 1 1 1 1 1] [0 0 0 1 0 0 0] [0 0 0 1 0 0 0] [0 0 0 1 0 0 0]
[0 1 0] [1 1 1] [0 1 0]
(3x3)
[1 1 1] [1 1 1] [1 1 1]
Image processing, 2006, lingrand@polytech.unice.fr
38
kernel 3x3, applied once kernel 3x3, applied twice
Image processing, 2006, lingrand@polytech.unice.fr
39
Original image After median filtering
Image processing, 2006, lingrand@polytech.unice.fr
40
[0 -1 0] [1 -2 1] [-1 -1 -1] [-1 10 -1] ou [-2 5 -2] ou [-1 9 -1] [0 -1 0] [1 -2 1] [-1 -1 -1]
Image processing, 2006, lingrand@polytech.unice.fr
41
Salt and pepper noise + 2 times median filtering (3x3)
Image processing, 2006, lingrand@polytech.unice.fr
42
White noise σ = 16 followed by Gaussian filtering (7x7)
Image processing, 2006, lingrand@polytech.unice.fr
43
– Median filtering performs well
– Gaussian filtering performs rather well
– Contours smoothing
– Smoothing only in areas of weak gradients
Image processing, 2006, lingrand@polytech.unice.fr
44
– Gaussian noise – Salt and pepper noise
– Mean filters (2n+1x2n+1), Gaussian filters – Conservative filtering – Median filtering – Contrast enhancement filters
Image processing, 2006, lingrand@polytech.unice.fr
45
Image processing, 2006, lingrand@polytech.unice.fr
46
Image processing, 2006, lingrand@polytech.unice.fr
47
Image processing, 2006, lingrand@polytech.unice.fr
48
u(x) u(x,t)
– Initialization : u(x,t0) = u0(x) – State at a given time t : u(x,t) = modified image – evolution : speed ?
Image processing, 2006, lingrand@polytech.unice.fr
49
Image processing, 2006, lingrand@polytech.unice.fr
50
– Check out that the solution is valid
– Correlation between Gaussian smoothing with variance σ2=2t and evolution of the image according to the heat PDE (Partial Differential Equation) – A classical Gaussian filter can be defined as the result of a PDE
Image processing, 2006, lingrand@polytech.unice.fr
51
– Numerical implementation of the evolution
Image processing, 2006, lingrand@polytech.unice.fr
52
– We expect :
direction parallel to the contour – Idea : weight by a function depending on the
gradient [Perona-Malik] s c(s)
c(|∇u|2)
Image processing, 2006, lingrand@polytech.unice.fr
53
– Weak |∇u| : c near to 1 : heat equation – High |∇u| : c near to 0 : null speed, no smoothing
Image processing, 2006, lingrand@polytech.unice.fr
54
Image processing, 2006, lingrand@polytech.unice.fr
55
c(s) = 1 / 1 + s
decreasing tends at infinity towards
Image processing, 2006, lingrand@polytech.unice.fr
56
Histogram equaliza- tion Smoothing with edge conservation
Image processing, 2006, lingrand@polytech.unice.fr
57