KEMBAR78
3 ImageProcessing-SpatialFiltering | PDF | Electronics | Computer Graphics
0% found this document useful (0 votes)
12 views19 pages

3 ImageProcessing-SpatialFiltering

The document discusses spatial filtering in image processing, focusing on techniques such as smoothing and sharpening filters. It explains the use of neighborhood operations, linear and nonlinear filtering methods, and the effects of different filters on image quality. Additionally, it covers the importance of median filtering for noise reduction and the principles behind highpass and high boost filtering for enhancing image details.

Uploaded by

try.admerch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views19 pages

3 ImageProcessing-SpatialFiltering

The document discusses spatial filtering in image processing, focusing on techniques such as smoothing and sharpening filters. It explains the use of neighborhood operations, linear and nonlinear filtering methods, and the effects of different filters on image quality. Additionally, it covers the importance of median filtering for noise reduction and the principles behind highpass and high boost filtering for enhancing image details.

Uploaded by

try.admerch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

1 2

of
39
of
39
BACKGROUND
The use of spatial masks for image processing
usually is called spatial filtering
At each point (x,y), the response of the filter at
Image Enhancement- that point is calculated using a predefined
relationship
Spatial Filtering

1 2

1
3 4
of
39
BACKGROUND of
39
Neighbourhood Operations
Neighbourhood operations simply operate
The mask: also called filter, kernel, template or on a larger neighbourhood of pixels than
window
point operations Origin x
The values in a filter mask are called coefficients, not
pixels Neighbourhoods are
mostly a rectangle
around a central pixel
(x, y)
Any size rectangle Neighbourhood

and any shape filter


are possible
3 y Image f (x, y)

3 4

2
5 6
of
39
Neighbourhood Operations of
39
Neighbourhood Operations
For each pixel in the origin image, the Simple neighbourhood operations example:
outcome is written on the same location at
the target image. – Min: Set the pixel value to the minimum in
Origin Target
Origin x the neighbourhood

– Max: Set the pixel value to the maximum in


(x, y) the neighbourhood
Neighbourhood

y Image f (x, y)

5 6

3
7 8
of
39
Basic of Spatial Filtering of
39
The Spatial Filtering Process
Origin x
Linear spatial filtering often is referred to as a b c j k l
“convolving a mask with an image” d e f
* m n o

Nonlinear spatial filtering g h i p q r


Original Image Filter (w)
– The filtering operation is based conditionally Simple 3*3
e 3*3 Filter Pixels
Neighbourhood
on the values of the pixels in the
eprocessed = n*e +
neighborhood under consideration, but not j*a + k*b + l*c +
explicitly use coefficients in the sum-of- m*d + o*f +
products manner y Image f (x, y) p*g + q*h + r*i
– e.g., median filter for noise reduction: compute
the median gray-level value in the The above is repeated for every pixel in the
neighborhood 7 original image to generate the filtered image
7 8

4
10 11
of
39
Operation Steps of
39
Smoothing Spatial Filters
One of the simplest spatial filtering
1. Select a single pixel.
2. Determine the pixel’s neighborhood.
operations we can perform is a smoothing
3. Apply a function to the values of the pixels in the neighborhood. operation
4. Find the pixel in the output image whose position corresponds
to that of the center pixel in the input image. Set this output pixel
– Simply average all of the pixels in a
to the value returned by the function. neighbourhood around a central value
5. Repeat steps 1 through 4 for each pixel in the input image. – Especially useful
1/ 1/ 1/
in removing noise 9 9 9
from images Simple
1/ 1/ 1/
– Also useful for 9 9 9 averaging
highlighting gross filter
1/ 1/ 1/
detail 9 9 9
10

10 11

5
12 13
of
39
Smoothing Spatial Filters of
39
Smoothing Spatial Filters(cont.)
Purpose: blurring or noise reduction
Low pass spatial filtering
– removes high frequency components
– Neighborhood averaging
– Can use different size of masks
– Sum of the mask coefficients is 1
– Drawbacks: blur edges and other sharp features
Median filtering
– Nonlinear
– The gray level of each pixel is replaced by the median
of its neighbors
– Good at denoising 12 13

12 13

6
14 15
of
39
Smoothing Spatial Filtering of
39
Image Smoothing Example
Origin x
104 100 108 1/
9
1/
9
1/
9 The image at the top left
is an original image of
99 106 98

95 90 85
* 1/

1/
9
1/

1/
9
1/

1/
9
size 500*500 pixels
9 9 9

Simple 3*3
1/ 100
104
9
1/ 108
9
1/
9
3*3 Smoothing
Original Image Filter The subsequent images
1/
99 1/ 1/
9 98
9 106
Pixels
Neighbourhood 195
/9 190
/9
9
185
/9
Filter show the image after
e = 1/9*106 +
1/ *104 + 1/ *100 + 1/ *108 + filtering with an averaging
9 9 9
1/ *99 + 1/ *98 +
9 9
filter of increasing sizes
y Image f (x, y) 1/ *95 + 1/ *90 + 1/ *85
9 9 9 – 3, 5, 9, 15 and 35
= 98.3333
Notice how detail begins
The above is repeated for every pixel in the
to disappear
original image to generate the smoothed image
14 15

7
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

16
of
39
16
Image Smoothing Example

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

17
of
39
17
Image Smoothing Example

8
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

18
of
39
18
Image Smoothing Example

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

19
of
39
19
Image Smoothing Example

9
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

20
of
39
20
Image Smoothing Example

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

21
of
39
21
Image Smoothing Example

10
22 23
of
39
Weighted Smoothing Filters of
39
Another Smoothing Example
More effective smoothing filters can be By smoothing the original image we get rid

Images taken from Gonzalez & Woods, Digital Image Processing (2002)
generated by allowing different pixels in the of lots of the finer detail which leaves only
neighbourhood and different weights in the the gross features for thresholding
averaging function
1/ 2/ 1/
– Pixels closer to the 16 16 16
central pixel are more
2/ 4/ 2/
important 16 16 16

– Often referred to as a 1/ 2/ 1/
weighted averaging 16 16 16
Original Image Smoothed Image Thresholded Image
Weighted
averaging filter * Image taken from Hubble Space Telescope

22 23

11
24
of
Averaging Filter Vs. Median Filter 25
of
Averaging Filter Vs. Median Filter
39 Example 39 Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Original

Original Image Image After Image After


With Noise Averaging Filter Median Filter

Filtering is often used to remove noise from


images
Sometimes a median filter works better than
an averaging filter

24 25

12
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

26
of
39
26

Filter
Averaging
Averaging Filter Vs. Median Filter
Example

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

27
of
39
27

Filter
Median
Averaging Filter Vs. Median Filter
Example

13
28 29
of
39
Median filtering of
39
Strange Things Happen At The Edges!
Nonlinear spatial filters whose response is based on
ordering the pixels in the area to be filtered
At the edges of an image we are missing
– Examples : max filter, min filter & median filter pixels to form a neighbourhood
Median filter Origin x
– The median m of a set of values is such that half the values in the e e
set are less than m and half are greater than m
– Replace the value of a pixel by the median of the gray levels in
the neighborhood of that pixel
– Force points with distinct gray levels to be more like their e
neighbors
e
– For 3 x 3 neighborhood
(10, 15, 20, 20, 25, 20, 20, 20,100) sorted as (10, 15, 20, 20, 20,
20, 20, 25, 100 ) -> median is 20
e e e
28 y Image f (x, y)

28 29

14
30 Strange Things Happen At The Edges! 32
of
39 (cont…)
of
39
Sharpening Spatial Filters
There are a few approaches to dealing with Previously we have looked at smoothing
missing edge pixels: filters which remove fine detail
– Omit missing pixels Sharpening spatial filters seek to highlight
• Only works with some filters fine detail
• Can add extra code and slow down processing
– Remove blurring from images
– Pad the image
– Highlight edges
• Typically with either all white or all black pixels
– Replicate border pixels
Sharpening filters are based on spatial
differentiation
– Truncate the image

30 32

15
33 34
of
39
Sharpening filters of
39
Sharpening filters
Highlight fine detail in an image or to enhance – Basic highpass spatial filtering
detail that has been blurred – High-boost filtering
Averaging is analogous to integration, and
sharpening can be accomplished by spatial
differentiation
Uses of image sharpening vary and include
applications ranging from electronic printing
and medical imaging to industrial inspection
and autonomous target detection in smart
weapons
33 34

33 34

16
35 36
of
39
Highpass filters of
39
Basic HighPass Spatial Filtering
• Eliminates the low frequency regions while retaining or The shape of the impulse response needed to implement
enhancing the high frequency components a highpass spatial filter indicates that the filter should have
• A high passed image would have no background and would positive coefficients near its center, and negative
have enhanced edges coefficients in the outer periphery
• Used to sharpen the blurred images.

High Pass Mask


– Note the sum of the coefficients is 0
– When the filter is over an area of constant or slowly
varying gray level, the output of the filter is zero or very
small
35 36

35 36

17
37 38
of
39
Example of
39
High Boost Filtering
(a) (b) • High pass filter gives great results
• But, it gets rid of the complete background
• In some cases we need to enhance the edges by
retaining the background
• Modified version of the high pass filter is known
as high boost filtering
(a)Image of a human retina; (b)highpass filtered result using the mask

As expected, the result is characterized by somewhat enhanced


edges over a rather dark background

37

37 38

18
39
of
39
High Boost Filtering

A highpass filtered image may be computed as the


difference between the original image and a
lowpass filtered version of that image
Highpass = Original-Lowpass
A : Multiplying the original image by an amplification
factor
High boost = (A)(Original) -Lowpass
= (A-1)(Original) + Original -Lowpass
= (A-1)(Original) + Highpass

39

39

19

You might also like