170 likes | 349 Views
Digital Image Processing Week IV. Thurdsak LEAUHATONG. Neighborhood Processing. Linear vs non-linear operation. Neighborhood processing Define center point ( x,y ) Perform operations involving only pixels in the neighborhood Result of operation is response to process at that point
E N D
Digital Image Processing Week IV Thurdsak LEAUHATONG
Neighborhood Processing Linear vs non-linear operation • Neighborhood processing • Define center point (x,y) • Perform operations involving only pixels in the neighborhood • Result of operation is response to process at that point • Moving the pixel results in a new neighborhood • Repeat process for every point in the image Spatial Filtering (Neighborhood Processing) Linear Spatial Filtering (Spatial Convolution, Correlation) Nonlinear Spatial Filtering
Linear Spatial Filtering • Linear operation • Multiply each pixel in the neighborhood by the corresponding coefficient and sum the results to get the response for each point (x,y) • If neighborhood is m x n , then mn coefficients are required • Coefficients are arranged in a matrix, called • Filter • Filter mask • Kernel • Template • Mask sizes are typically odd sizes (3x3, 5x5, etc.) • Larger the mask, greater the compute time
1-Dimensional Convolution Impulse Function, Signal Sampling • Let (t) be a unit square function whose width is a. • Impulse function d(t) is the unit square whose is zero. • A function x(t) can be considered as a sequence of the impulse functions,
1-Dimensional Convolution Linear Time Invariant System and Convolution • The impulse response of a system is the output signal when inputting the impulse function to the system. • The time-invariant system is a system whose transformation does not depend on time.
1-Dimensional Convolution Linear Time Invariant System and Convolution • Linear Transformation Properties • T(x) = y, T(x1) = y1, T(x2) = y2 • 1. T(ax) = ay • 2. T(a1x1 + a2x2) = a1y1 + a2y2 • The output of the linear time-variant system is called convolution.
1-Dimensional Convolution Algorithm • 3 Steps of computing the convolution • 1. Flip the impulse response • 2. Shift the impulse response • 3. Compute the output
1-Dimensional Convolution Example • Impulse Response sometime is called mask. • In order to convolve at the start and end of x[k], zeros are padded.
2-Dimensional Convolution Example
Low Pass Filter Smoothing Linear Filter • The output of the smoothing filter is the average of the pixels contained in the neighborhood of the filter mask (local mean). • These filters are called average filter or box filter. • The average filter is one of the low pass filter.
Low Pass Filter Smoothing Linear Filter • In filter mask, some coefficients are more important than others. For example, such as the center coefficient. • The weighted average filter is an average filter that the pixels are multiplied by different coefficients. • The general implementation of the weighted average filter is given by follows.
Low Pass Filter Gaussian Filter • The optimal smoothing filter for images should be localized in both the spatial and frequency domains. (D. Marr and E. Hildreth, “Theory of edge detection,” Proc. R. Soc. London B, vol. 207, no. 1167, pp. 187-217, Feb. 29, 1980.) • The Gaussian filter is the only one smoothing filter which satisfies the above constraint.
Order Statistic (Nonlinear) Filters Salt and Pepper Noises • Salt and pepper Noises are a form of noise typically seen on images. • It represents itself as randomly occurring white (salt) and black (pepper) pixels. • The salt and pepper noise cannot be removed by the linear filters such as average or Gaussian filter. Salt and Pepper noise Image Remove by using average filter Remove by using Gaussian filter
Order Statistic (Nonlinear) Filters Problems of Removing the Salt and Pepper Noises • The intensities of the salt and pepper noise are the minimum and maximum intensities of the local histogram. • In order to remove the noises, the output intensities must not be the minimum or maximum intensities. • However, the noises cannot be removed by the local mean (average filter).
Order Statistic (Nonlinear) Filters Median Filter • Local mean = (3+7+2+8+5+0+3+9+1)/9 • = 4.22 • Ascending sort the local intensities. • 0 1 2 3 3 5 7 8 9 • Local median = 3
Order Statistic (Nonlinear) Filters Median Filter Algorithm • Local mean = (3+7+2+8+5+0+3+9+1)/9 • = 4.22 • Ascending sort the local intensities. • 0 1 2 3 3 5 7 8 9 • Local median = 3
Sorting Algorithm Bubble Sort • { 5 1 4 2 8 } • First Run • {5 1 4 2 8 } Swap(5, 1) • {15 4 2 8 } Swap(5, 4) • {145 2 8 } Swap(5, 2) • {1425 8 } Not Swap(5, 8) • Second Run • {1425 8 } Not Swap(1, 4) • {1425 8 } Swap(4, 2) • {1245 8 } Not Swap(4, 5) • {12458 } Not Swap(5, 8) • Third Run • {1245 8 } Not Swap(1, 2) • {1245 8 } Not Swap(2, 4) • {1245 8 } Not Swap(4, 5) • {1245 8 } Not Swap(5, 8) • Stop Run