SlideShare a Scribd company logo
1 of 89
Spatial Filtering
Background
Filter term in “Digital image processing”
is referred to the subimage
There are others term to call subimage
such as mask, kernel, template, or
window
The value in a filter subimage are
referred as coefficients, rather than
pixels.
Basics of Spatial Filtering
The concept of filtering has its roots in
the use of the Fourier transform for
signal processing in the so-called
frequency domain.
Spatial filtering term is the filtering
operations that are performed directly
on the pixels of an image
Mechanics of spatial filtering
The process consists simply of moving
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
Neighbourhood Operations
Neighbourhood operations simply
operate on a larger neighbourhood of
pixels than point operations
Neighbourhoods are
mostly a rectangle
around a central pixel
Any size rectangle
and any shape filter
are possible
Origin x
y Image f (x, y)
(x, y)
Neighbourhood
Simple Neighbourhood
Operations
Some simple neighbourhood operations
include:
Min: Set the pixel value to the minimum in
the neighbourhood
Max: Set the pixel value to the maximum
in the neighbourhood
Median: The median value of a set of
numbers is the midpoint value in that set
(e.g. from the set [1, 7, 15, 18, 24] 15 is
the median). Sometimes the median works
better than the average
The Spatial Filtering Process
r s t
u v w
x y z
Origin x
y Image f (x, y)
eprocessed = v*e +
r*a + s*b + t*c +
u*d + w*f +
x*g + y*h + z*i
Filter
Simple 3*3
Neighbourhood
e 3*3 Filter
a b c
d e f
g h i
Original
Image
Pixels
*
The above is repeated for every pixel in the original
image to generate the filtered image
Spatial Filtering: Equation Form


 




a
a
s
b
b
t
t
y
s
x
f
t
s
w
y
x
g )
,
(
)
,
(
)
,
(
Filtering can be given
in equation form as
shown above
Notations are based on
the image shown to the
left
Spatial Filtering: Equation Form


 




a
a
s
b
b
t
t
y
s
x
f
t
s
w
y
x
g )
,
(
)
,
(
)
,
(
Filtering can be given
in equation form as
shown above
Notations are based on
the image shown to the
left
Linear spatial filtering
f(x-1,y-1) f(x-1,y) f(x-1,y+1)
f(x,y-1) f(x,y) f(x,y+1)
f(x+1,y-1) f(x+1,y) f(x+1,y+1)
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,-1) w(1,0) w(1,1)
The result is the sum of
products of the mask
coefficients with the
corresponding pixels directly
under the mask
Pixels of image
Mask coefficients
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,-1) w(1,0) w(1,1)
)
1
,
1
(
)
1
,
1
(
)
,
1
(
)
0
,
1
(
)
1
,
1
(
)
1
,
1
(
)
1
,
(
)
1
,
0
(
)
,
(
)
0
,
0
(
)
1
,
(
)
1
,
0
(
)
1
,
1
(
)
1
,
1
(
)
,
1
(
)
0
,
1
(
)
1
,
1
(
)
1
,
1
(


























y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w

)
,
( y
x
f
Linear filtering
The coefficient w(0,0) coincides with image
value f(x,y), indicating that the mask is
centered at (x,y) when the computation of
sum of products takes place.
For a mask of size mxn, we assume that
m=2a+1 and n=2b+1, where a and b are
nonnegative integer. Then m and n are odd.
Linear filtering
In general, linear filtering of an image f
of size MxN with a filter mask of size
mxn is given by the expression:


 




a
a
s
b
b
t
t
y
s
x
f
t
s
w
y
x
g )
,
(
)
,
(
)
,
(
Discussion
The process of linear filtering similar to
a frequency domain concept called
“convolution”







mn
i
i
i
mn
mn z
w
z
w
z
w
z
w
R
1
2
2
1
1 ...







9
1
9
9
2
2
1
1 ...
i
i
i z
w
z
w
z
w
z
w
R
Simplify expression
w1 w2 w3
w4 w5 w6
w7 w8 w9
Where the w’s are mask coefficients, the z’s are the value of
the image gray levels corresponding to those coefficients
Nonlinear spatial filtering
Nonlinear spatial filters also operate on
neighborhoods, and the mechanics of
sliding a mask past an image are the
same as was just outlined.
The filtering operation is based
conditionally on the values of the pixels
in the neighborhood under
consideration
Smoothing Spatial Filters
Smoothing filters are used for blurring
and for noise reduction.
– Blurring is used in preprocessing steps,
such as removal of small details from an
image prior to object extraction, and
bridging of small gaps in lines or curves
– Noise reduction can be accomplished by
blurring
Type of smoothing filtering
There are 2 way of smoothing spatial
filters
Smoothing Linear Filters
Order-Statistics Filters
Smoothing Linear Filters
Linear spatial filter is simply the
average of the pixels contained in the
neighborhood of the filter mask.
Sometimes called “averaging filters”.
The idea is replacing the value of every
pixel in an image by the average of the
gray levels in the neighborhood defined
by the filter mask.
Two 3x3 Smoothing Linear Filters
1 1 1
1 1 1
1 1 1
1 2 1
2 4 2
1 2 1

9
1 
16
1
Standard average Weighted average
5x5 Smoothing Linear Filters
1 1 1
1 1 1
1 1 1
1
1
1
1
1
1
1 1 1 1 1
1 1 1 1 1

?
1

25
1
Smoothing Linear Filters
The general implementation for filtering
an MxN image with a weighted
averaging filter of size mxn is given by
the expression



 


 



 a
a
s
b
b
t
a
a
s
b
b
t
t
s
w
t
y
s
x
f
t
s
w
y
x
g
)
,
(
)
,
(
)
,
(
)
,
(
Result of Smoothing Linear Filters
[3x3] [5x5] [7x7]
Original Image
Image Smoothing Example
The image at the top left
is an original image of
size 500*500 pixels
The subsequent images
show the image after
filtering with an averaging
filter of increasing sizes
3, 5, 9, 15 and 35
Notice how detail begins
to disappear
Image Smoothing Example
Image Smoothing Example
Image Smoothing Example
Image Smoothing Example
Image Smoothing Example
Image Smoothing Example
Order-Statistics Filters
Order-statistics filters are nonlinear spatial
filters whose response is based on ordering
(ranking) the pixels contained in the image
area encompassed by the filter, and then
replacing the value of the center pixel with
the value determined by the ranking result.
Best-known “median filter”
Process of Median filter
Crop region of
neighborhood
Sort the values of
the pixel in our
region
In the MxN mask
the median is MxN
div 2 +1
10 15 20
20 100 20
20 20 25
10, 15, 20, 20, 20, 20, 20, 25, 100
5th
Result of median filter
Noise from Glass effect Remove noise by median filter
No reduction in contrast across steps, since
output values available consist only of those
present in the neighborhood (no averages).
– Median filtering does not shift boundaries, as
can happen with conventional smoothing filters
(a contrast dependent problem).
– Since the median is less sensitive than the
mean to extreme values (outliers), those
extreme values are more effectively removed.
The median is, in a sense, a more robust
“average” than the mean, as it is not
affected by outliers (extreme values).
• Since the output pixel value is one of the
neighboring values, new “unrealistic”
values are not created near edges.
• Since edges are minimally degraded,
median filters can be applied repeatedly, if
necessary.
The median filter is more expensive to
compute than a smoothing filter. Clever
algorithms can save time by making use of
repeating values as the neighborhood
window is slid across the image.
– Median filters are nonlinear:
This must be taken into account if you
plan on summing filtered images.
Another Smoothing Example
By smoothing the original image we get
rid of lots of the finer detail which leaves
only the gross features for thresholding
Original Image Smoothed ImageThresholded Image
Averaging Filter Vs. Median Filter Example
Filtering is often used to remove noise
from images
Sometimes a median filter works better
than an averaging filter
Original Image
With Noise
Image After
Averaging Filter
Image After
Median Filter
Averaging Filter Vs. Median Filter
Example
Averaging Filter Vs. Median Filter
Example
Averaging Filter Vs. Median Filter
Example
Simple Neighbourhood Operations
Example
123 127 128 119 115 130
140 145 148 153 167 172
133 154 183 192 194 191
194 199 207 210 198 195
164 170 175 162 173 151
x
y
Strange Things Happen At The Edges!
Origin x
y Image f (x, y)
e
e
e
e
At the edges of an image we are missing pixels
to form a neighbourhood
e e
e
Strange Things Happen At The Edges!
(cont…)There are a few approaches to dealing
with missing edge pixels:
Omit missing pixels
• Only works with some filters
• Can add extra code and slow down processing
Pad the image
• Typically with either all white or all black pixels
Replicate border pixels
Truncate the image
Allow pixels wrap around the image
• Can cause some strange image artifacts
Simple Neighbourhood Operations
Example
123 127 128 119 115 130
140 145 148 153 167 172
133 154 183 192 194 191
194 199 207 210 198 195
164 170 175 162 173 151
x
y
Strange Things Happen At The Edges!
(cont…)
Original
Image
Filtered
Image: Zero
Padding
Filtered Image:
Replicate Edge
Pixels
Filtered Image:
Wrap Around Edge
Pixels
Images
taken
from
Gonzalez
&
Woods,
Digital
Image
Processing
(2002)
Strange Things Happen At The Edges!
(cont…)
Strange Things Happen At The Edges!
(cont…)
Strange Things Happen At The Edges!
(cont…)
Correlation & Convolution
The filtering we have been talking about so
far is referred to as correlation with the filter
itself referred to as the correlation kernel
Convolution is a similar operation, with just
one subtle difference
For symmetric filters it makes no difference
eprocessed = v*e +
z*a + y*b + x*c +
w*d + u*e +
t*f + s*g + r*h
r s t
u v w
x y z
Filter
a b c
d e e
f g h
Original
Image
*
Summary
In this lecture we have looked at the
idea of spatial filtering and in particular:
Neighbourhood operations
The filtering process
Smoothing filters
Dealing with problems at image edges
when using filtering
Correlation and convolution
Sharpening Spatial Filters
The principal objective of sharpening is
to highlight transitions in intensity or to
enhance detail that has been blurred,
either in error or as an natural effect of
a particular method of image
acquisition.
Applications: electronic printing,
medical imaging to industrial inspection
& autonomous guidance in military
systems.
Introduction
The image blurring is accomplished in
the spatial domain by pixel averaging in
a neighborhood.
Since averaging is analogous to
integration.
Sharpening could be accomplished by
spatial differentiation.
Foundation
We are interested in the behavior of
these derivatives in areas of constant
gray level(flat segments), at the onset
and end of discontinuities(step and
ramp discontinuities), and along gray-
level ramps.
These types of discontinuities can be
noise points, lines, and edges.
Definition for a first derivative
Must be zero in flat segments(constant
intensity/areas)
Must be nonzero at the onset of a gray-
level step or ramp; and
Must be nonzero along ramps of
constant slope.
Definition for a second derivative
Must be zero in flat areas;
Must be nonzero at the onset and end
of a gray-level step or ramp;
Must be zero along ramps of constant
slope
Definition of the 1st-order derivative
A basic definition of the first-order derivative
of a one-dimensional function f(x) is
)
(
)
1
( x
f
x
f
x
f





Definition of the 2nd-order derivative
We define a second-order derivative as the
difference
).
(
2
)
1
(
)
1
(
2
2
x
f
x
f
x
f
x
f







A B
0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
-1 0 0 0 0 1 0 6 -12 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
First
derivative
Second
derivative
Gray-level profile
6
6
0 1 2 3
0 0 2 2 2 2 2
3 3 3 3 3
0 0 0 0 0 0 0 0 7 7 5 5
7
6
5
4
3
2
1
0
Derivative of image profile
0 0 0 1 2 3 2 0 0 2 2 6 3 3 2 2 3 3 0 0 0 0 0 0 7 7 6 5 5 3
0 0 1 1 1-1-2 0 2 0 4-3 0-1 0 1 0-3 0 0 0 0 0-7 0-1-1 0-2
0-1 0 0-2-1 2 2-2 4-7 3-1 1 1-1-3 3 0 0 0 0-7 7-1 0 1-2
first
second
Analyze
The 1st-order derivative is nonzero
along the entire ramp, while the 2nd-
order derivative is nonzero only at the
onset and end of the ramp.
The response at and around the point is
much stronger for the 2nd- than for the
1st-order derivative
1st make thick edge and 2nd make thin edge
The Laplacian (2nd order derivative)
Discrete formulation
Constructing filter based on formulation
Shown by Rosenfeld and Kak[1982] that the
simplest isotropic derivative operator is the
Laplacian is defined as
2
2
2
2
2
y
f
x
f
f







Discrete form of derivative
)
,
(
2
)
,
1
(
)
,
1
(
2
2
y
x
f
y
x
f
y
x
f
x
f







f(x+1,y)
f(x,y)
f(x-1,y)
f(x,y+1)
f(x,y)
f(x,y-1)
)
,
(
2
)
1
,
(
)
1
,
(
2
2
y
x
f
y
x
f
y
x
f
y
f







2-Dimentional Laplacian
The digital implementation of the 2-Dimensional
Laplacian is obtained by summing 2 components
2
2
2
2
2
x
f
x
f
f







)
,
(
4
)
1
,
(
)
1
,
(
)
,
1
(
)
,
1
(
2
y
x
f
y
x
f
y
x
f
y
x
f
y
x
f
f 









1
1
-4 1
1
Laplacian
1
1
-4 1
1
0 0
0 0
0
0
-4 0
0
1 1
1 1
1
1
-8 1
1
1 1
1 1
Laplacian
-1
-1
4 -1
-1
0 0
0 0
0
0
4 0
0
-1 -1
-1 -1
-1
-1
8 -1
-1
-1 -1
-1 -1
Effect of Laplacian Operator
Laplacian-derivative operator-highlights
intensity discontinuities.
deemphasizes regions with slowly
varying intensity levels.
Produce images that have grayish edge
lines & other discontinuities all
superimposed on a dark featureless
background.
Background features recovered while
preserving sharpening by simply adding
Laplacian image to original image.
Centre coefficient –ve subtract
otherwise add
Implementation








)
,
(
)
,
(
)
,
(
)
,
(
)
,
( 2
2
y
x
f
y
x
f
y
x
f
y
x
f
y
x
g If the center coefficient is negative
If the center coefficient is positive
Where f(x,y) is the original image
is Laplacian filtered image
g(x,y) is the sharpen image
)
,
(
2
y
x
f

Implementation
Implementation
Filtered = Conv(image,mask)
Implementation
filtered = filtered - Min(filtered)
filtered = filtered * (255.0/Max(filtered))
Implementation
sharpened = image + filtered
sharpened = sharpened - Min(sharpened )
sharpened = sharpened * (255.0/Max(sharpened ))
Algorithm
Using Laplacian filter to original image
And then add the image result from
step 1 and the original image
Simplification
We will apply two step to be one mask
)
,
(
4
)
1
,
(
)
1
,
(
)
,
1
(
)
,
1
(
)
,
(
)
,
( y
x
f
y
x
f
y
x
f
y
x
f
y
x
f
y
x
f
y
x
g 









)
1
,
(
)
1
,
(
)
,
1
(
)
,
1
(
)
,
(
5
)
,
( 







 y
x
f
y
x
f
y
x
f
y
x
f
y
x
f
y
x
g
-1
-1
5 -1
-1
0 0
0 0
-1
-1
9 -1
-1
-1 -1
-1 -1
Unsharp masking
A process used by printing & publishing
industry to sharpen images consists of
subtracting a blurred version of an image from
the image itself. This process, called unsharp
masking, is expressed as
)
,
(
)
,
(
)
,
( y
x
f
y
x
f
y
x
fs 

)
,
( y
x
fs
)
,
( y
x
f
)
,
( y
x
f
Where denotes the sharpened image obtained by
unsharp masking, and is a blurred version of
High-boost filtering
A high-boost filtered image, fhb is defined at
any point (x,y) as
1
)
,
(
)
,
(
)
,
( 

 A
where
y
x
f
y
x
Af
y
x
fhb
)
,
(
)
,
(
)
,
(
)
1
(
)
,
( y
x
f
y
x
f
y
x
f
A
y
x
fhb 



)
,
(
)
,
(
)
1
(
)
,
( y
x
f
y
x
f
A
y
x
f s
hb 


This equation is applicable general and does not state
explicity how the sharp image is obtained
High-boost filtering and Laplacian
If we choose to use the Laplacian, then we
know fs(x,y)








)
,
(
)
,
(
)
,
(
)
,
(
2
2
y
x
f
y
x
Af
y
x
f
y
x
Af
fhb
If the center coefficient is negative
If the center coefficient is positive
-1
-1
A+4 -1
-1
0 0
0 0
-1
-1
A+8 -1
-1
-1 -1
-1 -1
Spatial Filtering
High-boost or high-frequency-emphasis filter
original image
FILTERED IMAGE: LAPLACIAN FILTER
The Gradient (1st order derivative)
First Derivatives in image processing are
implemented using the magnitude of the
gradient.
The gradient of function f(x,y) is

























y
f
x
f
G
G
f
y
x
Gradient
The magnitude of this vector is given by
y
x
y
x G
G
G
G
f
mag 



 2
2
)
(
-1 1
1
-1
Gx
Gy
This mask is simple, and no isotropic.
Its result only horizontal and vertical.
Robert’s Method
The simplest approximations to a first-order
derivative that satisfy the conditions stated in
that section are
2
6
8
2
5
9 )
(
)
( z
z
z
z
f 




z1 z2 z3
z4 z5 z6
z7 z8 z9
Gx = (z9-z5) and Gy = (z8-z6)
6
8
5
9 z
z
z
z
f 




Robert’s Method
These mask are referred to as the
Roberts cross-gradient operators.
-1 0
0 1
-1
0
0
1
Sobel’s Method
Mask of even size are awkward to apply.
The smallest filter mask should be 3x3.
The difference between the third and
first rows of the 3x3 mage region
approximate derivative in x-direction,
and the difference between the third and
first column approximate derivative in y-
direction.
Sobel’s Method
Using this equation
)
2
(
)
2
(
)
2
(
)
2
( 7
4
1
9
6
3
3
2
1
9
8
7 z
z
z
z
z
z
z
z
z
z
z
z
f 












-1 -2 -1
0 0 0
1 2 1 1
-2
1
0
0
0
-1
2
-1
original image FILTERED IMAGE:SOBEL FILTER
FILTERED IMAGE: PREWITT FILTER
original image
Combining Spatial Enhancement Methods

More Related Content

What's hot

Frequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement TechniquesFrequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement Techniques
Diwaker Pant
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
Ashish Kumar
 

What's hot (20)

Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency Domain
 
Frequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement TechniquesFrequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement Techniques
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point Processing
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 
SPATIAL FILTER
SPATIAL FILTERSPATIAL FILTER
SPATIAL FILTER
 
SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSING
 
08 frequency domain filtering DIP
08 frequency domain filtering DIP08 frequency domain filtering DIP
08 frequency domain filtering DIP
 
Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filters
 
Chap6 image restoration
Chap6 image restorationChap6 image restoration
Chap6 image restoration
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
Image restoration and reconstruction
Image restoration and reconstructionImage restoration and reconstruction
Image restoration and reconstruction
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
 
Sharpening spatial filters
Sharpening spatial filtersSharpening spatial filters
Sharpening spatial filters
 
Segmentation Techniques -II
Segmentation Techniques -IISegmentation Techniques -II
Segmentation Techniques -II
 
Wiener Filter
Wiener FilterWiener Filter
Wiener Filter
 
Psuedo color
Psuedo colorPsuedo color
Psuedo color
 
Color image processing
Color image processingColor image processing
Color image processing
 

Similar to Spatial filtering

Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfiltering
John Williams
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
pawankamal3
 

Similar to Spatial filtering (20)

Lecture 4
Lecture 4Lecture 4
Lecture 4
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIP
 
Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp masking
 
Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfiltering
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
 
Image_filtering (1).pptx
Image_filtering (1).pptxImage_filtering (1).pptx
Image_filtering (1).pptx
 
Spatial domain filtering.ppt
Spatial domain filtering.pptSpatial domain filtering.ppt
Spatial domain filtering.ppt
 
4 image enhancement in spatial domain
4 image enhancement in spatial domain4 image enhancement in spatial domain
4 image enhancement in spatial domain
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehrDIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
 
CSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureCSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lecture
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
Image Noise Removal by Dual Threshold Median Filter for RVIN
Image Noise Removal by Dual Threshold Median Filter for RVINImage Noise Removal by Dual Threshold Median Filter for RVIN
Image Noise Removal by Dual Threshold Median Filter for RVIN
 
M017218088
M017218088M017218088
M017218088
 
vs.pptx
vs.pptxvs.pptx
vs.pptx
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
Module 31
Module 31Module 31
Module 31
 
Digital image processing - Image Enhancement (MATERIAL)
Digital image processing  - Image Enhancement (MATERIAL)Digital image processing  - Image Enhancement (MATERIAL)
Digital image processing - Image Enhancement (MATERIAL)
 

More from shabanam tamboli (7)

Image processing7 frequencyfiltering
Image processing7 frequencyfilteringImage processing7 frequencyfiltering
Image processing7 frequencyfiltering
 
Image enhancement in the spatial domain1
Image enhancement in the spatial domain1Image enhancement in the spatial domain1
Image enhancement in the spatial domain1
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Chapter01 (2)
Chapter01 (2)Chapter01 (2)
Chapter01 (2)
 
Chap01 visual perception
Chap01 visual perceptionChap01 visual perception
Chap01 visual perception
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introduction
 
Chapter01 lecture 1
Chapter01 lecture 1Chapter01 lecture 1
Chapter01 lecture 1
 

Recently uploaded

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 

Recently uploaded (20)

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 

Spatial filtering

  • 2. Background Filter term in “Digital image processing” is referred to the subimage There are others term to call subimage such as mask, kernel, template, or window The value in a filter subimage are referred as coefficients, rather than pixels.
  • 3. Basics of Spatial Filtering The concept of filtering has its roots in the use of the Fourier transform for signal processing in the so-called frequency domain. Spatial filtering term is the filtering operations that are performed directly on the pixels of an image
  • 4. Mechanics of spatial filtering The process consists simply of moving 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
  • 5. Neighbourhood Operations Neighbourhood operations simply operate on a larger neighbourhood of pixels than point operations Neighbourhoods are mostly a rectangle around a central pixel Any size rectangle and any shape filter are possible Origin x y Image f (x, y) (x, y) Neighbourhood
  • 6. Simple Neighbourhood Operations Some simple neighbourhood operations include: Min: Set the pixel value to the minimum in the neighbourhood Max: Set the pixel value to the maximum in the neighbourhood Median: The median value of a set of numbers is the midpoint value in that set (e.g. from the set [1, 7, 15, 18, 24] 15 is the median). Sometimes the median works better than the average
  • 7. The Spatial Filtering Process r s t u v w x y z Origin x y Image f (x, y) eprocessed = v*e + r*a + s*b + t*c + u*d + w*f + x*g + y*h + z*i Filter Simple 3*3 Neighbourhood e 3*3 Filter a b c d e f g h i Original Image Pixels * The above is repeated for every pixel in the original image to generate the filtered image
  • 8. Spatial Filtering: Equation Form         a a s b b t t y s x f t s w y x g ) , ( ) , ( ) , ( Filtering can be given in equation form as shown above Notations are based on the image shown to the left
  • 9. Spatial Filtering: Equation Form         a a s b b t t y s x f t s w y x g ) , ( ) , ( ) , ( Filtering can be given in equation form as shown above Notations are based on the image shown to the left
  • 10. Linear spatial filtering f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y-1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,-1) w(1,0) w(1,1) The result is the sum of products of the mask coefficients with the corresponding pixels directly under the mask Pixels of image Mask coefficients w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,-1) w(1,0) w(1,1) ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 ( ) 1 , ( ) 1 , 0 ( ) , ( ) 0 , 0 ( ) 1 , ( ) 1 , 0 ( ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 (                           y x f w y x f w y x f w y x f w y x f w y x f w y x f w y x f w y x f w  ) , ( y x f
  • 11. Linear filtering The coefficient w(0,0) coincides with image value f(x,y), indicating that the mask is centered at (x,y) when the computation of sum of products takes place. For a mask of size mxn, we assume that m=2a+1 and n=2b+1, where a and b are nonnegative integer. Then m and n are odd.
  • 12. Linear filtering In general, linear filtering of an image f of size MxN with a filter mask of size mxn is given by the expression:         a a s b b t t y s x f t s w y x g ) , ( ) , ( ) , (
  • 13. Discussion The process of linear filtering similar to a frequency domain concept called “convolution”        mn i i i mn mn z w z w z w z w R 1 2 2 1 1 ...        9 1 9 9 2 2 1 1 ... i i i z w z w z w z w R Simplify expression w1 w2 w3 w4 w5 w6 w7 w8 w9 Where the w’s are mask coefficients, the z’s are the value of the image gray levels corresponding to those coefficients
  • 14. Nonlinear spatial filtering Nonlinear spatial filters also operate on neighborhoods, and the mechanics of sliding a mask past an image are the same as was just outlined. The filtering operation is based conditionally on the values of the pixels in the neighborhood under consideration
  • 15. Smoothing Spatial Filters Smoothing filters are used for blurring and for noise reduction. – Blurring is used in preprocessing steps, such as removal of small details from an image prior to object extraction, and bridging of small gaps in lines or curves – Noise reduction can be accomplished by blurring
  • 16. Type of smoothing filtering There are 2 way of smoothing spatial filters Smoothing Linear Filters Order-Statistics Filters
  • 17. Smoothing Linear Filters Linear spatial filter is simply the average of the pixels contained in the neighborhood of the filter mask. Sometimes called “averaging filters”. The idea is replacing the value of every pixel in an image by the average of the gray levels in the neighborhood defined by the filter mask.
  • 18. Two 3x3 Smoothing Linear Filters 1 1 1 1 1 1 1 1 1 1 2 1 2 4 2 1 2 1  9 1  16 1 Standard average Weighted average
  • 19. 5x5 Smoothing Linear Filters 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  ? 1  25 1
  • 20. Smoothing Linear Filters The general implementation for filtering an MxN image with a weighted averaging filter of size mxn is given by the expression              a a s b b t a a s b b t t s w t y s x f t s w y x g ) , ( ) , ( ) , ( ) , (
  • 21. Result of Smoothing Linear Filters [3x3] [5x5] [7x7] Original Image
  • 22. Image Smoothing Example The image at the top left is an original image of size 500*500 pixels The subsequent images show the image after filtering with an averaging filter of increasing sizes 3, 5, 9, 15 and 35 Notice how detail begins to disappear
  • 29. Order-Statistics Filters Order-statistics filters are nonlinear spatial filters whose response is based on ordering (ranking) the pixels contained in the image area encompassed by the filter, and then replacing the value of the center pixel with the value determined by the ranking result. Best-known “median filter”
  • 30. Process of Median filter Crop region of neighborhood Sort the values of the pixel in our region In the MxN mask the median is MxN div 2 +1 10 15 20 20 100 20 20 20 25 10, 15, 20, 20, 20, 20, 20, 25, 100 5th
  • 31. Result of median filter Noise from Glass effect Remove noise by median filter
  • 32. No reduction in contrast across steps, since output values available consist only of those present in the neighborhood (no averages). – Median filtering does not shift boundaries, as can happen with conventional smoothing filters (a contrast dependent problem). – Since the median is less sensitive than the mean to extreme values (outliers), those extreme values are more effectively removed.
  • 33. The median is, in a sense, a more robust “average” than the mean, as it is not affected by outliers (extreme values). • Since the output pixel value is one of the neighboring values, new “unrealistic” values are not created near edges. • Since edges are minimally degraded, median filters can be applied repeatedly, if necessary.
  • 34. The median filter is more expensive to compute than a smoothing filter. Clever algorithms can save time by making use of repeating values as the neighborhood window is slid across the image. – Median filters are nonlinear: This must be taken into account if you plan on summing filtered images.
  • 35. Another Smoothing Example By smoothing the original image we get rid of lots of the finer detail which leaves only the gross features for thresholding Original Image Smoothed ImageThresholded Image
  • 36. Averaging Filter Vs. Median Filter Example Filtering is often used to remove noise from images Sometimes a median filter works better than an averaging filter Original Image With Noise Image After Averaging Filter Image After Median Filter
  • 37. Averaging Filter Vs. Median Filter Example
  • 38. Averaging Filter Vs. Median Filter Example
  • 39. Averaging Filter Vs. Median Filter Example
  • 40. Simple Neighbourhood Operations Example 123 127 128 119 115 130 140 145 148 153 167 172 133 154 183 192 194 191 194 199 207 210 198 195 164 170 175 162 173 151 x y
  • 41. Strange Things Happen At The Edges! Origin x y Image f (x, y) e e e e At the edges of an image we are missing pixels to form a neighbourhood e e e
  • 42. Strange Things Happen At The Edges! (cont…)There are a few approaches to dealing with missing edge pixels: Omit missing pixels • Only works with some filters • Can add extra code and slow down processing Pad the image • Typically with either all white or all black pixels Replicate border pixels Truncate the image Allow pixels wrap around the image • Can cause some strange image artifacts
  • 43. Simple Neighbourhood Operations Example 123 127 128 119 115 130 140 145 148 153 167 172 133 154 183 192 194 191 194 199 207 210 198 195 164 170 175 162 173 151 x y
  • 44. Strange Things Happen At The Edges! (cont…) Original Image Filtered Image: Zero Padding Filtered Image: Replicate Edge Pixels Filtered Image: Wrap Around Edge Pixels Images taken from Gonzalez & Woods, Digital Image Processing (2002)
  • 45. Strange Things Happen At The Edges! (cont…)
  • 46. Strange Things Happen At The Edges! (cont…)
  • 47. Strange Things Happen At The Edges! (cont…)
  • 48. Correlation & Convolution The filtering we have been talking about so far is referred to as correlation with the filter itself referred to as the correlation kernel Convolution is a similar operation, with just one subtle difference For symmetric filters it makes no difference eprocessed = v*e + z*a + y*b + x*c + w*d + u*e + t*f + s*g + r*h r s t u v w x y z Filter a b c d e e f g h Original Image *
  • 49. Summary In this lecture we have looked at the idea of spatial filtering and in particular: Neighbourhood operations The filtering process Smoothing filters Dealing with problems at image edges when using filtering Correlation and convolution
  • 50. Sharpening Spatial Filters The principal objective of sharpening is to highlight transitions in intensity or to enhance detail that has been blurred, either in error or as an natural effect of a particular method of image acquisition. Applications: electronic printing, medical imaging to industrial inspection & autonomous guidance in military systems.
  • 51. Introduction The image blurring is accomplished in the spatial domain by pixel averaging in a neighborhood. Since averaging is analogous to integration. Sharpening could be accomplished by spatial differentiation.
  • 52. Foundation We are interested in the behavior of these derivatives in areas of constant gray level(flat segments), at the onset and end of discontinuities(step and ramp discontinuities), and along gray- level ramps. These types of discontinuities can be noise points, lines, and edges.
  • 53. Definition for a first derivative Must be zero in flat segments(constant intensity/areas) Must be nonzero at the onset of a gray- level step or ramp; and Must be nonzero along ramps of constant slope.
  • 54. Definition for a second derivative Must be zero in flat areas; Must be nonzero at the onset and end of a gray-level step or ramp; Must be zero along ramps of constant slope
  • 55. Definition of the 1st-order derivative A basic definition of the first-order derivative of a one-dimensional function f(x) is ) ( ) 1 ( x f x f x f     
  • 56. Definition of the 2nd-order derivative We define a second-order derivative as the difference ). ( 2 ) 1 ( ) 1 ( 2 2 x f x f x f x f       
  • 57. A B 0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0 -1 0 0 0 0 1 0 6 -12 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0 First derivative Second derivative
  • 58. Gray-level profile 6 6 0 1 2 3 0 0 2 2 2 2 2 3 3 3 3 3 0 0 0 0 0 0 0 0 7 7 5 5 7 6 5 4 3 2 1 0
  • 59. Derivative of image profile 0 0 0 1 2 3 2 0 0 2 2 6 3 3 2 2 3 3 0 0 0 0 0 0 7 7 6 5 5 3 0 0 1 1 1-1-2 0 2 0 4-3 0-1 0 1 0-3 0 0 0 0 0-7 0-1-1 0-2 0-1 0 0-2-1 2 2-2 4-7 3-1 1 1-1-3 3 0 0 0 0-7 7-1 0 1-2 first second
  • 60. Analyze The 1st-order derivative is nonzero along the entire ramp, while the 2nd- order derivative is nonzero only at the onset and end of the ramp. The response at and around the point is much stronger for the 2nd- than for the 1st-order derivative 1st make thick edge and 2nd make thin edge
  • 61. The Laplacian (2nd order derivative) Discrete formulation Constructing filter based on formulation Shown by Rosenfeld and Kak[1982] that the simplest isotropic derivative operator is the Laplacian is defined as 2 2 2 2 2 y f x f f       
  • 62. Discrete form of derivative ) , ( 2 ) , 1 ( ) , 1 ( 2 2 y x f y x f y x f x f        f(x+1,y) f(x,y) f(x-1,y) f(x,y+1) f(x,y) f(x,y-1) ) , ( 2 ) 1 , ( ) 1 , ( 2 2 y x f y x f y x f y f       
  • 63. 2-Dimentional Laplacian The digital implementation of the 2-Dimensional Laplacian is obtained by summing 2 components 2 2 2 2 2 x f x f f        ) , ( 4 ) 1 , ( ) 1 , ( ) , 1 ( ) , 1 ( 2 y x f y x f y x f y x f y x f f           1 1 -4 1 1
  • 64. Laplacian 1 1 -4 1 1 0 0 0 0 0 0 -4 0 0 1 1 1 1 1 1 -8 1 1 1 1 1 1
  • 65. Laplacian -1 -1 4 -1 -1 0 0 0 0 0 0 4 0 0 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1
  • 66. Effect of Laplacian Operator Laplacian-derivative operator-highlights intensity discontinuities. deemphasizes regions with slowly varying intensity levels. Produce images that have grayish edge lines & other discontinuities all superimposed on a dark featureless background.
  • 67. Background features recovered while preserving sharpening by simply adding Laplacian image to original image. Centre coefficient –ve subtract otherwise add
  • 68. Implementation         ) , ( ) , ( ) , ( ) , ( ) , ( 2 2 y x f y x f y x f y x f y x g If the center coefficient is negative If the center coefficient is positive Where f(x,y) is the original image is Laplacian filtered image g(x,y) is the sharpen image ) , ( 2 y x f 
  • 71. Implementation filtered = filtered - Min(filtered) filtered = filtered * (255.0/Max(filtered))
  • 72. Implementation sharpened = image + filtered sharpened = sharpened - Min(sharpened ) sharpened = sharpened * (255.0/Max(sharpened ))
  • 73. Algorithm Using Laplacian filter to original image And then add the image result from step 1 and the original image
  • 74. Simplification We will apply two step to be one mask ) , ( 4 ) 1 , ( ) 1 , ( ) , 1 ( ) , 1 ( ) , ( ) , ( y x f y x f y x f y x f y x f y x f y x g           ) 1 , ( ) 1 , ( ) , 1 ( ) , 1 ( ) , ( 5 ) , (          y x f y x f y x f y x f y x f y x g -1 -1 5 -1 -1 0 0 0 0 -1 -1 9 -1 -1 -1 -1 -1 -1
  • 75. Unsharp masking A process used by printing & publishing industry to sharpen images consists of subtracting a blurred version of an image from the image itself. This process, called unsharp masking, is expressed as ) , ( ) , ( ) , ( y x f y x f y x fs   ) , ( y x fs ) , ( y x f ) , ( y x f Where denotes the sharpened image obtained by unsharp masking, and is a blurred version of
  • 76. High-boost filtering A high-boost filtered image, fhb is defined at any point (x,y) as 1 ) , ( ) , ( ) , (    A where y x f y x Af y x fhb ) , ( ) , ( ) , ( ) 1 ( ) , ( y x f y x f y x f A y x fhb     ) , ( ) , ( ) 1 ( ) , ( y x f y x f A y x f s hb    This equation is applicable general and does not state explicity how the sharp image is obtained
  • 77. High-boost filtering and Laplacian If we choose to use the Laplacian, then we know fs(x,y)         ) , ( ) , ( ) , ( ) , ( 2 2 y x f y x Af y x f y x Af fhb If the center coefficient is negative If the center coefficient is positive -1 -1 A+4 -1 -1 0 0 0 0 -1 -1 A+8 -1 -1 -1 -1 -1 -1
  • 78. Spatial Filtering High-boost or high-frequency-emphasis filter
  • 79. original image FILTERED IMAGE: LAPLACIAN FILTER
  • 80. The Gradient (1st order derivative) First Derivatives in image processing are implemented using the magnitude of the gradient. The gradient of function f(x,y) is                          y f x f G G f y x
  • 81. Gradient The magnitude of this vector is given by y x y x G G G G f mag      2 2 ) ( -1 1 1 -1 Gx Gy This mask is simple, and no isotropic. Its result only horizontal and vertical.
  • 82. Robert’s Method The simplest approximations to a first-order derivative that satisfy the conditions stated in that section are 2 6 8 2 5 9 ) ( ) ( z z z z f      z1 z2 z3 z4 z5 z6 z7 z8 z9 Gx = (z9-z5) and Gy = (z8-z6) 6 8 5 9 z z z z f     
  • 83. Robert’s Method These mask are referred to as the Roberts cross-gradient operators. -1 0 0 1 -1 0 0 1
  • 84. Sobel’s Method Mask of even size are awkward to apply. The smallest filter mask should be 3x3. The difference between the third and first rows of the 3x3 mage region approximate derivative in x-direction, and the difference between the third and first column approximate derivative in y- direction.
  • 85. Sobel’s Method Using this equation ) 2 ( ) 2 ( ) 2 ( ) 2 ( 7 4 1 9 6 3 3 2 1 9 8 7 z z z z z z z z z z z z f              -1 -2 -1 0 0 0 1 2 1 1 -2 1 0 0 0 -1 2 -1
  • 86.
  • 87. original image FILTERED IMAGE:SOBEL FILTER
  • 88. FILTERED IMAGE: PREWITT FILTER original image