SlideShare a Scribd company logo
1 of 42
SPATIAL FILTERING
ANUJ ARORA
B-TECH 2nd YEAR
ELCTRICAL ENGG.
SPATIAL FILTERING
(CONT’D)• Spatial filtering is defined by:
(1) An operation that is performed on the pixels inside the
Neighborhood
(2)First we need to create a N*N matrix called a
mask,kernel,filter(neighborhood).
(3)The number inside the mask will help us control the
kind of operation we are doing.
(4)Different number allow us to blur,sharpen,find edges.
output image
SPATIAL FILTERING
NEIGHBORHOOD
• Typically, the neighborhood is rectangular and its size
is much smaller than that of f(x,y)
- e.g., 3x3 or 5x5
SPATIAL FILTERING -
OPERATION
1 1
1 1
( , ) ( , ) ( , )
s t
g x y w s t f x s y t
Assume the origin of the
mask is the center of the
mask.
/ 2 / 2
/ 2 / 2
( , ) ( , ) ( , )
K K
s K t K
g x y w s t f x s y t
for a K x K mask:
for a 3 x 3 mask:
• A filtered image is generated as the center of the
mask moves to every pixel in the input image.
output image
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
HANDLING PIXELS CLOSE
TO BOUNDARIES
pad with zeroes
or
0 0 0 ……………………….0
000……………………….0
LINEAR VS NON-LINEAR
SPATIAL FILTERING METHODS
• A filtering method is linear when the output is a
weighted sum of the input pixels.
• In this slide we only discuss about liner filtering.
• Methods that do not satisfy the above property are
called non-linear.
• e.g.
LINEAR SPATIAL FILTERING
METHODS
• Two main linear spatial filtering methods:
• Correlation
• Convolution
CORRELATION
• TO perform correlation ,we move w(x,y) in all possible
locations so that at least one of its pixels overlaps a
pixel in the in the original image f(x,y).
/ 2 / 2
/ 2 / 2
( , ) ( , ) ( , ) ( , ) ( , )
K K
s K t K
g x y w x y f x y w s t f x s y t
CONVOLUTION
• Similar to correlation except that the mask is first flipped
both horizontally and vertically.
Note: if w(x,y) is symmetric, that is w(x,y)=w(-x,-y), then
convolution is equivalent to correlation!
/ 2 / 2
/ 2 / 2
( , ) ( , ) ( , ) ( , ) ( , )
K K
s K t K
g x y w x y f x y w s t f x s y t
CORRELATION AND
CONVOLUTION
Correlation:
Convolution:
HOW DO WE CHOOSE THE
ELEMENTS OF A MASK?
• Typically, by sampling certain functions.
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
FILTERS
• Smoothing (i.e., low-pass filters)
• Reduce noise and eliminate small details.
• The elements of the mask must be positive.
• Sum of mask elements is 1 (after normalization)
Gaussian
FILTERS
• Sharpening (i.e., high-pass filters)
• Highlight fine detail or enhance detail that has been
blurred.
• The elements of the mask contain both positive and
negative weights.
• Sum of the mask weights is 0 (after normalization)
1st derivative
of Gaussian
2nd derivative
of Gaussian
SMOOTHING FILTERS: AVERAGING
(LOW-PASS FILTERING)
SMOOTHING FILTERS:
AVERAGING
• Mask size determines the degree of smoothing and
loss of detail.
3x3 5x5 7x7
15x15 25x25
original
SMOOTHING FILTERS:
AVERAGING (CONT’D)
15 x 15 averaging image thresholding
Example: extract, largest, brightest objects
SMOOTHING FILTERS:
GAUSSIAN
• The weights are samples of the Gaussian function
mask size is
a function of σ :
σ = 1.4
SMOOTHING FILTERS:
GAUSSIAN (CONT’D)
• σ controls the amount of smoothing
• As σ increases, more samples must be obtained to represent
the Gaussian function accurately.
σ = 3
SMOOTHING FILTERS:
GAUSSIAN (CONT’D)
AVERAGING VS GAUSSIAN
SMOOTHING
Averaging
Gaussian
SHARPENING FILTERS
(HIGH PASS FILTERING)
• Useful for emphasizing transitions in image intensity
(e.g., edges).
SHARPENING FILTERS
(CONT’D)
• Note that the response of high-pass filtering might be
negative.
• Values must be re-mapped to [0, 255]
sharpened imagesoriginal image
SHARPENING FILTERS:
UNSHARP MASKING
• Obtain a sharp image by subtracting a lowpass filtered
(i.e., smoothed) image from the original image:
- =
SHARPENING FILTERS:
HIGH BOOST
• Image sharpening emphasizes edges .
• High boost filter: amplify input image, then subtract a
lowpass image.
• A is the number of image we taken for boosting.
(A-1) + =
SHARPENING FILTERS: UNSHARP
MASKING (CONT’D)
• If A=1, we get a high pass filter
• If A>1, part of the original image is added back to the
high pass filtered image.
SHARPENING FILTERS:
DERIVATIVES
• Taking the derivative of an image results in sharpening
the image.
• The derivative of an image can be computed using the
gradient.
SHARPENING FILTERS:
DERIVATIVES (CONT’D)
• The gradient is a vector which has magnitude and
direction:
| | | |
f f
x y
or
(approximation)
SHARPENING FILTERS:
DERIVATIVES (CONT’D)
• Magnitude: provides information about edge strength.
• Direction: perpendicular to the direction of the edge.
SHARPENING FILTERS: GRADIENT
COMPUTATION
• Approximate gradient using finite differences:
sensitive to horizontal edges
sensitive to vertical edges
Δx
SHARPENING FILTERS: GRADIENT
COMPUTATION (CONT’D)
• We can implement and using masks:
• Example: approximate gradient at z5
SHARPENING FILTERS: GRADIENT
COMPUTATION (CONT’D)
• A different approximation of the gradient:
•We can implement and using the following masks:
SHARPENING FILTERS: GRADIENT
COMPUTATION (CONT’D)
• Example: approximate gradient at z5
EXAMPLE
f
y
f
x
SHARPENING FILTERS:
LAPLACIAN
The Laplacian (2nd derivative) is defined as:
(dot product)
Approximate
derivatives:
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing

More Related Content

What's hot

Image segmentation
Image segmentationImage segmentation
Image segmentation
Deepak Kumar
 

What's hot (20)

Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filters
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIP
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
 
Color image processing Presentation
Color image processing PresentationColor image processing Presentation
Color image processing Presentation
 
Spatial Filters (Digital Image Processing)
Spatial Filters (Digital Image Processing)Spatial Filters (Digital Image Processing)
Spatial Filters (Digital Image Processing)
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
Image Restoration
Image RestorationImage Restoration
Image Restoration
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency Domain
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Spatial domain and filtering
Spatial domain and filteringSpatial domain and filtering
Spatial domain and filtering
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSING
 
Image Acquisition and Representation
Image Acquisition and RepresentationImage Acquisition and Representation
Image Acquisition and Representation
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Digital Image Fundamentals
Digital Image FundamentalsDigital Image Fundamentals
Digital Image Fundamentals
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processing
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 

Viewers also liked (9)

Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 
5 spatial filtering p1
5 spatial filtering p15 spatial filtering p1
5 spatial filtering p1
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial Domain
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
 

Similar to Spatial filtering using image processing

05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
pawankamal3
 

Similar to Spatial filtering using image processing (20)

Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
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
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
 
Edge detection
Edge detectionEdge detection
Edge detection
 
3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial
 
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehrDIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
 
Module 31
Module 31Module 31
Module 31
 
Image Degradation & Resoration
Image Degradation & ResorationImage Degradation & Resoration
Image Degradation & Resoration
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Filtering an image is to apply a convolution
Filtering an image is to apply a convolutionFiltering an image is to apply a convolution
Filtering an image is to apply a convolution
 
4 image enhancement in spatial domain
4 image enhancement in spatial domain4 image enhancement in spatial domain
4 image enhancement in spatial domain
 
Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp masking
 

More from Anuj Arora (10)

Intellij
IntellijIntellij
Intellij
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
design of sampling filter
design of sampling filter design of sampling filter
design of sampling filter
 
complete data structure
complete data structurecomplete data structure
complete data structure
 
Analysis of harmonic at different level on distribution system ,its effect a...
Analysis of harmonic at different level on distribution system ,its effect  a...Analysis of harmonic at different level on distribution system ,its effect  a...
Analysis of harmonic at different level on distribution system ,its effect a...
 
Fpga based heart rate monitoring system using gsm
Fpga based heart rate monitoring system using gsmFpga based heart rate monitoring system using gsm
Fpga based heart rate monitoring system using gsm
 
wirless power transmission
wirless power transmissionwirless power transmission
wirless power transmission
 
Case study on road accidents
Case study on road accidents   Case study on road accidents
Case study on road accidents
 
Second order differential equations and its current use
Second order differential equations  and its current useSecond order differential equations  and its current use
Second order differential equations and its current use
 
indian forign trade since 2001
indian forign trade since 2001indian forign trade since 2001
indian forign trade since 2001
 

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
 
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
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
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
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Recently uploaded (20)

Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
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
 
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
 
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-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
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
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
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
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
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...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 

Spatial filtering using image processing