250 likes | 793 Views
Edge enhancement by linear (and nonlinear) filtering. Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK. Objectives. Learn what edge enhancement is, why it is useful & how it differs from edge detection Define linear and nonlinear spatial filtering
E N D
Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK
Objectives • Learn what edge enhancement is, why it is useful & how it differs from edge detection • Define linear and nonlinear spatial filtering • Design linear filters to either smoothen or sharpen the edges in an image and show how the two operations are related • Appreciate that human vision enhances edges using local operations
Edge enhancement • The purpose of edge enhancement is to highlight fine detail in an image or to restore, at least partially, detail that has been blurred (either in error or as a consequence of a particular method of image acquisition) • Applications of edge enhancement include electronic printing, medical imaging, industrial inspection, and autonomous target detection in smart weapons
Edge enhancement • Edge enhancement involves sharpening the outlines of objects and features with respect to their background • Edge detection involves isolating the outlines of objects and features • The former is easier to do than the latter
Spatial filtering • Image processing in the spatial domain may be expressed as • g(x,y) = H{f(x,y)} • where f is the input image, g is the output image, and H is an operator on f, defined over some neighbour-hood of pixel (x,y)
Spatial filtering • The neighbourhood of pixel (x,y), for image f, may be expressed as a column vector w(x,y) of pixel values • e.g. Consider a 3 by 3 square neighbourhood centred on the pixel (x,y) of interest
Spatial filtering • A spatial filter H is linear if (and only if) • H{a∙f(x,y)} = a∙H{f(x,y)} • H{f1(x,y)+f2(x,y)} = H{f1(x,y)}+H{f2(x,y)} • For any linear spatial filter H, we may write g(x,y) = h•w(x,y) where g is the output image, w is the neighbourhood vector of the input image f, and • is the inner product operator • The column vector h is called a mask and it defines the properties of the linear filter
h1 h2 h3 w1 w2 w3 g(x,y) = h4 h5 h6 • w4 w5 w6 h7 h8 h9 w7 w8 w9 = h1w1+h2w2…+h9w9 f(x,y) Spatial filtering • It is easier to visualize linear spatial filtering as an inner product of h and w over the shape of the neighbourhood • e.g. For a 3 by 3 square neighbourhood centred on the pixel (x,y) of interest
1/9 1/9 1/9 w1 w2 w3 g(x,y) = 1/9 1/9 1/9 • w4 w5 w6 1/9 1/9 1/9 w7 w8 w9 f(x,y) Smoothing filter • To understand how to sharpen edges, we first consider how to smoothen them • The simplest way to smoothen an image f is to use the neighbourhood average of pixel values to define the image g
Smoothing filter • Middle region of the original image: 8 9 83 58 15 9 11 127 34 14 10 13 160 23 14 10 19 124 17 13 10 39 93 16 14 • Middle region of the smoothed image: 9 35 52 57 33 10 48 58 59 23 11 54 59 58 19 14 53 56 53 16 20 47 49 41 16
−1/9 −1/9 −1/9 w1 w2 w3 g(x,y) = −1/9 8/9 −1/9 • w4 w5 w6 −1/9 −1/9 −1/9 w7 w8 w9 f(x,y) Embossing filter • Compared to the original image, edges in the smoothed image are slightly blurred • Thus, the difference between the original and smooth images, which may be derived by spatial filtering, holds edge information
Embossing filter • Middle region of the original image: 8 9 83 58 15 9 11 127 34 14 10 13 160 23 14 10 19 124 17 13 10 39 93 16 14 • Middle region of the embossed image: -1 -26 31 1 -18 -1 -37 69 -25 -9 -1 -41 101 -35 -5 -4 -34 68 -36 -3 -10 -8 44 -25 -2
−1/9 −1/9 −1/9 w1 w2 w3 g(x,y) = −1/9 17/9 −1/9 • w4 w5 w6 −1/9 −1/9 −1/9 w7 w8 w9 f(x,y) Sharpening filter • The embossed image holds edge inform-ation over a uniform (zero) background • Thus, the sum of the original and embossed images, which may be derived by spatial filtering, will reinforce edges of the former
Sharpening filter • Middle region of the original image: 8 9 83 58 15 9 11 127 34 14 10 13 160 23 14 10 19 124 17 13 10 39 93 16 14 • Middle region of the sharpened image: 7 0 114 59 0 8 0 196 9 5 9 0 255 0 9 6 0 192 0 10 0 31 137 0 12
Edge enhancement • Without amplification: Emboss = Original − Smooth Sharp = Original + Emboss = 2∙Original − Smooth • With amplification A: Sharp = Original + A∙Emboss = (1+A)∙Original − A∙Smooth • e.g. Consider the mask h of a 3 by 3 square neighbourhood
Edge enhancement A = 0 A = 1 A = 2
Mach Bands illusion • This image has three sections: on the left, luminance is at a constant high; on the right, luminance is at a constant low; in the middle, it declines at a constant rate • The thin bands seen on either side of the ramp (and named after their discoverer) are illusory
Mach Bands illusion • Sensory tissue is often organized so that ex-citation of any location produces inhibition of surrounding nerves • In human vision, this lateral inhibition enhances edges by producing overshoot and undershoot
Review • Edge enhancement involves sharpening the outlines of objects and features in an image with respect to their background • Image processing in the spatial domain may be expressed as g(x,y) = H{f(x,y)} where f is the input image, g is the output image, and H is a linear or nonlinear operator on f, defined over some neighbourhood of pixel (x,y) • Linear filtering may be expressed by an inner product of a mask and the neighbourhood
Review • Smoothing of edges may be achieved by neighbourhood averaging • Sharpening of edges may be achieved by subtracting a multiple, A, of the neighbour-hood average from a larger multiple, 1+A, of the neighbourhood centre • The Mach Bands illusion may be understood in terms of edge enhancement by lateral inhibition in human vision
Resources • Gonzales and Woods, Digital Image Processing, Second Edition, Prentice Hall, 2002 (get the first two chapters free from http://www.imageprocessingbook.com/) • Matlab Image Processing Toolbox • http://www.cquest.utoronto.ca/psych/psy280f/ch3/mb/mb.html (Mach Bands illusion) • http://www.siggraph.org/education/materials/HyperVis/vision/latinib.htm (lateral inhibition)