FUNDAMENTALS OF SPATIAL FILTERING
• Spatial filtering is a fundamental concept in digital image processing that
involves modifying pixel values based on their neighboring pixels.
• This technique is essential for various applications, including image
enhancement, noise reduction, and edge detection.
• Definition: Spatial filtering involves applying a filter mask (or kernel) to an
image.
• The filter mask is a small matrix of coefficients that determines how the
pixel values in the neighborhood of a target pixel are combined to produce
a new pixel value.
• Filter Masks: The filter mask can be of various sizes, commonly 3x3, 5x5,
etc.
• Each coefficient in the mask corresponds to a pixel in the neighborhood of
the target pixel.
• The center of the mask is typically aligned with the target pixel.
• Types of Filters:
• Linear Filters: These filters compute the output pixel value as a
weighted sum of the input pixel values. The weights are defined by
the filter mask. Common linear filters include:
• Smoothing Filters: These reduce noise and blur the image. An example
is the averaging filter, which replaces each pixel with the average of its
neighbors.
• Sharpening Filters: These enhance edges and fine details. An example is
the Laplacian filter, which highlights areas of rapid intensity change.
• Nonlinear Filters: These filters do not use a simple weighted sum. For
example, median filters replace the pixel value with the median of the
neighborhood pixel values, which is effective for removing impulse
noise (salt-and-pepper noise).
MECHANICS OF LINEAR SPATIAL FILTERING
• Filter Application: The process of applying a filter involves moving the filter mask across the image.
• At each position (x, y), the response of the filter is calculated using the following equation:
Where:
• R(x,y)R(x, y)R(x,y) is the output pixel value at position (x,y)(x, y)(x,y)
• w(s,t)w(s, t)w(s,t) are the filter (kernel) coefficients
• f(x+s,y+t)f(x + s, y + t)f(x+s,y+t) are the neighboring pixel values from the original image
• m=2a+1m = 2a + 1m=2a+1 and n=2b+1n = 2b + 1n=2b+1 define the dimensions of the filter mask
(typically odd numbers)
• This operation computes a weighted sum of the neighboring pixels, enabling effects like blurring,
sharpening, or edge detection.
• Computational Efficiency: The naive implementation of spatial filtering can
be computationally expensive, especially for large masks. Techniques such as
the box filter algorithm can significantly reduce the number of computations
by updating only the parts of the image that change as the mask moves 9.
• Handling Image Borders: When the mask reaches the edges of the image,
several strategies can be employed:
• Limiting Mask Movement: Restrict the mask to only cover pixels that are
fully within the image.
• Padding: Add rows and columns of zeros (or replicate border pixels) to the
image to allow the mask to move freely 12.
• Centering the Mask: The filter mask is centered on the pixel being processed.
For a 3x3 mask, the center coefficient corresponds to the pixel value at (x, y),
while the other coefficients correspond to the surrounding pixels 12.
SPATIAL CORRELATION AND CONVOLUTION
Spatial Correlation
• Spatial correlation refers to the process of measuring the similarity between an image and
a filter (or kernel) as the filter is moved across the image.
• It quantifies how much the filter matches the image at each position.
• The primary purpose of spatial correlation is to extract features from the image, such as
edges or textures, by assessing how well the filter matches local patterns in the image.
Convolution
• Convolution is a mathematical operation that combines two functions to produce a third function.
• In the context of image processing, it involves applying a filter to an image in a way that combines
the values of the image pixels with the filter coefficients.
• Convolution is widely used for various image processing tasks, including blurring, sharpening, and
edge detection.
• It allows for the modification of pixel values based on their neighborhood, effectively altering the
image’s appearance.
SEPARABLE FILTER KERNELS
• Separable filter kernels allow for efficient implementation of filtering
operations by breaking down a two-dimensional filter into two one-
dimensional filters.
• Definition of Separable Filters
• A filter kernel is said to be separable if it can be expressed as the outer
product of two one-dimensional vectors.
• This means that a two-dimensional filter can be decomposed into two
successive one-dimensional filtering operations, one in the horizontal
direction and the other in the vertical direction.
• Advantages of Separable Filters
• Computational Efficiency: Separable filters significantly reduce the computational cost of
applying a filter. Instead of performing a two-dimensional convolution, which involves (m x
n) multiplications for an (m x n) filter, two one-dimensional convolutions can be performed.
This reduces the number of operations to (m + n), which is much more efficient, especially
for large filters.
• Simplicity in Implementation: Implementing two one-dimensional convolutions is generally
simpler and requires less memory than implementing a single two-dimensional convolution.
• Flexibility: Separable filters allow for greater flexibility in designing filters. Different one-
dimensional filters can be combined to create various effects, such as smoothing or
sharpening.
• Examples of Separable Filters
• Gaussian Filter: The Gaussian filter is a common example of a separable filter. The two-
dimensional Gaussian function can be expressed as the product of two one-dimensional
Gaussian functions.
• Box Filter: A simple averaging filter (box filter) can also be separated into two one-
dimensional box filters.
Implementation of Separable Filters
When applying a separable filter to an image, the process typically involves two
steps:
Horizontal Convolution: The image is first convolved with the horizontal filter
( u(x) ).
This modifies the pixel values based on their horizontal neighbors.
Vertical Convolution: The result from the first convolution is then convolved with
the vertical filter ( v(y) ).
This completes the filtering process, effectively applying the two-dimensional
filter.

More Related Content

PPSX
Image Processing: Spatial filters
PDF
Lecture 4
PPTX
imge enhncement sptil filtering55555.pptx
PDF
Module 2 Computer Vision: Image Processing
PPTX
Lec5_AIP [Spatial Filtering] (1).pptxJJJJJJJJJJJJJJJJJJJJJJJ
PPTX
Lec5_AIP [Spatial Filtering] (1).pptxt767686777
PDF
PPT s04-machine vision-s2
PPTX
COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filterin...
Image Processing: Spatial filters
Lecture 4
imge enhncement sptil filtering55555.pptx
Module 2 Computer Vision: Image Processing
Lec5_AIP [Spatial Filtering] (1).pptxJJJJJJJJJJJJJJJJJJJJJJJ
Lec5_AIP [Spatial Filtering] (1).pptxt767686777
PPT s04-machine vision-s2
COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filterin...

Similar to spatial_filtering fundamentals from textbook (20)

PDF
Overview of Convolutional Neural Networks
PPTX
Image enhancement
PPTX
Digital image processing techniques
PDF
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
PPT
12-Image enhancement and filtering.ppt
PPT
PPTX
Spatial enhancement
PPTX
image processing using matlab in faculty
PPTX
Smoothing in Digital Image Processing
PPTX
Digital image processing
PPTX
SPATIAL FILTERING. FOR UNDERGRADUATE .pptx
PPTX
CNN_AH.pptx
PPTX
CNN_AH.pptx
PPT
Imageddddddddddddddddddddddddddddddddddd_Filter.ppt
PPTX
Computer Vision UNit 3 Presentaion Slide
PPTX
different filters used in the images.pptx
PDF
International Journal of Computational Engineering Research(IJCER)
PPTX
Unit-2 Image Enhancement and Restoration Techniques.pptx
PPTX
2. filtering basics
PDF
Spatial Domain Filtering.pdf
Overview of Convolutional Neural Networks
Image enhancement
Digital image processing techniques
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
12-Image enhancement and filtering.ppt
Spatial enhancement
image processing using matlab in faculty
Smoothing in Digital Image Processing
Digital image processing
SPATIAL FILTERING. FOR UNDERGRADUATE .pptx
CNN_AH.pptx
CNN_AH.pptx
Imageddddddddddddddddddddddddddddddddddd_Filter.ppt
Computer Vision UNit 3 Presentaion Slide
different filters used in the images.pptx
International Journal of Computational Engineering Research(IJCER)
Unit-2 Image Enhancement and Restoration Techniques.pptx
2. filtering basics
Spatial Domain Filtering.pdf
Ad

Recently uploaded (20)

PDF
Applications of Equal_Area_Criterion.pdf
PPTX
Amdahl’s law is explained in the above power point presentations
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
Prof. Dr. KAYIHURA A. SILAS MUNYANEZA, PhD..pdf
PDF
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PPTX
CyberSecurity Mobile and Wireless Devices
PDF
First part_B-Image Processing - 1 of 2).pdf
PPTX
wireless networks, mobile computing.pptx
PPTX
Software Engineering and software moduleing
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPTX
Petroleum Refining & Petrochemicals.pptx
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
ai_satellite_crop_management_20250815030350.pptx
PPTX
Building constraction Conveyance of water.pptx
PPTX
Principal presentation for NAAC (1).pptx
PDF
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
Applications of Equal_Area_Criterion.pdf
Amdahl’s law is explained in the above power point presentations
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
August -2025_Top10 Read_Articles_ijait.pdf
Module 8- Technological and Communication Skills.pptx
Prof. Dr. KAYIHURA A. SILAS MUNYANEZA, PhD..pdf
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
20250617 - IR - Global Guide for HR - 51 pages.pdf
CyberSecurity Mobile and Wireless Devices
First part_B-Image Processing - 1 of 2).pdf
wireless networks, mobile computing.pptx
Software Engineering and software moduleing
distributed database system" (DDBS) is often used to refer to both the distri...
Petroleum Refining & Petrochemicals.pptx
"Array and Linked List in Data Structures with Types, Operations, Implementat...
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
ai_satellite_crop_management_20250815030350.pptx
Building constraction Conveyance of water.pptx
Principal presentation for NAAC (1).pptx
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
Ad

spatial_filtering fundamentals from textbook

  • 2. • Spatial filtering is a fundamental concept in digital image processing that involves modifying pixel values based on their neighboring pixels. • This technique is essential for various applications, including image enhancement, noise reduction, and edge detection. • Definition: Spatial filtering involves applying a filter mask (or kernel) to an image. • The filter mask is a small matrix of coefficients that determines how the pixel values in the neighborhood of a target pixel are combined to produce a new pixel value. • Filter Masks: The filter mask can be of various sizes, commonly 3x3, 5x5, etc. • Each coefficient in the mask corresponds to a pixel in the neighborhood of the target pixel. • The center of the mask is typically aligned with the target pixel.
  • 3. • Types of Filters: • Linear Filters: These filters compute the output pixel value as a weighted sum of the input pixel values. The weights are defined by the filter mask. Common linear filters include: • Smoothing Filters: These reduce noise and blur the image. An example is the averaging filter, which replaces each pixel with the average of its neighbors. • Sharpening Filters: These enhance edges and fine details. An example is the Laplacian filter, which highlights areas of rapid intensity change. • Nonlinear Filters: These filters do not use a simple weighted sum. For example, median filters replace the pixel value with the median of the neighborhood pixel values, which is effective for removing impulse noise (salt-and-pepper noise).
  • 4. MECHANICS OF LINEAR SPATIAL FILTERING
  • 5. • Filter Application: The process of applying a filter involves moving the filter mask across the image. • At each position (x, y), the response of the filter is calculated using the following equation: Where: • R(x,y)R(x, y)R(x,y) is the output pixel value at position (x,y)(x, y)(x,y) • w(s,t)w(s, t)w(s,t) are the filter (kernel) coefficients • f(x+s,y+t)f(x + s, y + t)f(x+s,y+t) are the neighboring pixel values from the original image • m=2a+1m = 2a + 1m=2a+1 and n=2b+1n = 2b + 1n=2b+1 define the dimensions of the filter mask (typically odd numbers) • This operation computes a weighted sum of the neighboring pixels, enabling effects like blurring, sharpening, or edge detection.
  • 6. • Computational Efficiency: The naive implementation of spatial filtering can be computationally expensive, especially for large masks. Techniques such as the box filter algorithm can significantly reduce the number of computations by updating only the parts of the image that change as the mask moves 9. • Handling Image Borders: When the mask reaches the edges of the image, several strategies can be employed: • Limiting Mask Movement: Restrict the mask to only cover pixels that are fully within the image. • Padding: Add rows and columns of zeros (or replicate border pixels) to the image to allow the mask to move freely 12. • Centering the Mask: The filter mask is centered on the pixel being processed. For a 3x3 mask, the center coefficient corresponds to the pixel value at (x, y), while the other coefficients correspond to the surrounding pixels 12.
  • 8. Spatial Correlation • Spatial correlation refers to the process of measuring the similarity between an image and a filter (or kernel) as the filter is moved across the image. • It quantifies how much the filter matches the image at each position. • The primary purpose of spatial correlation is to extract features from the image, such as edges or textures, by assessing how well the filter matches local patterns in the image.
  • 9. Convolution • Convolution is a mathematical operation that combines two functions to produce a third function. • In the context of image processing, it involves applying a filter to an image in a way that combines the values of the image pixels with the filter coefficients. • Convolution is widely used for various image processing tasks, including blurring, sharpening, and edge detection. • It allows for the modification of pixel values based on their neighborhood, effectively altering the image’s appearance.
  • 11. • Separable filter kernels allow for efficient implementation of filtering operations by breaking down a two-dimensional filter into two one- dimensional filters. • Definition of Separable Filters • A filter kernel is said to be separable if it can be expressed as the outer product of two one-dimensional vectors. • This means that a two-dimensional filter can be decomposed into two successive one-dimensional filtering operations, one in the horizontal direction and the other in the vertical direction.
  • 12. • Advantages of Separable Filters • Computational Efficiency: Separable filters significantly reduce the computational cost of applying a filter. Instead of performing a two-dimensional convolution, which involves (m x n) multiplications for an (m x n) filter, two one-dimensional convolutions can be performed. This reduces the number of operations to (m + n), which is much more efficient, especially for large filters. • Simplicity in Implementation: Implementing two one-dimensional convolutions is generally simpler and requires less memory than implementing a single two-dimensional convolution. • Flexibility: Separable filters allow for greater flexibility in designing filters. Different one- dimensional filters can be combined to create various effects, such as smoothing or sharpening. • Examples of Separable Filters • Gaussian Filter: The Gaussian filter is a common example of a separable filter. The two- dimensional Gaussian function can be expressed as the product of two one-dimensional Gaussian functions. • Box Filter: A simple averaging filter (box filter) can also be separated into two one- dimensional box filters.
  • 13. Implementation of Separable Filters When applying a separable filter to an image, the process typically involves two steps: Horizontal Convolution: The image is first convolved with the horizontal filter ( u(x) ). This modifies the pixel values based on their horizontal neighbors. Vertical Convolution: The result from the first convolution is then convolved with the vertical filter ( v(y) ). This completes the filtering process, effectively applying the two-dimensional filter.