2002 R. C. Gonzalez & R. E. Woods. Chapter 3: Spatial Processing:
NEIGHBORHOOD OF (x,y). Masks or filters operate on neighborhoods of input
image ...
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Image Enhancement: INTRODUCTION I- GOALS OF IMAGE ENHANCEMENT • Better visual quality for human analysis • Facilitate further image processing
II- SPATIAL DOMAIN PROCESSING •Processing directly the pixels of the image •Single pixel or neighborhood of pixels is processed •Statistical model of gray levels used •Linear or Nonlinear types of processing •Corresponding frequency domain interpretation is possible III- FOURIER/FREQUENCY DOMAIN PROCESSING •Explicitly process the image in the frequency domain (DFT) © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
Chapter 3: Spatial Processing: NEIGHBORHOOD OF (x,y)
Masks or filters operate on neighborhoods of input image
© 2002 R. C. Gonzalez & R. E. Woods
www.imageprocessingbook.com
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: IMAGE AVERAGING (set-up) •Problem: Image has additive noise •Advantage: Multiple images are available (assumed to be aligned) •Noise mode: zero-mean, uncorrelated •Recall: Variance is reduced
g i ( x, y ) f ( x, y ) i ( x, y ) 1 g ( x, y ) K
K
g ( x, y ) i 1
i
E{g ( x, y )} f ( x, y ) ; © 2002 R. C. Gonzalez & R. E. Woods
2 g ( x, y )
1 2 ( x, y ) K
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: IMAGE AVERAGING (Example)
Simulated Example: Add Gaussian Noise (Std=60) Orig., Noisy Image Average of 8, 16 images Average of 64, 128 images
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3:IMAGE AVERAGING (differences)
Diff. = Original - Averaged (8, 16, 64, 128 images) NOTE: non-zero mean due to negative noise values and scaling for display (?)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. Chapter 3: SPATIAL DOMAIN FILTERING
www.imageprocessingbook.com
Mask Image neighborhood “under” the mask
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3:MASK COEFFICIENTS. and CONVOLUTION EQUATION
t a
g ( x, y )
b
w(s, t ) f ( x s, y t )
s a t b
a
b
w(s,t ) f ( x s, y t )
s a t b
x 0,1,..., M 1 ; y 0.1,2,...N 1 © 2002 R. C. Gonzalez & R. E. Woods
s
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Example Filter Masks, Border Effects
a
Note :
b
w(s, t ) 1
s a t b
Implementation Issue: (x,y) near borders, alternatives: Avoid non-overlap, zero-extension, constant extension, replicate rows & columns, symmetric extension, etc. © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Smoothing Filter Masks for Weighted Averaging
g ( x, y)
a
b
w(s, t ) f ( x s, y t )
s a t b
x 0,1,..., M 1 ; y 0.1,2,...N 1 © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: EXAMPLE OF SMOOTHING/AVERAGING
Filter Mask Sizes Used: 3x3, 5x5, 9x9, 15x15, 35x35
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Use of Spatial Smoothing before thresholding
•Gross detail is preserved •Apply threshold of 25% of maximum gray level •Small objects do not survive the processing © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Implementing neigborghood operations – MATLAB example % assume a 3x3 mask and anMxM image % zero pad extension of image Xe = X; Xe = [ zeros(1,M); X; zeros(1,M)]; Xe = [zeros(N+2,1) Xe zeros(N+2,1)]; %output image Ye = zeros(size(Xe); %for loops to move over the image for n = 2:N+1 for m = 2:M+1 %for loops to implement 2-D mask new_value = 0; for i = -1:1 for j=-1:1 new_value = new_value + mask(i+2,j+2)*Xe( n+i, m+j) ; end end Ye(n,m) = new_value; end end %remove padding Y = Ye(2:N+1,2:M+1);
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Order-Statistics, Median Filters
g ( x, y ) median { f ( x s, y t ) : s [a, a], t [b, b]} x 0,1,..., M 1 ; y 0,1,2,...N 1
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Order-Statistics, Median Filters - II
g ( x, y ) median { f ( x s, y t ) : s [a, a], t [b, b]} x 0,1,..., M 1 ; y 0,1,2,...N 1 Properties of Median Filter: • Nonlinear Operation • Replace outliers (impulsive noise, salt-pepper noise) with typical gray level value • Often preserves edge discontinuities (vs. mean filter) Other Order-Statistics Filters: • X percentile (vs. 50%) rank • Max filter (100%) • Min filter (0%)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Intro. to Derivative Operations
Typical responses for 1st and 2nd derivative operators in 1-D
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Intro. to Derivative Operations - II
Discrete derivate operators for 1-D f f ( x 1) f ( x) x 2 f f ( x 1) f ( x) f ( x) f ( x 1) 2 x f ( x 1) 2 f ( x) f ( x 1)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Intro. to Derivative Operations - III
Discrete derivate operators for 2-D f ( x, y ) f ( x 1, y ) f ( x, y ) x f ( x, y ) f ( x, y 1) f ( x, y ) y 2 f ( x, y ) f ( x 1, y ) 2 f ( x, y ) f ( x 1, y ) 2 x 2 f ( x, y ) f ( x, y 1) 2 f ( x, y ) f ( x, y 1) 2 y 2 2 f ( x , y ) f ( x, y ) 2 f 2 x y 2
© 2002 R. C. Gonzalez & R. E. Woods
Laplacian
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Re-Visit Derivative Operations
Typical responses for 1st and 2nd derivative operators in 1-D
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Use of Laplacian for Enhancement
+
90°
45°
2 f f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1) 4 f ( x, y ) © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Application of Laplacian for Enhancement
g ( x, y) f ( x, y) 2 f Original plus high-pass filtered (Laplacian with negative center value in the mask)
g ( x, y) 5 f ( x, y) f ( x 1, y) f ( x 1, y) f ( x, y 1) f ( x, y 1) © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Comparison of 2 Laplacian Masks for Enhancement with Combined Masks
4+1 8+1
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Unsharp Masking and High-Boost Filtering Unsharp Masking: Original – Blurred Version
f s ( x, y) f ( x, y) f ( x, y) High-Boost: A x Original – Blurred Version (A>1)
f hb ( x, y) Af ( x, y) f ( x, y) Using Laplacian: Blurred=Original – Sharpened Image
f hb ( x, y ) Af ( x, y ) f ( x, y )
( A 1) f ( x, y ) f ( x, y ) f ( x, y )
( A 1) f ( x, y ) f ( x, y ) 2 f ( x, y ) Af ( x, y ) 2 f ( x, y ) © 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Unsharp Masking and High-Boost Filtering Unsharp Masking: Original – Blurred Version
f s ( x, y) f ( x, y) f ( x, y) High-Boost Using Laplacian:
f hb ( x, y) Af ( x, y) 2 f ( x, y)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Example: Unsharp, High-Boost
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Use of First Derivatives for Enhancement: Gradient Vector, Gradient
f 2 1/ 2 2 f f y Gx f f f G y x y y f Gx G y common approx .
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Masks for First Partial Derivatives
Roberts Operators
Sobel Operators
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
Chapter 3: Example use of Gradient
Use Gradient for preprocessing before automated inspection
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
© 2002 R. C. Gonzalez & R. E. Woods
www.imageprocessingbook.com
Digital Image Processing, 2nd ed.
© 2002 R. C. Gonzalez & R. E. Woods
www.imageprocessingbook.com