Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Note: Part of the materials in the slides are from Gonzalezs Digital Image Processing and Prof. Yao Wangs lecture slides
Lecture Outline
Noise removal using low-pass filters Sharpening by b edge enhancement
Edge detection using high-pass filters Edge enhancement by high emphasis filters
Debluring techniques
Spring 2010
Lecture 5, Page 2
Spring 2010
Lecture 5, Page 3
100 100 100 100 144 167 145 100 167 200 168 100 144 166 144 100 100 100 100 100
Lecture 5, Page 6
Example
(a) Original image (500x500 pixels) Sizes of the black squares: 3, 5, 9, 15, 25, 35 45 35, 45, 55 Diameter of the circles is 25 pixels The vertical bars are 5x100 pixels The noisy rectangles are 50x120 pixels (b-f) Smoothing with square averaging filters (b) 3x3 (c) 5x5 (d) 9x9 (e) 15x15 (f) 35x35
FIGURE 3.33 ab cd ef
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 7
k1
l1
This type of operation is in fact 2-D 2 D linear convolution of f(m,n) by a filter h(m,n). Weighted g average g filter retains low frequency q y and suppresses high frequency = low-pass filter
Spring 2010
Lecture 5, Page 8
1
1 9
1 1 1
1 1 1
1 16
1 2 1
2 4 2
1 2 1
1 1
Spring 2010
Lecture 5, Page 9
100 100 200 205 195 200 200 205 100 100
1 1 1
1 1 1
100 100
1 2 1
2 4 2
1 2 1
100 100 144 167 167 200 144 166 100 100
100 100 156 176 174 201 156 175 100 100
100 100 158 100 175 100 156 100 100 100
Spring 2010
Lecture 5, Page 10
Original image
Averaged image
1 1 9 1
1 1 1 1 1 1 1
1 2 1
2 4 2
1 2 1
Spring 2010
Lecture 5, Page 11
Suppose
k = l =
h( k , l ) f ( m k , n l ) = f ( k , l ) h( m k , n l )
k = l =
The size of the image (f) is M x N. The e size s eo of t the e filter te ( (h) ) is s K x L.
g (m, n) = f (m, n) * h(m, n) = h(k , l ) f (m k , n l )
k =0 l =0 K 1 L 1
Separable Filtering
If h(m,n) is separable: h(m, n)=hx(m)hy(n), the 2D convolution can be accomplished by first applying 1D filtering along each row using hy(n), (n) and then applying 1D filtering to the intermediate result along each column using the filter hx(n) h (n)
y
m=0
f(m n) f(m,n)
m=M-1
gy(m,n)=f(m,n)*hy(n) hx(m)
g y (m, n) =
= f (m k , n l )hy (l ) hx (k ) k l = g y (m k , n)hx (k )
k
f (m, n l )h (l )
y l
Spring 2010
g(m,n)=gy(m,n)*hx(m)
Lecture 4, Page 13
Each pixel in a row: L mul; L-1 add. g y (m, n) = f (m, n l )hy (l ) Each row: NxL mul; Nx(L-1) Nx(L 1) add add. l M rows: MxNxL mul; MxNx(L-1) add. Each p pixel in a column: K mul; K-1 add. Each column: MxK mul; Mx(K-1) add. g (m, n) = g y (m k , n)hx (k ) k N columns: NxMxK mul; NxMx(K-1) add. T t l MxNx(K+L) Total: M N (K+L) mul; l MxNx(K+L-2) M N (K+L 2) add. dd When f and h are squares: M=N, K=L
2M2K multiplication; 2M2(K-1) addition. Non-separable filtering: M2K2 multiplication + M2(K2-1) add
Spring 2010
Lecture 4, Page 14
Symmetrical Filter
The smoothing filter is symmetrical in both horizontal and vertical directions, as well as diagonal. -W
k=0 W -W
H h
l=0
+ h(k,0)( f (m k, n) + f (m + k, n))
k =1
W W
Spring 2010
Lecture 5, Page 15
h( k , l ) f ( m k , n l )
Symmetrical filter
For each pixel:1+2W+W2=(W+1)2 multiplications
Spring 2010
Lecture 5, Page 16
Spring 2010
Lecture 5, Page 17
Image signal usually varies slowly, and noise is usually a wide band signal. Image edges and other details are blurred
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 18
Noise Removal by Averaging Multiple Images Assume y = x + n, where n ~ N(0, 2). Observe Obser e one image image, the noise is n Observe N images: yi = x + ni, i=1,,N, where ni ~ N(0, 2), and ni are independent.
1 y= N 1 yi = N i =1
N
1 ( x + ni ) = x + N i =1
n
i =1
y = x + n , where n ~ N (0, 2 / N )
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 19
Spring 2010
Lecture 5, Page 20
Image Sharpening
Sharpening : to enhance line structures or other details in an image Enhanced image = original image + scaled version of the line structures and edges in the image Line structures and edges can be obtained by applying a difference operator (=high pass filter) on the image p is still a weighted g averaging g g Combined operation operation, but some weights can be negative. In frequency domain, the filter has the high-emphasis character h t
Spring 2010
Lecture 5, Page 21
Example
Spring 2010
Lecture 5, Page 22
Spring 2010
Lecture 5, Page 23
m = n =
f (m, n)e
j 2 ( mu + nv )
k = k 0 l = l0
h(k , l ) = 0
k1
l1
Original image
Binary image
Spring 2010
Lecture 5, Page 25
Illustration of the First and the Second Derivatives of1-D digital g function
df = f ( x + 1) f ( x) dx
d2 f = [ f ( x + 1) f ( x)] [ f ( x) f ( x 1)] dx 2 = f ( x + 1) + f ( x 1) 2 f ( x)
Spring 2010
Lecture 5, Page 26
g x = ( z9 z5 ) and
g y = ( z8 z 6 )
Sobel operators
g x = ( z7 + 2 z8 + z9 ) ( z1 + 2 z 2 + z3 ) g y = ( z3 + 2 z6 + z9 ) ( z1 + 2 z 4 + z7 )
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 27
Laplacian Operator
2f = [ f ( x + 1, y ) + f ( x 1, y ) + f ( x, y + 1) + f ( x, y 1)] 4 f ( x, y )
0 1 0 0 1 0 1 4 1; 1 4 1; 0 1 0 0 1 0
Spring 2010
1 1 1 1 1 1 1 8 1; 1 8 1; 1 1 1 1 1 1
Lecture 5, Page 28
Hx Original image Hy
ELEN E4830 Digital Image Processing Lecture 5, Page 30
f g= x
2 2
Laplacian operator
2 2 f f 2 f = 2 + 2 ; 2 (h * f ) = 2 (h ) * f x y
(h ) =
2
x + y 2
2 2
x2 + y2 2 2
Lecture 5, Page 31
Laplacian of Gaussian
Gaussian filter
Laplacian of Gaussian
0 0 1 0 0 0 1 2 1 0 1 2 16 2 1 0 1 2 1 0 0 0 1 0 0
Lecture 5, Page 32
|g|>T
Hx fy
Spring 2010
tan-1(fx/fy)
ELEN E4830 Digital Image Processing
theta
Lecture 5, Page 33
4 5 7
Lecture 5, Page 34
Sharpening filter
hs (m, n) = (m, n) + hh (m, n)
Matrix form
Spring 2010
H s = I + H h
ELEN E4830 Digital Image Processing Lecture 5, Page 35
Spring 2010
Lecture 5, Page 36
0 1 0 0 1 0 1 1 H h = 1 4 1 H s = 1 8 1 with = 1. 4 4 0 1 0 0 1 0
H s = I + H h
Spring 2010 ELEN E4830 Digital Image Processing
0 0 0 I = 0 1 0 0 0 0
Lecture 5, Page 37
Original image
Sharpened image
Difference image
Spring 2010
Lecture 5, Page 38
1 8 1 1 1 1 1 8 1 1 1
0 1 0 (d) 1 4 1 0 1 0
1 1 1 (e) 1 8 1 1 1 1
Spring 2010
Lecture 5, Page 39
Sharpening filter
hs (m, n) = (1 + ) (m, n) hl (m, n)
Matrix form
H s = (1 + ) I H l
Spring 2010
Lecture 5, Page 40
1 2 1 1 2 1 1 1 H l = 2 4 2 H s = 2 28 2 with = 1. 16 16 1 2 1 1 2 1
H s = (1 + ) I H l
Criteria for designing g g sharpening p g filters: There are both p positive and negative g Coefficients, h(0,0) > 0, and h(k, l)>0.
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 41
Original image
Sharpened image
Difference image
Spring 2010
Lecture 5, Page 42
Spring 2010
Lecture 5, Page 43
Taking an image without injecting a contrast agent first. Then take the image again after the organ is injected some special contrast agent (which go into the bloodstreams only). Then subtract the two images --- A popular technique in medical imaging
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 44
Spring 2010
Lecture 5, Page 45
The human visual system low-pass filters the scenes under observation. We will exploit this observation by hiding processing errors where humans cannot see
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 46
Wavelet-Domain Filtering
Image Deblurring
Noise removal considered thus far assumes the image is corrupted by additive noise
Each pixel is corrupted by a noise value, independent of neighboring pixels
Image blurring
When the camera moves while taking a picture Or when the object j moves Each pixel value is the sum of surrounding pixels The blurred image is a filtered version of the original
g ( x, y ) = f ( x, y )dt
0
y f (x,y) ( ,y)
g ( x, y ) = f [x x0 (t ), y y0 (t )]dt
0
G (u , v) =
T
j 2 ( ux + vy ) g ( x , y ) e dxdy j 2 ( ux + vy )
x
dxdy
0 T
f [x x (t ), y y (t )]dt e
0 0
Spring 2010
Lecture 5, Page 49
T sin(ua)e jua ua
Spring 2010
Spring 2010
Lecture 5, Page 51
Inverse Filtering
Inverse filtering )
G (u , v) F (u , v) = = F (u , v) H (u , v)
G (u , v) = F (u , v) H (u , v) + N (u , v)
Inverse filter
) G (u , v) N (u , v) F (u , v) = = F (u , v) + H (u , v) H (u , v)
Challenges
N(u,v) is normally unknown H(u,v) may have zero or very small values, then N(u,v)/H(u,v) may dominate d i t
Spring 2010 ELEN E4830 Digital Image Processing Lecture 5, Page 52
2 1 ) H (u , v) F (u , v) = G (u , v) 2 2 2 H (u , v) H (u , v) + N (u , v) / F (u , v)
Depends on the power spectrum of noise and the original image When there is no noise, , Wiener filter reduces to inverse filter.
Spring 2010
Lecture 5, Page 53
Spring 2010
Lecture 5, Page 54
Homework
1. Write a Matlab or C-program to simulate noise removal. First create a noisy image, by adding normal random noise to your image (In matlab, the noise can be generated using randn. You can multiple the resulting numbers by a scaling parameter, which controls the variance of the noise). Then apply an averaging filter to the noise added image. For a chosen variance of the added noise, you need to try different window sizes (from 3x3 to 7x7) to see which one gives you the best trade-off between noise removal and blurring. Hand in your program, the original noiseadded images at two different noise levels and the corresponding filtered images with the best window sizes. Write down your observation. W it a Matlab Write M tl b or C-program C f implementing for i l ti th the f following ll i simple i l edge d d detection t ti algorithm: l ith F For every pixel: i) find the horizontal and vertical gradients, gx and gy, using the Sobel operator; ii)
2 2 + gy calculate the magnitude of the gradient using g m = g x ; and iii) For a chosen threshold T,
2 2.
consider the p pixel to be an edge g p pixel if gm T. Save the resulting g edge g map p( (Use a g gray y level of 255 to indicate an edge pixel, and a gray level of 0 for a non-edge pixel). Apply this program to your test image, and observe the resulting edge map with different T values, until you find a T that gives you a good result. Hand in your program and the edge maps generated by two different th h ld values. threshold l W Write it d down your observation. b ti Hi Hint: t one automatic t ti way t to d determine t i T is i b by sorting the pixels based on the gradient magnitudes, and choose T such that a certain percentage (say 5%) of pixels will be edge pixels.
Spring 2010
Lecture 5, Page 55
Reading
R. Gonzalez, Digital Image Processing, Sections 3 3.4~3.8, 4~3 8 5 5.6~5.8. 6~5 8 A. K. Jain, Fundamentals of Digital Image Processing Section 7 Processing, 7.4 4 (except median filter).
Spring 2010
Lecture 5, Page 56