Digital Image Processing COSC 6380/4393 Lecture 11 Oct 3 rd, 2017 Pranav Mantini Slides from Dr. Shishir K Shah, and Frank Liu
Review: 2D Discrete Fourier Transform If I is an image of size N then Sin image Cos image Let ሚI be the DFT of the I N 1 N 1 ሚI u, v = I i, j cos[ 2π (ui + vj)] N 1 i=0 j=0 N 1 N 1 N 1 N 1 i=0 I i, j sin[ 2π (ui + vj)] N ሚI u, v = I i, j (cos[ 2π (ui + vj)] N 1sin[2π (ui + vj)]) N i=0 j=0 N 1 N 1 ሚI u, v = I i, j e 12π N (ui+vj) i=0 j=0 0 F u = f x e 1ux
Review: 2D Inverse Discrete Fourier Transform Let ሚI be the DFT of the I N 1 N 1 I i, j = u=0 u=0 ሚI u, v e 12π N (ui+vj) f x = F u e iux
Review: Properties of DFT Matrix We can understand the DFT matrix better by studying some of its properties. Any image I of interest to us is composed of real integers. However, the DFT of I is generally complex. It can be written in the form 21 8.5 8.5 12 1.5 1.5 0 4.3 4.3 0 0.8 0.8
Review: Symmetry of DFT ሚI N u, N v = ሚI u, v The DFT of an image I is conjugate symmetric: The magnitude DFT of an image I is symmetric:
Review: Symmetry of DFT Depiction of the symmetry of the DFT (magnitude). The highest frequencies are represented near (u, v) = (N/2, N/2). 6
Review: Periodicity of DFT We have defined the DFT matrix as finite in extent (N x N): However, if the arguments are allowed to take values outside the range 0 u, v N-1, we find that the DFT is periodic in both the u- and v-directions, with period N: For any integers m, n This is called the periodic extension of the DFT. It is defined for all integer frequencies u, v. 7
Review: Periodic Extension of DFT 8
Review: Periodic Extension of Image The IDFT equation implies the periodic extension of the image I as well (with period N), simply by letting the arguments (i, j) take any integer value. Note that for any integers n, m In a sense, the DFT implies that the image I is already periodic. This will be extremely important when we consider convolution 9
Review: Periodic Extension of Image 10
Review: Displaying the DFT Usually, the DFT is displayed with its center coordinate (u, v) = (0, 0) at the center of the image. This way, the lower frequency information (which usually dominates an image) is clustered together near the origin at the center of the display. This can be accomplished in practice by taking the DFT of the alternating image (for display purposes only!) Observe that [(-1) i+j I(i,j) ; 0 i, j N-1] A simple shift of the DFT by half its length in both directions. 11
Review: Centered DFT 12
Review: Granularity Large values near the DFT origin correspond to large smooth regions in the image or a strong background. Since images are positive (implying an additive offset), any image has a large peak at (u, v) = (0, 0). Masking the DFT Suppose that we define several zero-one images: Masking the DFT with these will produce IDFT images with only low, mid-, or high frequencies remaining (slides). Of course, if we add up the results, we get the original image back. 13
Review: Directionality If the DFT is brighter along a specific orientation, then the image must contains highly oriented components in that direction. Masking the DFT Suppose that we define several oriented zero-one images: Masking the DFT with these will produce IDFT images with only highly oriented frequencies remaining (slides). Again, if we add up the results, we get the original image back. 14
Review: Periodic Noise removal
Spatial Correlation Operator The correlation of a filter w( x, y) of size m n with an image f ( x, y), denoted as w( x, y) f ( x, y) a w( x, y) f ( x, y) w( s, t) f ( x s, y t) b s a t b 10/6/2017 16
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 1 2 3 2 8 0 0 0 1 0 0 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 2 3 2 8 Initial Position
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 2 3 2 8 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 2 3 2 8 Position after one shift 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 2 3 2 8 Position after one shift 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 2 3 2 8 Position after four shift 0 0 0 8
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 2 3 2 8 Final Position 0 0 0 8 2 3 2 1 0 0 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Full Correlation result 0 0 0 8 2 3 2 1 0 0 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Cropped Correlation result 0 8 2 3 2 1 0 0
Spatial Convolution Operator The convolution of a filter w( x, y) of size m n with an image f ( x, y), denoted as w( x, y) f ( x, y) a w( x, y) f ( x, y) w( s, t) f ( x s, y t) b s a t b 10/6/2017 27
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 8 2 3 2 1 w rotated by 180 0 0 0 0 1 0 0 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 8 2 3 2 1 Initial Position
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 8 2 3 2 1 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Zero Padding 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 8 2 3 2 1 Position after four shift 0 0 0 1
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Full Convolution result 0 0 0 1 2 3 2 8 0 0 0 0
f 0 0 0 1 0 0 0 0 w 1 2 3 2 8 Cropped Convolution result 0 8 2 3 2 1 0 0
Spatial Filtering A spatial filter consists of (a) a neighborhood, and (b) a predefined operation Linear spatial filtering of an image of size MXN with a filter of size mxn is given by the expression a b g( x, y) w( s, t) f ( x s, y t) s a t b 35
Spatial Filtering 36
Spatial Correlation Operator 37
38
Linear Systems And Linear Image Filtering A process that accepts a signal or image I as input and transforms it by an act of linear convolution is a type of linear system Example 39
Goals of Linear Image Filtering Process sampled, quantized images to transform them into - images of better quality (by some criteria) - images with certain features enhanced - images with certain features de-emphasized or eradicated 40
Some Specific Goals smoothing - remove noise from bit errors, transmission, etc deblurring - increase sharpness of blurred images sharpening - emphasize significant features, such as edges combinations of these 41
Smoothing Spatial Filters Smoothing filters are used for blurring and for noise reduction Blurring is used in removal of small details and bridging of small gaps in lines or curves Smoothing spatial filters include linear filters and nonlinear filters. 42
Spatial Smoothing Linear Filters The general implementation for filtering an M N image with a weighted averaging filter of size m n is given g( x, y) a b s a t b w( s, t) f ( x s, y t) w( s, t) where m 2a 1, n 2b 1. a b s a t b 43
Two Smoothing Averaging Filter Masks 44
Two Smoothing Averaging Filter Masks Demo Filters 45
46
Example: Gross Representation of Objects Blur an image for getting a gross representation. Small objects get blended with background 47
Example: Gross Representation of Objects Blur an image for getting a gross representation. Small objects get blended with background Demo stars 48
Laplace Operator: Foundation The first-order derivative of a one-dimensional function f(x) is the difference f f ( x 1) f ( x) x The second-order derivative of f(x) as the difference 2 f f ( x 1) f ( x 1) 2 f ( x) 2 x 50
10/6/2017 51
Laplace Operator The second-order isotropic derivative operator is the Laplacian for a function (image) f(x,y) f x f y 2 2 2 f 2 2 2 f f ( x 1, y) f ( x 1, y) 2 f ( x, y) 2 x 2 f f ( x, y 1) f ( x, y 1) 2 f ( x, y) 2 y 2 f f x y f x y f x y f x y ( 1, ) ( 1, ) (, 1) (, 1) - 4 f ( x, y) 52
Laplace Operator Demo Filters 53
Sharpening Spatial Filters: Laplace Operator Image sharpening in the way of using the Laplacian: g x y f x y c f x y where, f ( x, y) is input image, g( x, y) is sharpenend images, c 2 (, ) (, ) (, ) 2-1 if f ( x, y) corresponding to Fig. 3.37(a) or (b) and c 1 if either of the other two filters is used. 54
55
Unsharp Masking and Highboost Filtering Unsharp masking Sharpen images consists of subtracting an unsharp (smoothed) version of an image from the original image e.g., printing and publishing industry Steps 1. Blur the original image 2. Subtract the blurred image from the original 3. Add the mask to the original 56
Unsharp Masking and Highboost Filtering Let f ( x, y) denote the blurred image, unsharp masking is g ( x, y) f ( x, y) f ( x, y) mask Then add a weighted portion of the mask back to the original g( x, y) f ( x, y) k * g ( x, y) k 0 mask when k 1, the process is referred to as highboost filtering. 57
Unsharp Masking: Demo 58
Unsharp Masking and Highboost Filtering: Example Demo Sharpen 59
Convolution Theorem Let f be and image and h a filtering window Lets us consider the convolution f(t) h(t)
Convolution Theorem Let f and h be two function Lets us consider the convolution f t h t = f τ h t τ τ= From the definition of convolution a w( x, y) f ( x, y) w( s, t) f ( x s, y t) b s a t b
Convolution Theorem Let f and h be two function Lets us consider the convolution f t h t = f τ h t τ F[f t h t ] τ= = [ f τ h t τ ]e 12πμt t= τ= Computing the Fourier transform of the convolution F u = f x e 1ux
Convolution Theorem Let f and h be two function Lets us consider the convolution f t h t = f τ h t τ τ= F[f t h t ] = [ f τ h t τ ]e 12πμt t= τ= = f τ [ h t τ e 12πμt ] τ= t=
Convolution Theorem Let f and h be two function Lets us consider the convolution f t h t = f τ h t τ τ= F[f t h t ] = [ f τ h t τ ]e 12πμt t= τ= = f τ [ h t τ e 12πμt ] τ= t= = f τ [ h t τ e 12πμ(t τ) ] e 12πμτ τ= t=
Convolution Theorem Let f and h be two function Lets us consider the convolution f t h t = F[f t h t ] = = = τ= τ= = τ= f τ [ τ= [ t= τ= f τ [ t= t= f τ h t τ f τ h t τ ]e 12πμt h t τ e 12πμt ] h t τ e 12πμ(t τ) ] e 12πμτ f τ [H(μ)] e 12πμ(τ) = H(μ) = H μ F(μ) τ= f τ e 12πμ(τ)
Convolution Theorem Fourier transform pairs f t h t H μ F(μ) f t h t H μ F(μ)