IMAGE FILTERING INEL 6088 Computer Vision References: Chapter 4 Jain et al, Chapter 3 Davies
2.3 Convolutions and Point Spread Functions 39 at perfectly good algorithm strategies that mysteriously turn out not to work well in practice! 2.3 Convolutions and Point Spread Functions Convolution is a powerful and widely used technique in image processing and 2.3 Convolutions and Point Spread Functions 39 other areas of science. Because it appears in many applications throughout this book, it is useful to introduce it at an early stage. We start by defining the convolution of two functions/(x) and g(x) as the integral: at perfectly good algorithm strategies that mysteriously turn out not to work well in practice! f(x) * g(x) = / f(u)g(x - u)du (2.26) J—oo The action of this integral is normally described as the result of applying a point 2.3 Convolutions and Point Spread Functions spread function g(x) to all points of a function f(x) and accumulating the contributions at every point. It is significant that if the point spread function (PSF) Convolution is a powerful and widely used technique in image processing and is very narrow,^ then the convolution is identical to the original function/(x). This other areas of science. Because it appears in many applications throughout this makes it natural to think of the function/(x) as having been spread out under the book, it is useful to introduce it at an early stage. We start by defining the influence of g(x). This argument may give the impression that convolution convolution of two functions/(x) and g(x) as the integral: necessarily blurs the original function, but this is not always so if, for example, the PSF has a distribution of positive and negative values. f(x) * g(x) = / f(u)g(x - u)du (2.26) 40 CHAPTER 2 Images and Imaging Operations When convolution is appHed to digital images, the above formulation changes J—oo The action of this integral is normally described as the result of applying a point in two ways: (1) a double integral must be used in respect of the two dimensions; CONVOLUTION spread function g(x) to all points of a function f(x) and accumulating the and (2) integration must be changed into discrete summation. The new form of the Convolution can then be calculated using the more intuitive formula: contributions at every point. It is significant that if the point spread function (PSF) convolution is: is very narrow,^ then the convolution is identical to the original function/(x). This makes it natural to think of the function/(x) as having been spread out under the influence of g(x). This argument may give the impression that convolution (2.29) necessarily blurs the original function, but this is not always so if, for example, the i J PSF has a distribution of positive and negative values. f ( x ) ⋆ g ( x ) = ∫ + ∞ m When convolution is appHed to digital images, the above formulation changes ∑ Clearly, this involves multiplying corresponding values in the modified mask and f ( u ) g ( x − u ) du ⇒ f ( i ) ⋆ g ( i ) = f ( k ) g ( i − k ) 1D: where g is now referred to as a spatial convolution mask. When convolutions are in two ways: (1) a double integral must be used in respect of the two dimensions; the neighborhood under consideration. Reexpressing this result for a 3 x 3 and (2) integration must be changed into discrete summation. The new form of the −∞ performed on whole images, it is usual to restrict the sizes of masks as far as k =1 neighborhood and writing the mask coefficients in the form: convolution is: 2D, discrete possible in order to save computation. Thus, convolution masks are seldom larger than 15 pixels square, and 3 x 3 masks are typical. The fact that the mask has to be inverted before it is applied is inconvenient for visualizing the process of h4 h3 h2" 40 CHAPTER 2 Images and Imaging Operations convolution. In this book we therefore present only preinverted masks of the form: h5 hO hi where g is now referred to as a spatial convolution mask. When convolutions are Convolution can then be calculated using the more intuitive formula: h6 h7 h8 For convenience, pre-calculate h{x^y) = g(-x^~y) (2.28) performed on whole images, it is usual to restrict the sizes of masks as far as mask possible in order to save computation. Thus, convolution masks are seldom (2.29) the algorithm can be obtained in terms of our earlier notation: larger than 15 pixels square, and 3 x 3 masks are typical. The fact that the mask has 5 Formally, it can be a delta function, which is infinite at one point and zero elsewhere while having an i J to be inverted before it is applied is inconvenient for visualizing the process of integral of unity. convolution. In this book we therefore present only preinverted masks of the form: CONV : [[ q 0 = p 0 h 0 + p 1 h 1 + p 2 h 2 + p 3 h 3 CONVOLV: [[ QO = PO * hO + PI * hi + P2 * h2 + P3 * h3 + P4 * h4 Clearly, this involves multiplying corresponding values in the modified mask and the neighborhood under consideration. Reexpressing this result for a 3 x 3 h{x^y) = g(-x^~y) (2.28) + p 4 h 4 + p 5 h 5 + p 6 + h 6 + p 7 h 7 + p 8 h 8 ]] +P5 * h5 + P6 * h6 + P7 * h7 -f P8 * h8; ]] (2.30) neighborhood and writing the mask coefficients in the form: We are now in a position to apply convolution to a real situation. At this 5 Formally, it can be a delta function, which is infinite at one point and zero elsewhere while having an h4 h3 h2" integral of unity. stage we merely extend the ideas of the previous section, attempting to suppress h5 hO hi noise by averaging not over corresponding pixels of different images, but over h6 h7 h8 nearby pixels in the same image. A simple way of achieving this is to use the convolution mask: the algorithm can be obtained in terms of our earlier notation: "1 1 1 CONVOLV: [[ QO = PO * hO + PI * hi + P2 * h2 + P3 * h3 + P4 * h4 1 1 1 1 +P5 * h5 + P6 * h6 + P7 * h7 -f P8 * h8; ]] (2.30) 9 1 1 1 We are now in a position to apply convolution to a real situation. At this stage we merely extend the ideas of the previous section, attempting to suppress noise by averaging not over corresponding pixels of different images, but over where the number in front of the mask weights all the coefficients in the mask nearby pixels in the same image. A simple way of achieving this is to use the and is inserted to ensure that applying the convolution does not alter the mean convolution mask: intensity in the image. As hinted earher, this particular convolution has the effect of blurring the image as well as reducing the noise level (Fig. 2.17). More will "1 1 1 be said about this in the next chapter. 1 1 1 1 Convolutions are linear operators and are the most general spatially invariant 9 1 1 1 linear operators that can be applied to a signal such as an image. Note that linearity is often of interest in that it permits mathematical analysis to be performed that would otherwise be intractable. where the number in front of the mask weights all the coefficients in the mask and is inserted to ensure that applying the convolution does not alter the mean intensity in the image. As hinted earher, this particular convolution has the effect of blurring the image as well as reducing the noise level (Fig. 2.17). More will be said about this in the next chapter. Convolutions are linear operators and are the most general spatially invariant linear operators that can be applied to a signal such as an image. Note that linearity is often of interest in that it permits mathematical analysis to be performed that would otherwise be intractable.
CHARACTERISTICS OF CONVOLUTION • Linear (convolution of a sum is the sum of the convolutions) • Convolution of a scaled image is the scaled convolution • Spatially invariant • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain • Frequency-domain convolution used only for very large kernels – not common in machine vision • The kernel defines the filter being used • We use non-linear filters as well; formalism does not apply but many are used in a very similar way. 3
Common Types of Noise Noise-free Impulse - Gaussian – random Salt & pepper - Only random gray level variations Random black & white white pixels 4
ADDITIVE WHITE GAUSSIAN NOISE 5
MEAN FILTER Smoothing filter: pixel weights are not equal, Single-peak, or main lope but are usually symmetric and add 1. 6
Mean Filter Applied to Noisy Images 3 × 3 5 × 5 7 × 7 7
Result of using the smoothing filter seen previously 8
MEDIAN FILTER Nonlinear filter - effective to remove salt & pepper and impulse noise without removing too much image detail. MATLAB Example 9
MATLAB EXAMPLE openExample('images/CompareResultsOfAveragingFilterAndMedianFilterExample') I = imread('eight.tif'); figure imshow(I)
% For this example, add salt and pepper noise to the image. This % type of noise consists of random pixels being set to black or % % white (the extremes of the data range). J = imnoise(I,'salt & pepper',0.02); figure imshow(J)
% Filter the noisy image, |J|, % Now use a median filter to filter % with an averaging filter and % the noisy image, |J|. The example % display the results. The % also uses a 3-by-3 neighborhood. % example uses a 3-by-3 % Display the two filtered images % neighborhood. % side-by-side for comparison. Notice Kaverage = % that |medfilt2| does a better job % of removing noise, with less filter2(fspecial('average',3),J)/ % blurring of edges of the coins. 255; Kmedian = medfilt2(J); figure imshowpair(Kaverage,Kmedian,'montage') imshow(Kaverage)
Recommend
More recommend