Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 ·...

63
1

Transcript of Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 ·...

Page 1: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

1

Spatial Domain Filtering

Some portions of conte

Page 2: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

2

Lecture Outline

● Basics of Spatial Filtering

● Smoothing Spatial Filters

● Averaging filters, Order-Statistics filters

● Sharpening Spatial Filters

● Laplacian filters, High-boost filters

● Gradient Masks

● Combining Spatial Enhancement Methods

Page 3: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

4

Spatial Domain

● Spatial Domain Operations – procedures that

operate directly on pixelsg(x,y) = T[F(x,y)]

where● f(x,y) is the input image● g(x,y) is the processed image● T is an operator on f defined over some neighborhood of

(x,y)

Page 4: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

5

Mask / Filter

● Neighborhood of a point (x,y) can be defined by using

a square/rectangular (commonly used) or circular

subimage area centered at (x,y) – mask or filter

● The center of the subimage is moved from pixel to

pixel starting at the top left corner of the image

Page 5: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

6

Spatial Filtering

● Use filter (can also be called as

mask / kernel / template / window)

● The values of a filter subimage are

referred to as coefficients, rather

than pixel intensities.

● Our focus will be on masks of odd

sizes, e.g. 3X3, 5x5.

● Can a filter be of even size?

Page 6: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

7

Spatial Filtering Process

● Simply move the filter mask from point to point in an

image

● At each point (x,y), the response of the filter at that

point is calculated using a predefined relationship

∑=

=

+++=mn

iiii

mnmn

zw

zwzwzwR ...2211

(Linear Filtering)

Page 7: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

8

Spatial Filtering Approaches

● Linear Filtering

● Non-linear Filtering

● Order-Statistics filtering

● Morphological filtering

● Adaptive Filtering

Page 8: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

9

How Does Linear Filtering Work?

Page 9: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

10

Linear Filtering

● Linear Filtering of an image f of size MxN by filter by mask of

size mxn is given by the expression

● To generate a complete filtered image this equation must be

applied for x = 0, 1, 2, ..., M-1 and y = 0, 1, 2, ..., N-1

● Convolution process

where a = (m-1)/2 and b = (n-1)/2

g x , y=∑s=�a

a

∑t=�b

b

w s ,t f xs , yt

Page 10: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

11

What Happens at the Borders?

● The mask falls outside the edge!

● Solutions?

● Ignore the edges

● The resultant image is smaller than the original

● Pad with zeros

● Introducing unwanted artifacts

● What else?

Page 11: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

12

Smoothing Spatial Filters

● Use: For blurring images & noise reduction

● Blurring is used in preprocessing steps, such as

● Removal of small details from an image prior to object

extraction

● Bridging of small gaps in lines or curves

● Noise Reduction can be accomplished by blurring

with linear or non-linear filters

Page 12: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

13

Smoothing Linear Filters

● Output is simply the average of the pixels contained

in the neighborhood of the filter mask

● Also referred to as averaging filters or lowpass filters

(explained in future lecture)

Page 13: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

14

Averaging Filter: An Intuitive Approach

● Replace each pixel by the average of pixels in a

square window surrounding this pixel

● 3x3 averaging filter

● What happens if we use an averaging filter with a

larger window?

Page 14: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

15

Example: Applying 3x3 Averaging Filter

Assume edges ignored, thus resultant image is 3x3

Page 15: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

16

More Examples

● Original image, size 500x500

pixels

● Results of smoothing with

averaging filter masks of

size n=3, 5, 9, 15, 35

respectively

(order: left to right, top to bottom)

Page 16: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

17

Example: Space Imagery

Page 17: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

18

Smoothing Linear Filters

● Able to reduce sharp transitions in gray levels

● Random noise in the image

● Edges of objects in the image

● Smoothing can reduce noises (desirable) and blur

edges (undesirable)

Page 18: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

19

3x3 Smoothing Linear Filters

box filter weighted average

Page 19: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

20

Weighted Averaging Filter

● Instead of averaging all the pixel values in the window, give

the closer-by pixels higher weighting, and far-away pixels

lower weighting

● Reduce value of coefficients as a function of increasing

distance from the origin

● An attempt to reduce blurring in the smoothing process

Page 20: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

21

General form: Smoothing Mask

● Filter of size m x n (m and n odd)

∑∑

∑∑

−= −=

−= −=

++= a

as

b

bt

a

as

b

bt

tsw

tysxftswyxg

),(

),(),(),(

Summation of all

coefficients of the mask

Page 21: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

22

Example: Lena 'Smoothen'

Page 22: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

23

Other Common Smoothing Filters

● Criteria for designing a smoothing filter

● w(s, t) ≥ 0 (function as averaging)

● (mean value is preserved)

● Another popular smoothing filter: Gaussian filter

∑s=�a

a

∑t=�b

b

w s ,t =1

Page 23: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

24

Order-Statistics Filters

● Non-linear filters

● Response is based on ordering (ranking) the pixels contained

in the image area encompassed by the filter

● Example:

● Median filter:

● Max filter:

● Min filter:

(Note: n x n is the size of the mask)

R=median zk , k=1,2,. .. , n xn

R=max zk , k=1,2,. .. , n xn

R=min zk , k=1,2,. .. , n x n

Page 24: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

25

Median Filters

● Replaces the value of a pixel by the median of the gray levels

in the specified neighborhood of that pixel (Original value of

the pixel is included in the computation of the median)

● Popularly used for certain types of random noise (impulse

noise, salt and pepper noise)

– Excellent noise-reduction capabilities

– Less blurring effect that linear smoothing filters of similar size

● Intuitively, how do they work?

Page 25: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

26

Example: Fighting Salt and Pepper

Noise

Page 26: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

27

Sharpening Spatial Filters

● Sharpening: to enhance line structures or other

details in an image

● Sharpening Spatial Filters:

– To highlight fine detail or edges in an image

– To enhance and focus on details that has been blurred,

either in error or as a natural effect of a particular method

of image acquisition

Page 27: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

Image Sharpening

• Blur the original image

• Add the Laplacian

g(x, y) = f(x, y) ± c ⋅ ∇2f(x, y)

6

Page 28: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

28

Blurring vs. Sharpening

● Blurring can be done in spatial domain by pixel

averaging in the neighborhood of a pixel

● Since averaging is analogous to integration...

● Can we conclude that sharpening is accomplished by

spatial differentiation?

Page 29: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

29

Derivative Operator

● The strength of the response of a derivative operator

is proportional to the degree of discontinuity of the

image at the point at which the operator is applied

● Image differentiation

– Enhances edges and other discontinuities (such as noise)

– De-emphasizes area with slowly varying gray-level values

Page 30: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

30

First-order Derivative

● A basic definition of the first-order derivative of a

one-dimensional function f(x) is the difference

)()1( xfxfx

f −+=∂∂

Page 31: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

31

Second-order Derivative

● Similarly, the second-order derivative of a one-

dimensional function f(x) is the difference

)(2)1()1(2

2

xfxfxfx

f −−++=∂∂

Page 32: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

32

First & Second Derivatives of f(x,y)

● Consider an image function of two variables f(x,y), we

are dealing with partial derivatives along the two

spatial axes.

y

yxf

x

yxf

yx

yxf

∂∂+

∂∂=

∂∂∂=∇ ),(),(),(

f

2

2

2

22 ),(),(

y

yxf

x

yxff

∂∂+

∂∂=∇Laplacian operator

Gradient operator

Page 33: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

33

Discrete form of Laplacian

From

yield,

),(2),1(),1(2

2

yxfyxfyxfx

f −−++=∂∂

),(2)1,()1,(2

2

yxfyxfyxfy

f −−++=∂∂

)],(4)1,()1,(

),1(),1([2

yxfyxfyxf

yxfyxff

−−+++−++=∇

Page 34: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

34

Laplacian Mask

● The Laplacian mask contains the coefficients of the Laplacian

operator (second-order derivatives)

Page 35: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

35

Laplacian Mask witih Diagonal Terms

● This Laplacian mask is implemented differently by

incorporating the diagonal directions. The center value is

now -8 due to the total subtracted from the difference terms.

Page 36: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

36

Other Implementations of Laplacian

Masks

● These masks (difference in sign) give the same result as the

previous two masks.

● The difference in sign must be kept in mind when combining

(add / subtract) a Laplacian-filtered image with another

image

Page 37: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

37

Effect of Laplacian Operator

● Tends to produce images that have

– Grayish edge lines and other discontinuities (in brighter intensities),

all superimposed on a dark, featureless background

● To correct the effect of featureless background

– Add the original and Laplacian-filtered image together

– Be careful with the Laplacian filter used

∇+∇−

=),(),(

),(),(),(

2

2

yxfyxf

yxfyxfyxg

if the center coefficient of the

Laplacian mask is negative

if the center coefficient of the

Laplacian mask is positive

Page 38: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

38

Example: Moon Images

● Image of the moon

● Laplacian-filtered image with

● Laplacian image scaled for

display purposes

● Image enhanced (sharpened) by

adding Laplacian-filtered image

to the original image

(Note: left to right, top to bottom)

111

1-81

111

Page 39: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

39

Simplifications

● To simplify the computation, we can create a mask which do

both operations, Laplacian filter and Addition of original

image

● Composite Laplacian Mask

)]1,()1,(

),1(),1([),(5

),(4)]1,()1,(

),1(),1([),(),(

−+++−++−=

+−+++−++−=

yxfyxf

yxfyxfyxf

yxfyxfyxf

yxfyxfyxfyxg

0-10

-15-1

0-10

Page 40: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

40

Composite Laplacian Mask

Page 41: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

41

Composite Laplacian Mask

● Which composite mask (normal Laplacian / Laplacian with

diagonal terms) can produce better image sharpening?

0-10

-19-1

0-10

0-10

-15-1

0-10

Page 42: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

42

Composite Laplacian Mask

0-10

-19-1

0-10

0-10

-15-1

0-10

∇+∇−

=),(),(

),(),(),(

2

2

yxfyxf

yxfyxfyxg

000

010

000

0-10

-14-1

0-10

= +

000

010

000

0-10

-18-1

0-10

+=

Page 43: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

43

Unsharp Masking

● A process used many years in the publishing industry

to sharpen images

● Sharpened image: Subtracting a blurred version of an

image from the image itself

),(),(),( yxfyxfyxf s −=sharpened image = original image – blurred image

Page 44: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

44

Unsharp Masking

● Can you make sense of unsharp masking?

Page 45: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

45

High-Boost Filtering

● High-boost Filtering: A further generalization of

unsharp masking

),(),(),( yxfyxAfyxfhb −=

),(),()1(

),(),(),()1(),(

yxfyxfA

yxfyxfyxfAyxf

s

hb

+−=−+−=

1≥Awhere

Page 46: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

46

High-Boost Filtering

● This general equation does not state explicitly how the sharp

image is obtained...

● If we choose to use Laplacian operator to sharpen the image,

we get

),(),()1(),( yxfyxfAyxf shb +−=

∇+∇−

=),(),(

),(),(),(

2

2

yxfyxAf

yxfyxAfyxfhb

if the center coefficient

of the Laplacian mask is

negative

if the center coefficient

of the Laplacian mask is

positive

Page 47: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

47

High-Boost Filtering

● If A = 1, it becomes a “standard” Laplacian sharpening

1≥A

Page 48: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

48

Example: High-Boost Filtering

Page 49: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

49

Example: Lena 'Sharpened'

Page 50: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

50

First Derivatives: Gradient Operator

● First derivatives are implemented using the

magnitude of the gradient

∂∂∂∂

=

=∇

y

fx

f

G

G

y

xf

21

22

2122 ][)f(

∂∂+

∂∂=

+=∇=∇

y

f

x

f

GGmagf yx

The magnitude becomes nonlinear

yx GGf +≈∇Approximation:

Page 51: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining
Page 52: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

51

Gradient Mask

● On the basis of a first-order derivative of a 2-D

function f(x,y), the simplest approximation of the

gradient mask: 2x2

)( and )( 5658 zzGzzG yx −=−=

212

562

582

122 ])()[(][ zzzzGGf yx −+−=+=∇

5658 zzzzf −+−≈∇z9z8z7

z6z5z4

z3z2z1

Page 53: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

52

Gradient Mask

● Roberts 2x2 cross-gradient operators [1965]

)( and )( 6859 zzGzzG yx −=−=

212

682

592

122 ])()[(][ zzzzGGf yx −+−=+=∇

6859 zzzzf −+−≈∇ z9z8z7

z6z5z4

z3z2z1

Page 54: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

53

Gradient Mask

● Sobel operators, 3x3

z9z8z7

z6z5z4

z3z2z1

)2()2(

)2()2(

741963

321987

zzzzzzG

zzzzzzG

y

x

++−++=++−++=

yx GGf +≈∇

The weight value 2 is to achieve

smoothing by giving more

important to the center point

Page 55: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

54

Example: Gradient Filtering

More on gradient masks will be covered under

Edge Detection (Image Segmentation)

Page 56: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

55

Gradient Mask

● The summation of coefficients in gradient masks

equals 0, indicating that they would give a response

of 0 in an area of constant gray level

Page 57: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

56

Figure out!

● The summation of coefficients in a mask equals 0 for both

gradient operators (1st derivative) and Laplacian operators

(2nd derivative)

● The summation of coefficients in a smoothing mask equals 1

● Why???

Page 58: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

57

Separable Filters

● In 2D filtering, some filters can be implemented by successive

application of two simpler filters

– One horizontal followed by another vertical

● This can significantly lower the computational complexity

● By how much? For a mask of size n x n,

– Originally, n2 multiplications and n2 – 1 additions

– After separation, 2n multiplications and 2n – 2 additions

Page 59: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

58

Values Outside the Range?

● Linear filtering might bring the intensity outside the display

range

● Solutions?

– Clip values

– Scaling transformation

Transform values in [gL, gH] to [0, 255]

>≤≤

<=

255 xif ,255

255x0 if x,

0 x if 0,

y

LH

L

gg

gxy

−−= 255

Page 60: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

59

Example: Combining Spatial

Enhancement Methods● Target: To sharpen the original

image and bring out more

skeletal detail

● Problems:

– Narrow dynamic range of

gray level

– High noise content makes

image difficult to enhance

Page 61: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

60

Example: Combining Spatial

Enhancement Methods

I. Laplacian to highlight fine

details

II. Gradient to enhance prominent

edges

III.Gray level transformation to

increase the dynamic range of

gray levels

Solution:

Page 62: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

61

Example: Combining Spatial

Enhancement Methods

Page 63: Spatial Domain Filtering - Gaziantep Üniversitesiskoc/spatial-filter.pdf · 2010-03-18 · Sharpening Spatial Filters Laplacian filters, High-boost filters Gradient Masks Combining

62

Example: Combining Spatial

Enhancement Methods