Unit II
Unit II
image by applying a filter directly in the spatial domain. This involves manipulating pixel values based on their
neighborhood, usually using a kernel or mask. The technique is widely used in tasks such as image smoothing,
sharpening, edge detection, and noise reduction.
Key Concepts in Spatial Filtering
1. Spatial Domain: Operations performed directly on the pixels of an image.
2. Kernel/Mask: A small matrix (e.g., 3x3, 5x5) used to apply filtering. It is convolved with the image to compute
new pixel values.
3. Convolution: A mathematical operation where the kernel slides over the image, and each pixel is replaced by
a weighted sum of its neighbors, determined by the kernel.
Types of Spatial Filters
1. Linear Filters:
1. Smoothing Filters: Reduce noise and smooth the image by averaging pixel values. Examples:
1. Mean filter
2. Gaussian filter
2. Sharpening Filters: Enhance edges and details in the image by emphasizing intensity differences.
Examples:
1. Laplacian filter
2. High-pass filter
2. Non-Linear Filters:
1. These filters do not use a fixed kernel and often rely on ranking or statistical operations. Examples:
1. Median filter: Reduces noise, especially salt-and-pepper noise.
2. Mode filter: Replaces a pixel value with the most common value in its neighbourhood.
Applications of Spatial Filtering
•Noise Reduction: Smoothing filters like the Gaussian filter help remove unwanted noise while preserving edges
to some extent.
• Edge Detection: Filters like the Sobel, Prewitt, or Laplacian are designed to highlight edges in an image.
• Image Sharpening: High-pass filters are used to accentuate fine details and edges in an image.
•Feature Extraction: Spatial filters can emphasize specific patterns, such as textures or contours, to assist in image
analysis tasks.
Implementation Steps
1. Choose a Kernel: Based on the intended purpose (e.g., smoothing, edge detection).
2. Apply Convolution: Slide the kernel over the image and compute the filtered pixel value.
3. Handle Borders: Techniques like padding or ignoring borders are used to deal with edge cases where the kernel
exceeds image dimensions.
Combining Spatial Enhancement Methods
Combining spatial enhancement methods involves integrating different techniques to
achieve improved image quality, balancing contrast, edge sharpness, and noise
reduction. Below is an example process for combining methods effectively:
Advantages of Combining Methods
•Noise Removal: Smoothing filters remove noise, ensuring a cleaner image.
•Detail Preservation: CLAHE enhances local contrast, revealing fine textures.
• Balanced Enhancement: Combining local and global enhancement avoids over-
enhancement or loss of uniformity.
• Improved Edge Clarity: Sharpening filters ensure edges are distinct, improving feature
detection.
FILTERING IN THE FREQUENCY DOMAIN
Filtering in the frequency domain is a signal processing technique used to modify or enhance certain
frequency components of a signal while attenuating others. It is widely applied in image processing,
audio processing, and other domains where frequency information is critical.