SlideShare a Scribd company logo
1 of 24
SPATIAL DOMAIN
FILTERING
1
2
What are images?
•2D image f(x,y).
•x and y are spatial co-ordinates.
•Amplitude of f at any (x,y) is called intensity or
gray level of the image.
3
•Continuous image to discrete image
4
•Result is a matrix of real numbers of size M*N.
•Each element in this array is called a pixel.
5
OBJECTIVE
The principal objective of enhancement is to process
an images so that the result is more suitable than the
original image for a SPECIFIC application.
Category of image enhancement
• Spatial domain
• Frequency domain
6
WHAT IS???
Spatial filtering (neighborhood processing) is defined by:
A neighborhood
An operation that is performed on the pixels inside
the neighborhood
7
•Typically, the neighborhood is rectangular and its
size is much smaller than that of f(x , y)
e.g., 3x3 or 5x5
Neighborhood
8
Neighborhood
•Coefficients of neighborhood is also called as filter,
mask, filter mask, kernel, template or window.
•Image size is M*N and filter mask size m*n.
•m=2a+1 and n=2b+1.
•a and b are non-negative integers.
9
Assume the
origin of the
mask is the
center of the
mask.
for a 3 x 3 mask,
1 1
1 1
( , ) ( , ) ( , )
s t
g x y w s t f x s y t
 
   
10
LINEAR V/S NON-LINEAR
A filtering method is linear when the output is
a weighted sum of the input pixels.
Methods that do not satisfy the above property
are called non-linear.
11
Linear Spatial Filtering Methods
Two main linear spatial filtering methods:
Correlation
Convolution
12
Correlation:
•Process of passing the mask w by the image array f.
Convolution
•Often used in applications where we need to
measure the similarity between images or parts of
images
(e.g., pattern matching).
•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!
13
TOOL BOX IMPLEMENTATION
g = imfilter(f, w, filtering_mode, boundary_options,
size_options)
Common syntax
g = imfilter(f, w, ‘replicate’)
14
How do we choose the elements of a
mask?
Typically, by sampling certain functions.
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
15
Spatial filters : Smoothing ( low pass)
Use: for blurring and noise reduction.
How it works? The value of every pixel is replaced by the
average of the gray levels in the neighborhood.
Type of smoothing filters:
1. Standard average
2. Weighted average.
3. Median filter
Gaussian
16
1 1 1
1 1 1
1 1 1

9
1
1 2 1
2 4 2
1 2 1

16
1
Standard average Weighted average
13090120110
200989491
100999190
90859682
Standard averaging filter:
(110 +120+90+91+94+98+90+91+99)/9 =883/9 = 98.1
Weighted averaging filter:
(110 +2 x 120+90+2 x 91+4 x 94+2 x 98+90+2 x 91+99)/16 =97.81
17
Mask size determines the degree of smoothing and
loss of detail.
original 3x3 5x5 7x7
15x15 25x25
18
13090120110
200989491
100999590
90859682
95
Steps:
1. Sort the pixels in ascending order:
90,90, 91, 94, 95, 98, 99, 110, 120
2. replace the original pixel value by the median : 95
Median filter(non linear)
19
Very effective for removing “salt and pepper” noise
(i.e., random occurrences of black and white pixels).
Averaging Median filtering
20
Spatial filters : Sharpening ( high pass)
Use: for highlighting fine detail or enhancing
detail that has been blurred.
1st derivative
of Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
Type of sharpening filters:
21
155153156157153
159156158156159
160156154158155
160160158157154
155156157157157
•154*4 – 158- 156-158-158 = -14
•So the value after filter = -14
•We call the resultant image: sharpened image.
•Filtered image=original +sharpened image
•The value in the filter image=154-14 =130
SHARPENING – 1ST DERIVATIVE
•Apply the following laplace on the highlighted pixel
22
155153156157153
159156158156159
160156154158155
160160158157154
155156157157157
•Apply the following laplace 2nd derivative on the highlighted pixel
•154*4 – 158- 156-158-158 = -14
•Apply laplace to all pixels
•Then apply it again to our pixel:-14*4 – 10 -10 – (-6) -4 =-74
•So the value after 2nd derivative filter =-74
•The value of pixel in the filter image=154-74 = 80
SHARPENING – 2nd DERIVATIVE
23
Original Image
Laplace Sharpened Image
Laplace Filtered Image
24
Thank you

More Related Content

What's hot

Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainMostafa G. M. Mostafa
 
Image Restoration
Image RestorationImage Restoration
Image RestorationPoonam Seth
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 
Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency DomainAmnaakhaan
 
Image restoration and degradation model
Image restoration and degradation modelImage restoration and degradation model
Image restoration and degradation modelAnupriyaDurai
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersSuhaila Afzana
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersKuppusamy P
 
Color Image Processing
Color Image ProcessingColor Image Processing
Color Image Processingkiruthiammu
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit NotesAAKANKSHA JAIN
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processingkumari36
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersKarthika Ramachandran
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainMadhu Bala
 
Image Restoration And Reconstruction
Image Restoration And ReconstructionImage Restoration And Reconstruction
Image Restoration And ReconstructionAmnaakhaan
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & DescriptorsPundrikPatel
 

What's hot (20)

Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency Domain
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image Restoration
Image RestorationImage Restoration
Image Restoration
 
Data Redundacy
Data RedundacyData Redundacy
Data Redundacy
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency Domain
 
Image restoration and degradation model
Image restoration and degradation modelImage restoration and degradation model
Image restoration and degradation model
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain Filters
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Color Image Processing
Color Image ProcessingColor Image Processing
Color Image Processing
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial Domain
 
Image transforms
Image transformsImage transforms
Image transforms
 
Image Restoration And Reconstruction
Image Restoration And ReconstructionImage Restoration And Reconstruction
Image Restoration And Reconstruction
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 

Viewers also liked

Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniquessakshij91
 
5 spatial filtering p1
5 spatial filtering p15 spatial filtering p1
5 spatial filtering p1Gichelle Amon
 
Image enhancement
Image enhancementImage enhancement
Image enhancementAyaelshiwi
 
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...Hemantha Kulathilake
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniquesSaideep
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial DomainDEEPASHRI HK
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIPbabak danyal
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domainAshish Kumar
 

Viewers also liked (8)

Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
5 spatial filtering p1
5 spatial filtering p15 spatial filtering p1
5 spatial filtering p1
 
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
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIP
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
 

Similar to SPATIAL FILTER

Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp maskingRavi Teja
 
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehrDIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehrstudyd133
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingrkumarankit06875
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filteringDeepikaT13
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.pptpawankamal3
 
Spatial Filters (Digital Image Processing)
Spatial Filters (Digital Image Processing)Spatial Filters (Digital Image Processing)
Spatial Filters (Digital Image Processing)Kalyan Acharjya
 
Lecture 5-2023.pdf
Lecture 5-2023.pdfLecture 5-2023.pdf
Lecture 5-2023.pdfssuserff72e4
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatialElsayed Hemayed
 
Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfilteringJohn Williams
 
CSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureCSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureFatmaNewagy1
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfvikasmittal92
 

Similar to SPATIAL FILTER (20)

Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp masking
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Module 31
Module 31Module 31
Module 31
 
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehrDIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
DIP_Lecture6.pdf. jdowjwdieehekehdjejrejwhehr
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
 
Spatial Filters (Digital Image Processing)
Spatial Filters (Digital Image Processing)Spatial Filters (Digital Image Processing)
Spatial Filters (Digital Image Processing)
 
Lecture 5-2023.pdf
Lecture 5-2023.pdfLecture 5-2023.pdf
Lecture 5-2023.pdf
 
4 image enhancement in spatial domain
4 image enhancement in spatial domain4 image enhancement in spatial domain
4 image enhancement in spatial domain
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 4.pptx
Lecture 4.pptxLecture 4.pptx
Lecture 4.pptx
 
Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfiltering
 
CSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureCSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lecture
 
PPT s04-machine vision-s2
PPT s04-machine vision-s2PPT s04-machine vision-s2
PPT s04-machine vision-s2
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdf
 

More from shalet kochumuttath Shaji (20)

Integrated circuits
Integrated circuitsIntegrated circuits
Integrated circuits
 
Measuring devices
Measuring devicesMeasuring devices
Measuring devices
 
Optical fibre
Optical fibreOptical fibre
Optical fibre
 
Robot applications
Robot applicationsRobot applications
Robot applications
 
Sensors
SensorsSensors
Sensors
 
Introduction to robotics
Introduction to roboticsIntroduction to robotics
Introduction to robotics
 
Op amps
Op ampsOp amps
Op amps
 
Nuclear i nstrumentation
Nuclear i nstrumentationNuclear i nstrumentation
Nuclear i nstrumentation
 
Gas chromatography
Gas chromatographyGas chromatography
Gas chromatography
 
Electronics basic concept
Electronics basic conceptElectronics basic concept
Electronics basic concept
 
Electronic passive components
Electronic passive componentsElectronic passive components
Electronic passive components
 
Diode applications
Diode applicationsDiode applications
Diode applications
 
Creativity
CreativityCreativity
Creativity
 
Communications
CommunicationsCommunications
Communications
 
Cellular communication
Cellular communicationCellular communication
Cellular communication
 
Evolution of electronics
Evolution of electronicsEvolution of electronics
Evolution of electronics
 
venturi meter
venturi meterventuri meter
venturi meter
 
Basics of digital electronics
Basics of digital electronicsBasics of digital electronics
Basics of digital electronics
 
fundamentals of machine vision system
fundamentals of machine vision systemfundamentals of machine vision system
fundamentals of machine vision system
 
vision system
vision systemvision system
vision system
 

SPATIAL FILTER

  • 2. 2 What are images? •2D image f(x,y). •x and y are spatial co-ordinates. •Amplitude of f at any (x,y) is called intensity or gray level of the image.
  • 3. 3 •Continuous image to discrete image
  • 4. 4 •Result is a matrix of real numbers of size M*N. •Each element in this array is called a pixel.
  • 5. 5 OBJECTIVE The principal objective of enhancement is to process an images so that the result is more suitable than the original image for a SPECIFIC application. Category of image enhancement • Spatial domain • Frequency domain
  • 6. 6 WHAT IS??? Spatial filtering (neighborhood processing) is defined by: A neighborhood An operation that is performed on the pixels inside the neighborhood
  • 7. 7 •Typically, the neighborhood is rectangular and its size is much smaller than that of f(x , y) e.g., 3x3 or 5x5 Neighborhood
  • 8. 8 Neighborhood •Coefficients of neighborhood is also called as filter, mask, filter mask, kernel, template or window. •Image size is M*N and filter mask size m*n. •m=2a+1 and n=2b+1. •a and b are non-negative integers.
  • 9. 9 Assume the origin of the mask is the center of the mask. for a 3 x 3 mask, 1 1 1 1 ( , ) ( , ) ( , ) s t g x y w s t f x s y t      
  • 10. 10 LINEAR V/S NON-LINEAR A filtering method is linear when the output is a weighted sum of the input pixels. Methods that do not satisfy the above property are called non-linear.
  • 11. 11 Linear Spatial Filtering Methods Two main linear spatial filtering methods: Correlation Convolution
  • 12. 12 Correlation: •Process of passing the mask w by the image array f. Convolution •Often used in applications where we need to measure the similarity between images or parts of images (e.g., pattern matching). •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!
  • 13. 13 TOOL BOX IMPLEMENTATION g = imfilter(f, w, filtering_mode, boundary_options, size_options) Common syntax g = imfilter(f, w, ‘replicate’)
  • 14. 14 How do we choose the elements of a mask? Typically, by sampling certain functions. Gaussian 1st derivative of Gaussian 2nd derivative of Gaussian Gaussian 1st derivative of Gaussian 2nd derivative of Gaussian
  • 15. 15 Spatial filters : Smoothing ( low pass) Use: for blurring and noise reduction. How it works? The value of every pixel is replaced by the average of the gray levels in the neighborhood. Type of smoothing filters: 1. Standard average 2. Weighted average. 3. Median filter Gaussian
  • 16. 16 1 1 1 1 1 1 1 1 1  9 1 1 2 1 2 4 2 1 2 1  16 1 Standard average Weighted average 13090120110 200989491 100999190 90859682 Standard averaging filter: (110 +120+90+91+94+98+90+91+99)/9 =883/9 = 98.1 Weighted averaging filter: (110 +2 x 120+90+2 x 91+4 x 94+2 x 98+90+2 x 91+99)/16 =97.81
  • 17. 17 Mask size determines the degree of smoothing and loss of detail. original 3x3 5x5 7x7 15x15 25x25
  • 18. 18 13090120110 200989491 100999590 90859682 95 Steps: 1. Sort the pixels in ascending order: 90,90, 91, 94, 95, 98, 99, 110, 120 2. replace the original pixel value by the median : 95 Median filter(non linear)
  • 19. 19 Very effective for removing “salt and pepper” noise (i.e., random occurrences of black and white pixels). Averaging Median filtering
  • 20. 20 Spatial filters : Sharpening ( high pass) Use: for highlighting fine detail or enhancing detail that has been blurred. 1st derivative of Gaussian 1st derivative of Gaussian 2nd derivative of Gaussian Type of sharpening filters:
  • 21. 21 155153156157153 159156158156159 160156154158155 160160158157154 155156157157157 •154*4 – 158- 156-158-158 = -14 •So the value after filter = -14 •We call the resultant image: sharpened image. •Filtered image=original +sharpened image •The value in the filter image=154-14 =130 SHARPENING – 1ST DERIVATIVE •Apply the following laplace on the highlighted pixel
  • 22. 22 155153156157153 159156158156159 160156154158155 160160158157154 155156157157157 •Apply the following laplace 2nd derivative on the highlighted pixel •154*4 – 158- 156-158-158 = -14 •Apply laplace to all pixels •Then apply it again to our pixel:-14*4 – 10 -10 – (-6) -4 =-74 •So the value after 2nd derivative filter =-74 •The value of pixel in the filter image=154-74 = 80 SHARPENING – 2nd DERIVATIVE
  • 23. 23 Original Image Laplace Sharpened Image Laplace Filtered Image