IMAGE PROCESSING: AREA OPERATIONS...
Transcript of IMAGE PROCESSING: AREA OPERATIONS...
![Page 1: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/1.jpg)
IMAGE PROCESSING: AREA OPERATIONS (FILTERING)
N. C. State University
CSC557 ♦ Multimedia Computing and Networking
Fall 2001
Lecture # 13
![Page 2: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/2.jpg)
IMAGE PROCESSING: AREA OPERATIONS (FILTERING)
N. C. State University
CSC557 ♦ Multimedia Computing and Networking
Fall 2001
Lecture # 13
![Page 3: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/3.jpg)
3Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Announcements / Questions
• ???
![Page 4: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/4.jpg)
4Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Image Frequencies
• Low frequency components = slow changes in pixel intensity — broad areas of uniform intensity / color
• High frequency components = rapid changes in pixel intensity — sharp or abrupt changes in intensity / color
— i.e., edges!
• Note: we will not use frequency-domain representations of images to any major degree
![Page 5: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/5.jpg)
5Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Example: Low Frequency Content
![Page 6: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/6.jpg)
6Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)Example: High Frequency Content
![Page 7: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/7.jpg)
7Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Convolution Kernels
• An output, or new, pixel value is computed from the input value of neighboring pixels— ex.: a weighted sum of a neighborhood of values
• Convolution of an NxN matrix (kernel) with the image— “weights” = coefficients of the kernel
— coefficients of the kernel determine its function
• Kernel size choice— smaller kernel less computation
— larger kernel higher quality results
![Page 8: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/8.jpg)
8Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Convolution Illustration
![Page 9: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/9.jpg)
9Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Convolution Example
250240220200
200130120100
18011010070
1501108050
0.20
.1.3.1
0.20
A small portion of an image
(pixel values shown are greyscale)
A 3x3 convolution kernel
141113
10988
*
Some of the output pixel values produced by convolving the image with the kernel
![Page 10: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/10.jpg)
10Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Convolution (cont’d)
• How deal with edge pixels (boundaries, again!) ?— zero fill (add black border around image), or
— duplicate the edge pixels, or
— don’t process the edges!
• What does convolution of color images mean?1. filter the luminance channel only; do not change the chroma
information
2. convolve each of R, G, and B independently
![Page 11: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/11.jpg)
11Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Smoothing (Blurring) Filters
• Smoothing = eliminate details (high frequencies)— eliminates pixelation effects, other noise
— low-pass filters
• Convolution kernels for smoothing— Usually, sum of kernel coefficients = 1
— i.e., preserves average image intensity
• Examples of smoothing— simple averaging (all pixels weighted equally)
— gaussian blurring (coefficient values approximate the normal distribution)
![Page 12: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/12.jpg)
12Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Example: Smoothing (Simple Averaging)
Before After
![Page 13: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/13.jpg)
13Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Example: Gaussian Smoothing
![Page 14: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/14.jpg)
14Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Example: Smoothing of “Noise”
![Page 15: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/15.jpg)
15Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Sharpening (Edge Detection) Filters
• Edge-detection, enhancement, or sharpening— preserve the abrupt change (edges)
— same as remove the areas of constant / similar color
— high-pass filter
• Convolution kernels for sharpening filters— generally, the sum of kernel coefficients = 0
• average image intensity almost 0 (black)
— both positive and negative coefficients• differences in signs emphasizes differences (first-order
derivative) in pixel values
• Any “negative” values that result saturate at 0 (black)
![Page 16: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/16.jpg)
16Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Examples: Edge Detection
![Page 17: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/17.jpg)
17Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Edge Detection Kernels
• Some first order (gradient) kernels— Prewitt row
— Sobel row
• Combined row and column operators for arbitrary direction
1 0 -11 0 -11 0 -1
1 0 -12 0 -21 0 -1
![Page 18: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/18.jpg)
18Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Prewitt Result
![Page 19: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/19.jpg)
19Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Sobel Result
![Page 20: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/20.jpg)
20Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Edge Direction
• Assymetric kernels detect edges from specific directions
• Example (Prewitt):
East: 1 1 -11 -2 -11 1 -1
NorthEast:1 -1 -11 -2 -11 1 1
North:-1 -1 -11 -2 11 1 1
NorthWest:-1 -1 1-1 -2 11 1 1
West: -1 1 1-1 -2 1-1 1 1
![Page 21: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/21.jpg)
21Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Directional Kernel Results
![Page 22: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/22.jpg)
22Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Second Order Derivative Kernels
• Second order kernels— Non-directional
— Results in closed curves (contours)
— Example: Laplacian
• Replace output pixel values with sign changes (zero crossings)
0 -1 0-1 4 -10 -1 0
-1 -1 -1-1 8 -1-1 -1 -1
![Page 23: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/23.jpg)
23Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
LAPLACIAN Example
![Page 24: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/24.jpg)
24Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Edge “Sharpening”
• Mix edges detected with some amount of original image
![Page 25: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/25.jpg)
25Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Discrete Cosine Transform (DCT)
• A frequency transform— uses a different set of basis functions than the Fourier transform
• Fundamental part of JPEG (image) and MPEG (video) compression
• More when we talk about JPEG next time…
![Page 26: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/26.jpg)
26Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
“Statistical” Filters
• Not based on the convolution operation
• Example: median filter is used for smoothing— preserves edges better than blurring
• Implementing median filter1. sort pixel values in a region or neighborhood
2. find the median value
3. use this as the value of the pixel in the middle of the neighborhood
— neighborhood size and shape?
![Page 27: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/27.jpg)
27Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Median Filter Example
250240220200
200130120100
18011010070
1501108050
Select median value of 3x3 neighborhood
A small portion of an image
(pixel values shown are greyscale)
180120
120100
Some of the output pixel values produced by median filtering over a 3x3 neighborhood
![Page 28: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/28.jpg)
28Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Median Filter Example
Before After
![Page 29: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/29.jpg)
29Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Median Filter of Noise
![Page 30: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/30.jpg)
30Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Other “Statistical” Filters
1. Minimum filter — Replace pixel value with the minimum (darkest) value of its
neighborhood
— result: “thinning” of the bright areas, “growing” of dark areas
2. Maximum filter— replace pixel value with the maximum (brightest) value in its
neighborhood
— result: growing the bright areas, thinning the dark areas
3. “Pixellate” functions• Related to the median filter
![Page 31: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/31.jpg)
31Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
After applying “Maximum filter”
Original
After applying “minimum filter”
Max / Min Examples
![Page 32: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/32.jpg)
32Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Pixellate Examples
![Page 33: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/33.jpg)
33Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Image Transforms
−+= ∑∑−
=
−
=)22cos(),([1),(
1
0
1
0 Nvy
Muxyxh
MNvuH
N
y
M
x
ππ
)]22sin(),(1
0
1
0 Nvy
Muxyxhj
N
y
M
x
ππ +∑∑−
=
−
=
• H(u,v) is component with frequency u < M/2, v < N/2— H(0,0) mapped to center of the image
• Computing the transform: correlate with the 2-D sine and cosine wave functions, as before
• M, N are size of image
• h(x,y) is pixel intensity at position x,y
![Page 34: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/34.jpg)
34Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Transform Example
![Page 35: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/35.jpg)
35Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Filtering In The Frequency Domain
• …for another day...
![Page 36: IMAGE PROCESSING: AREA OPERATIONS (FILTERING)reeves.csc.ncsu.edu/.../image-processing-filtering.pdf— [Crane97] A Simplified Approach to Image Processing •C hapter 3 • Optional](https://reader035.fdocuments.in/reader035/viewer/2022070906/5f7ad495839c3904002ebb74/html5/thumbnails/36.jpg)
36Copyright 2001 Douglas S. Reeves (http://reeves.csc.ncsu.edu)
Sources Of Info
• Recommended— [Crane97] A Simplified Approach to Image Processing
• Chapter 3
• Optional— [Smith97] The Scientist and Engineer’s Guide to Digital Signal
Processing• Chapters 23-25 (selected parts discussed in lecture)
— [Watkins97] Modern Image Processing