Computer Vision – Enhancement(Part II) Hanyang University Jong-Il Park Local Enhancement Global enhancement The same operation for all pixels Local enhancement Different operation for each pixel According to the statistics of local support Department of Computer Science and Engineering, Hanyang University Local Histogram Equalization Using a fixed window at each point Computationally expensive Histogram equalization at each point Department of Computer Science and Engineering, Hanyang University Use of statistics of local support Eg. E f ( x, y) g ( x, y) f ( x, y) m Original image if m k0 M G AND k1DG k2 DG otherwise E Enhanced image Department of Computer Science and Engineering, Hanyang University Spatial Operations Spatial averaging and spatial LPF for noise smoothing Input image output * Spatial mask ( 33, 55, ) Department of Computer Science and Engineering, Hanyang University Spatial Mask Department of Computer Science and Engineering, Hanyang University Spatial Averaging Mean-filtering v(m, n) a (k , l ) y (m k , n l ) ( k .l ) W ak , l : filtercoefficients equal weight filter: ak , l 1 , N w 2M 1 2 N 1 Nw Noise reduction v(m, n) u(m, n) (m, n) (m, n) ~ N (0, ) 2 a(k , l ) 1 Nw 1 v(m, n) u (m k , n l ) (m, n) N w ( k ,l ) W (m, n) ~ N (0, ), where 2 2 2 Nw Department of Computer Science and Engineering, Hanyang University Spatial Averaging Mask Spatial averaging masks a(k,l) Disadvantage : blurring Department of Computer Science and Engineering, Hanyang University Effect of window size Department of Computer Science and Engineering, Hanyang University Eg. Spatial Averaging(1) Department of Computer Science and Engineering, Hanyang University Eg. Spatial Averaging(2) Original image Averaging 후의 image Department of Computer Science and Engineering, Hanyang University Cf. Multi-image averaging Department of Computer Science and Engineering, Hanyang University Spatial Operations - Filtering Parametric Low Pass Filter 1 b 1 2 H b b b 2 1 b 2 but h ij i 1 1 b 1 to preserve the mean j Department of Computer Science and Engineering, Hanyang University Spatial LPF, BPF, HPF hHP (m, n) (m, n) hLP (m, n) hBP (m, n) hL (m, n) hL (m, n) 1 u (m, n) Spatial averaging 2 u (m, n) VLP (m, n) LPF + (a) Spatial low-pass filter u (m, n) VHP (m, n) (b) Spatial high-pass filter LPF + VBP (m, n) hL (m, n) 1 LPF hL (m, n) 2 (c) Spatial band-pass filter Department of Computer Science and Engineering, Hanyang University Eg. Spatial LPF Original image Lowpass Filter된 후의 image Department of Computer Science and Engineering, Hanyang University Spatial High-Pass Filtering Department of Computer Science and Engineering, Hanyang University Eg. Spatial HPF Original image Highpass filtered image Department of Computer Science and Engineering, Hanyang University Spatial Band-Pass Filtering Original image Lowpass Filter(Short Term) =A Bandpass Filter된 후의 Image =B-A Lowpass Filter(Long Term) =B Department of Computer Science and Engineering, Hanyang University Denoising by LPF Noisy! Blurred! Trade-off? Department of Computer Science and Engineering, Hanyang University Directional Smoothing Directional Smoothing to protect the edges from blurring while smoothing spatialaveragesvm, n, are calculatedin severaldirection 1 v(m, n : ) N W y(m k , n l ) ( k ,l ) W v(m, n) v(m, n : ) Find out such that min | y(m, n) v(m, n : ) | l k Department of Computer Science and Engineering, Hanyang University Eg. Directional Smoothing Original image Lowpass Filter(Long Term) Direc. Smoothing (대각선) Direc. Smoothing (수 직) Department of Computer Science and Engineering, Hanyang University Median Filtering Median Filter v(m, n) median { y(m k , n l ), (k , l ) W } filter length should be odd number Properties nonlinear filter median {x( m) y ( m)} median {x(m)} median { y ( m)} Example y m 2,3,8, 4, 2 , 3 1 median filter v 0 2 boundary value , v 1 median 2,3,8 3 v 2 median 3,8, 4 4, v 3 median 8, 4, 2 4 v 5 2 boundary value v m 2,3, 4, 4, 2 Numberof operations 3( NW2 1) / 8 comparisons Department of Computer Science and Engineering, Hanyang University Eg. 1D Median Filtering L 5 1 Department of Computer Science and Engineering, Hanyang University Discussion – Median filter 1) median filter preserve discontinuities in a step function 2) smooth a few pixels whose values differ significantly from the surrounding, without affecting the other pixels. 3) pulse function, whose width is less than one half the filter length, are suppressed Department of Computer Science and Engineering, Hanyang University 2D Median Filtering Filter Filtered Image Original Image Filter Filtered Image Department of Computer Science and Engineering, Hanyang University Eg. Median Filtering Salt-and-pepper noise(=impulsive noise) Original 7x7 Median filtered image Excellent performance! Department of Computer Science and Engineering, Hanyang University Eg. Median Filter – Impulsive Noise Department of Computer Science and Engineering, Hanyang University Eg. Median Filter – Impulsive Noise Department of Computer Science and Engineering, Hanyang University Eg. Median Filter – Gaussian Noise Moderate performance Department of Computer Science and Engineering, Hanyang University Various patterns for median filter Neighborhood patterns used for median filtering Department of Computer Science and Engineering, Hanyang University Eg. Median filter – Square pattern Original image 10% black, 10% white Median filtering using 3 by 3 square region Median filtering using 5 by 5 square region Department of Computer Science and Engineering, Hanyang University Eg. Median filter – Octagon pattern Original image 5 by 5 octagonal median filter Department of Computer Science and Engineering, Hanyang University Eg. Median filter – Reconstruction Original image Median filtering and color compensation Department of Computer Science and Engineering, Hanyang University Sharpening Images Emphasis of high-frequency components Usually exploiting 1st order derivative and 2nd order derivatives 1D derivatives f st f ( x 1) f ( x) 1 order derivative: x 2 f nd f ( x 1) f ( x 1) 2 f ( x) 2 order derivative: 2 x Department of Computer Science and Engineering, Hanyang University Eg. 1st & 2nd order derivatives Department of Computer Science and Engineering, Hanyang University Observation on derivatives 2nd order derivative Thinner edges Stronger response to fine details Weaker response to a gray-level step Double response at step changes Intensity of response: point > line > step The 2nd order derivative is better suited than the 1st order derivative for image enhancement. Department of Computer Science and Engineering, Hanyang University Laplacian Operator – Derivation The simplest isotropic derivative operator 2 2 f f 2 f x 2 y 2 x f (i, j ) x f (i 1, j ) x f (i, j ) 2 [ f (i 1, j ) f (i, j )] [ f (i, j ) f (i 1, j )] f (i 1, j ) f (i 1, j ) 2 f (i, j ) y f (i, j ) f (i, j 1) f (i, j 1) 2 f (i, j ) 2 2 f (i, j ) x f (i, j ) y f (i, j ) 2 2 [ f (i 1, j ) f (i 1, j ) f (i, j 1) f (i, j 1)] 4 f (i, j ) Department of Computer Science and Engineering, Hanyang University Laplacian Operator 0 1 0 H1 1 4 1 0 1 0 1 1 1 H 2 1 8 1 1 1 1 Eg) 0 0 0 1 2 3 4 x f 0 0 1 0 0 0 0 1 0 0 0 2 f x f 2 0 0 1 1 2 3 4 5 1 2 1 H 3 2 4 2 1 2 1 5 5 5 6 5 5 5 Department of Computer Science and Engineering, Hanyang University Sharpening by Laplacian operator Department of Computer Science and Engineering, Hanyang University Eg. Sharpening Original SEM image Laplacian operator Original image Laplacian operator Subtraction of the Laplacian from the original Subtraction of the Laplacian from the original Department of Computer Science and Engineering, Hanyang University Composite Laplacian mask Department of Computer Science and Engineering, Hanyang University Unsharp masking and Crispening v(m, n) u (m, n) g (m, n), 0 where g (m, n) : Laplacianoutput (high pass filtered ) 1 g (m, n) u (m, n) (u (m 1, n) u (m, n 1) u (m 1, n) u (m, n 1)) 4 (1) Signal (2) Low-pass (3) High-pass (1)+(3) Department of Computer Science and Engineering, Hanyang University Unsharp mask application Original image Processed image Department of Computer Science and Engineering, Hanyang University High-boost filtering Let g(n1, n2) = u(n1, n2) - uL(n1, n2) v(n1, n2) = u(n1, n2) + k g(n1, n2) k=1: Unsharp Masking Crispening an image k>1: High-boost filtering edge or line details to be emphasized Department of Computer Science and Engineering, Hanyang University Eg. High-boost filtering Department of Computer Science and Engineering, Hanyang University Zoom(1:2 magnification) revisited Nearest neighbor=Replication = zero - order hold 1 0 1 3 2 4 5 6 4 0 0 0 0 0 3 0 5 0 0 0 0 0 2 0 6 0 0 0 0 0 1 1 1 1 1 1 4 4 1 1 4 4 3 3 5 5 3 3 5 5 2 2 6 6 2 2 6 6 column, row zero-padding Department of Computer Science and Engineering, Hanyang University Zoom revisited(cont.) Linear Interpolation : first - order hold 1 0 1 7 3 1 3 0 0 7 0 1 4 0 0 0 0 0 3 2 0 1 0 0 0 0 0 0 H 1 4 1 2 1 4 1 2 1 1 2 1 4 1 2 1 4 7 3.5 1 2 0 0 3 1 0.5 0 0 1.5 3.5 3 4 2 2 1 0.5 1 0.5 0.25 4 7 Department of Computer Science and Engineering, Hanyang University