Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital Image Processing

Similar presentations


Presentation on theme: "Digital Image Processing"— Presentation transcript:

1 Digital Image Processing
Image Enhancement Spatial Filtering 10/13/2018 Duong Anh Duc - Digital Image Processing

2 Image Enhancement: Spatial Filtering
Image enhancement in the spatial domain can be represented as: g(m,n) = T(f)(m,n) The transformation T maybe linear or nonlinear. We will mainly study linear operators T but will see one important nonlinear operation. Transformation Enhanced Image Given Image 10/13/2018 Duong Anh Duc - Digital Image Processing

3 Duong Anh Duc - Digital Image Processing
How to specify T If the operator T is linear and shift invariant (LSI), characterized by the point-spread sequence (PSS) h(m,n) , then (recall convolution) 10/13/2018 Duong Anh Duc - Digital Image Processing

4 Duong Anh Duc - Digital Image Processing
How to specify T In practice, to reduce computations, h(m,n) is of “finite extent: h(k,l) = 0 for (k,l)   where D is a small set (called neighborhood). D is also called as the support of h. In the frequency domain, this can be represented as: G(u,v) = He(u,v) Fe(u,v) where He(u,v) and Fe(u,v) are obtained after appropriate zeropadding. 10/13/2018 Duong Anh Duc - Digital Image Processing

5 Duong Anh Duc - Digital Image Processing
How to specify T Many LSI operations can be interpreted in the frequency domain as a “filtering operation.” It has the effect of filtering frequency components (passing certain frequency components and stopping others). The term filtering is generally associated with such operations. 10/13/2018 Duong Anh Duc - Digital Image Processing

6 Duong Anh Duc - Digital Image Processing
How to specify T Examples of some common filters (1-D case): Lowpass filter Highpass filter 10/13/2018 Duong Anh Duc - Digital Image Processing

7 Duong Anh Duc - Digital Image Processing
If h(m, n) is a 3 by 3 mask given by then w1 w2 w3 h= w4 w5 w6 w7 w8 w9 10/13/2018 Duong Anh Duc - Digital Image Processing

8 Duong Anh Duc - Digital Image Processing
The output g(m, n) is computed by sliding the mask over each pixel of the image f(m, n). This filtering procedure is sometimes referred to as moving average filter. Special care is required for the pixels at the border of image f(m, n). This depends on the so-called boundary condition. Common choices are: The mask is truncated at the border (free boundary) The image is extended by appending extra rows/columns at the boundaries. The extension is done by repeating the first/last row/column or by setting them to some constant (fixed boundary). The boundaries “wrap around” (periodic boundary). 10/13/2018 Duong Anh Duc - Digital Image Processing

9 Duong Anh Duc - Digital Image Processing
In any case, the final output g(m, n) is restricted to the support of the original image f(m, n). The mask operation can be implemented in MATLAB using the filter2 command, which is based on the conv2 command. 10/13/2018 Duong Anh Duc - Digital Image Processing

10 Duong Anh Duc - Digital Image Processing
Smoothing Filters Image smoothing refers to any image-to-image transformation designed to “smooth” or flatten the image by reducing the rapid pixel-to-pixel variation in grayvalues. Smoothing filters are used for: Blurring: This is usually a preprocessing step for removing small (unwanted) details before extracting the relevant (large) object, bridging gaps in lines/curves, Noise reduction: Mitigate the effect of noise by linear or nonlinear operations. 10/13/2018 Duong Anh Duc - Digital Image Processing

11 Image smoothing by averaging (lowpass spatial filtering)
Smoothing is accomplished by applying an averaging mask. An averaging mask is a mask with positive weights, which sum to 1. It computes a weighted average of the pixel values in a neighborhood. This operation is sometimes called neighborhood averaging. Some 3 x 3 averaging masks: This operation is equivalent to lowpass filtering. 10/13/2018 Duong Anh Duc - Digital Image Processing

12 Example of Image Blurring
Original Image Avg. Mask 10/13/2018 Duong Anh Duc - Digital Image Processing

13 Example of Image Blurring
10/13/2018 Duong Anh Duc - Digital Image Processing

14 Example of Image Blurring
10/13/2018 Duong Anh Duc - Digital Image Processing

15 Example of noise reduction
Noise-free Image 10/13/2018 Duong Anh Duc - Digital Image Processing

16 Example of noise reduction
Zero-mean Gaussian noise, Variance = 0.01 10/13/2018 Duong Anh Duc - Digital Image Processing

17 Example of noise reduction
Zero-mean Gaussian noise, Variance = 0.05 10/13/2018 Duong Anh Duc - Digital Image Processing

18 Duong Anh Duc - Digital Image Processing
Median Filtering The averaging filter is best suited for noise whose distribution is Gaussian: The averaging filter typically blurs edges and sharp details. The median filter usually does a better job of preserving edges. Median filter is particularly suited if the noise pattern exhibits strong (positive and negative) spikes. Example: salt and pepper noise. 10/13/2018 Duong Anh Duc - Digital Image Processing

19 Duong Anh Duc - Digital Image Processing
Median Filtering Median filter is a nonlinear filter, that also uses a mask. Each pixel is replaced by the median of the pixel values in a neighborhood of the given pixel. Suppose A ={a1, a2, …, ak} are the pixel values in a neighborhood of a given pixel with a1  a2  … ak. Then Note: Median of a set of values is the “center value,” after sorting. For example: If A ={0,1,2,4,6,6,10,12,15} then median(A) = 6. 10/13/2018 Duong Anh Duc - Digital Image Processing

20 Example of noise reduction
Gaussian noise: s = 0.2 Salt & Pepper noise: prob. = 0.2 MSE = MSE = 0.062 10/13/2018 Duong Anh Duc - Digital Image Processing

21 Example of noise reduction
Output of 3x3 Averaging filter MSE = MSE = 10/13/2018 Duong Anh Duc - Digital Image Processing

22 Example of noise reduction
Output of 3x3 Median filter MSE = MSE = 10/13/2018 Duong Anh Duc - Digital Image Processing

23 Duong Anh Duc - Digital Image Processing
Image Sharpening This involves highlighting fine details or enhancing details that have been blurred. Before After Sharpening 10/13/2018 Duong Anh Duc - Digital Image Processing

24 Basic highpass spatial filtering
This can be accomplished by a linear shift-invariant operator, implemented by means of a mask, with positive and negative coefficients. This is called a sharpening mask, since it tends to enhance abrupt graylevel changes in the image. The mask should have a positive coefficient at the center and negative coefficients at the periphery. The coefficients should sum to zero. 10/13/2018 Duong Anh Duc - Digital Image Processing

25 Basic highpass spatial filtering
Example: This is equivalent to highpass filtering. A highpass filtered image g can be thought of as the difference between the original image f and a lowpass filtered version of f : g(m,n) = f(m,n) – lowpass(f(m,n)) 10/13/2018 Duong Anh Duc - Digital Image Processing

26 Duong Anh Duc - Digital Image Processing
Example Original Image Highpass filtering 10/13/2018 Duong Anh Duc - Digital Image Processing

27 High-boost filtering This is a filter whose output g is produced by subtracting a lowpass (blurred) version of f from an amplified version of f g(m,n) = Af(m,n) – lowpass(f(m,n)) This is also referred to as unsharp masking. 10/13/2018 Duong Anh Duc - Digital Image Processing

28 Duong Anh Duc - Digital Image Processing
High-boost filtering Observe that g(m,n) = Af(m,n) – lowpass(f(m,n)) = (A-1)f(m,n) + f(m,n) – lowpass(f(m,n)) = (A-1)f(m,n) + hipass(f(m,n)) For 1 > A , part of the original image is added back to the highpass filtered version of f. The result is the original image with the edges enhanced relative to the original image. 10/13/2018 Duong Anh Duc - Digital Image Processing

29 Duong Anh Duc - Digital Image Processing
Example Original Image Highpass filtering High-boost filtering 10/13/2018 Duong Anh Duc - Digital Image Processing

30 Duong Anh Duc - Digital Image Processing
Derivative filter Averaging tends to blur details in an image. Averaging involves summation or integration. Naturally, differentiation or “differencing” would tend to enhance abrupt changes, i.e., sharpen edges. Most common differentiation operator is the gradient: 10/13/2018 Duong Anh Duc - Digital Image Processing

31 Duong Anh Duc - Digital Image Processing
Derivative filter The magnitude of the gradient is: Discrete approximations to the magnitude of the gradient is normally used. 10/13/2018 Duong Anh Duc - Digital Image Processing

32 Duong Anh Duc - Digital Image Processing
Derivative filter Consider the following image region: We may use the approximation: z1 z2 z3 z4 z5 z6 z7 z8 z9 10/13/2018 Duong Anh Duc - Digital Image Processing

33 Duong Anh Duc - Digital Image Processing
Derivative filter This can implemented using the masks: As follows: 10/13/2018 Duong Anh Duc - Digital Image Processing

34 Duong Anh Duc - Digital Image Processing
Derivative filter Alternatively, we may use the approximation: This can implemented using the masks: As follows: 10/13/2018 Duong Anh Duc - Digital Image Processing

35 Duong Anh Duc - Digital Image Processing
Derivative filter The resulting maks are called Roberts cross-gradient operators. The Roberts operators and the Prewitt/Sobel operators (described later) are used for edge detection and are sometimes called edge detectors. 10/13/2018 Duong Anh Duc - Digital Image Processing

36 Example: Roberts cross-gradient operator
10/13/2018 Duong Anh Duc - Digital Image Processing

37 Example: Roberts cross-gradient operator
10/13/2018 Duong Anh Duc - Digital Image Processing

38 Duong Anh Duc - Digital Image Processing
Prewitt operators Better approximations to the gradient can be obtained by: This can be implemented using the masks: as follows: 10/13/2018 Duong Anh Duc - Digital Image Processing

39 Duong Anh Duc - Digital Image Processing
Sobel operators Another approximation is given by the masks: The resulting masks are called Sobel operators. 10/13/2018 Duong Anh Duc - Digital Image Processing

40 Duong Anh Duc - Digital Image Processing
Example Prewitt Sobel 10/13/2018 Duong Anh Duc - Digital Image Processing


Download ppt "Digital Image Processing"

Similar presentations


Ads by Google