Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering...

21
Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK

Transcript of Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering...

Page 1: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

Edge enhancement by linear (and nonlinear) filtering

Dr. Dileepan Joseph

Dept. of Engineering Science

University of Oxford, UK

Page 2: 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

Page 3: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 4: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 5: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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)

Page 6: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

)1,1(

)1,(

)1,1(

),1(

),(

),1(

)1,1(

)1,(

)1,1(

),(

yxf

yxf

yxf

yxf

yxf

yxf

yxf

yxf

yxf

yxw

Page 7: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 8: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

g(x,y) = 

h1 h2 h3

h4 h5 h6

h7 h8 h9

w1 w2 w3

w4 w5 w6

w7 w8 w9

h1w1+h2w2…+h9w9=  f(x,y)

Page 9: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

g(x,y) = 

1/9 1/9 1/9

1/9 1/9 1/9

1/9 1/9 1/9

w1 w2 w3

w4 w5 w6

w7 w8 w9

f(x,y)

Page 10: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

Smoothing filter

Middle region of the original image:

8 9 83 58 15

9 11 127 3411 127 34 14

10 13 160 2313 160 23 14

10 19 124 1719 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 5959 58 19

14 53 56 53 16

20 47 49 41 16

Page 11: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

g(x,y) = 

−1/9 −1/9 −1/9

−1/9 8/9 −1/9

−1/9 −1/9 −1/9

w1 w2 w3

w4 w5 w6

w7 w8 w9

f(x,y)

Page 12: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

Embossing filter

Middle region of the original image:

8 9 83 58 15

9 11 127 3411 127 34 14

10 13 160 2313 160 23 14

10 19 124 1719 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 101101 -35 -5

-4 -34 68 -36 -3

-10 -8 44 -25 -2

Page 13: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

g(x,y) = 

−1/9 −1/9 −1/9

−1/9 17/9 −1/9

−1/9 −1/9 −1/9

w1 w2 w3

w4 w5 w6

w7 w8 w9

f(x,y)

Page 14: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

Sharpening filter

Middle region of the original image:

8 9 83 58 15

9 11 127 3411 127 34 14

10 13 160 2313 160 23 14

10 19 124 1719 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 255255 0 9

6 0 192 0 10

0 31 137 0 12

Page 15: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

9

9

9

9

91

9

9

9

9

A

A

A

A

AA

A

A

A

A

h

Page 16: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

Edge enhancement

A = 0 A = 1 A = 2

Page 17: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 18: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 19: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 20: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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

Page 21: Edge enhancement by linear (and nonlinear) filtering Dr. Dileepan Joseph Dept. of Engineering Science University of Oxford, UK.

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)