Digital Image Processing Jen-Hui Chuang Department of Computer Science National Chiao Tung University 2 3 Image Enhancement in the Spatial Domain 3.1 Background 3.4 Enhancement Using Arithmetic/Logic Operations 3.1 Background Spatial Filtering (x, 3.5 Basics of Spatial Filtering 3.6 Smoothing Spatial Filters 3.7 Sharpening Spatial Filters 3.8 Combining Spatial Enhancement Methods f(x, g(x, 3 4 3.1 Background Contrast Stretching and Thresholding 3.2 Some Basic Intensity Transformation Functions 3.2.1 Image Negatives Always good enhancement results 6
3.2.2 Log Transformations (s = c log (1 + r)) to compress the dynamic range 3.2.3 Power-Law (Gamma) Transformations (s = c r ) (c = 1) (0 r x10 6 ) (0 s ) (c = 1) 7 8 Ex. Gamma correction for CRT = 2.5 = 0.4 Ex. 3.1 Contrast enhancement for MR image c = 1 = 0.6, 0.4, 0.3 = 2.5 9 -out look (staturation) 10 Ex. 3.2 The opposite problem Contrast stretching c = 1 = 3.0, 4.0, 5.0 11 12
Intensity-level slicing Bit-plane slicing Ex. 3.3 13 14 Bit-plane slicing Bit-plane slicing (intensity transformation) (bit planes 8 and 7) (bit planes 8,7, and 6) 15 (bit planes 8,7, 6, and 5) 16 Four Basic Image Types Four Basic Image Types 18
The basic idea Ex. 3.5- (the discrete case) P r (r k ) 5/7 4/7 3/7 2/7 1/7 5/7 4/7 3/7 2/7 1/7 P s (s k ) 5/7 4/7 3/7 2/7 1/7 (uniform histogram) 0 L-1 0 L-1 0 1 2 3 4 5 6 7 k r k (uniform histogram) s k = (L-1)P r (r j ) j=0 (3.3-8) 19 20 Ex. 3.5 (3-bit image of 64x64 pixels) Ex. 3.6 21 22 Ex. 3.6 (cont.) discrete transformation functions for HE 23 24
3.3.2 Histogram Matching (Specification) Ex. 3.8 Histogram Specification 3.3.2 Histogram Matching (Specification) Ex. 3.9 Comparison between H. E. and H. M. s k H.E. H.M. 25 26 3.3.2 Histogram Matching (Specification) Ex. 3.9 (cont.) 3.3.3 Local Histogram Processing Ex. 3.10 Local histogram equalization s k s k r k z q Original image (512x512 H. E.) (3x3 H. E.) 27 28 3.3.4 Use of Histogram Statistics for Image Enhancement Ex. 3.12 Local enhancement using histogram statistics 3.3.4 Use of Histogram Statistics for Image Enhancement Ex. 3.12 Enhancement based on local statistics g (x, = 4.0 f (x, 0.02 D G s D G m s M G m s s 0.02 D G s D G m s M G 29 30
3.4 Fundamentals of Spatial Filtering 3.4.1 The Mechanics of Spatial Filtering 3.4 Fundamentals of Spatial Filtering 3.4.2 Spatial Correlation and Convolution g(x, = w(i, j) f (x+i, y+j) Origin (x, w(x) f(x)=w(i) f (x+i) w(x) f(x)=w(i) f (xi) g(x, 31 32 3.4 Fundamentals of Spatial Filtering 3.4.2 Spatial Correlation and Convolution 3.4 Fundamentals of Spatial Filtering 3.4.3 Vector Representation of Linear Filtering w(x, f(x, =w(i, j) f (x+i, y+j) w(x, f(x, =w(i, j) f (x+i, y+j) w(x, f(x, =w(i, j) f (xi, yj) w(x, f(x, =w(i, j) f (xi, yj) Point spread function R = w 1 z 1 +w 2 z 2 + +w 9 z 9 = w T z 33 34 3.5 Smoothing Spatial Filters 3.5.1 Smoothing Linear Filters Ex. Object Detection Ex. 3.13 Image smoothing with masks of various sizes 15x15 Averaging Thresholding (largest, brightest objects) Border Effects 35 36
3.5.2 Order-Statistics (Nonlinear) Filters Averaging Filtering vs. Median Filtering Purpose: highlight or enhance fine details 3.6.1 Foundation 1st-order derivative: f f ( x 1) f ( x) x 2nd-order derivative: (Salt-and-pepper noise) 3x3 Averaging 3x3 Median 2 f 2 x f ( x 1) f ( x 1) 2 f ( x) Also: Max Filters and Min Filter 37 3.6.1 Foundation 3.6.2 Using the Second Derivatives for Image Sharpening 2 2 2 f f f 2 2 x y 0 Ex. 3.15 Image Sharpening Using the Laplacian g( x, f ( x, c[ 2 f ( x, ] 39 3.6.3 Unsharp Masking and Highboost Filtering Ex. 3.16 f (x, 3.6.4 Using First Derivatives for (Nonlinear) Image Sharpening Ex. 3.17 Use of the gradient for edge enhancement f ( x, : a blurred version of f (x, g mask ( x, f ( x, f ( x, Robert: g( x, f ( x, k g ( x, mask k = 1: Unsharp Masking k > 1: High-Boost Filtering k = 4.5 Sobel: 41 g x g y 42
3.7 Combining Spatial Enhancement Methods (a) (b) (e) (f) More examples Laplacian of (a) 5x5 averaging of (d) (c)x(e) (c) (d) (g) (h) (a)+(b) Sobel of (a) (a)+(f) 43 Enhancement Using Arithmetic/Logic Operations Ex. AND and OR Enhancement Using Arithmetic/Logic Operations Image Subtraction Ex. Mask Mode Radiography 45 f 0 (x, f (x, -f 0 (x, 46 Image Averaging Sharpening Spatial Filters Ex. Image Enhancement Using a Composite Laplacian Mask Ex. Noise Reduction by Image Averaging _ E {g (x, } = f (x, 2 _ g (x, = 2 (x, /K K = 8 K = 16 K = 64 K = 128 47 48
Sharpening Spatial Filters Ex. Image Enhancement with a High-Boost Filter Sharpening Spatial Filters Using First Derivatives for (Nonlinear) Image Sharpening Ex. Use of the Gradient for Edge Enhancement A = 0 Robert: Sobel: A = 1 A = 1.7 49 g x g y 50 Sharpening Spatial Filters Using First Derivatives for (Nonlinear) Image Sharpening Ex. (cont.) g y g x (After edge linking) 51