Image Processing and Pattern RecognitionUnit 28 min read
Image Enhancement in Spatial Domain: Techniques, Filters & Applications
Unit 2 of Image Processing and Pattern Recognition explores spatial-domain enhancement methods—point operations, spatial filtering, and morphological processing—to improve image quality, contrast, and features for better analysis and recognition.
Core Concepts
1. Spatial Domain vs. Frequency Domain
- Spatial domain: Direct manipulation of pixel intensities in the image (e.g., brightness, contrast).
- Frequency domain: Manipulation of image frequencies (Fourier transform) to enhance edges or remove noise.
- Key difference: Spatial methods work on pixel values; frequency methods work on transformed data.
2. Point Operations (Intensity Transformations)
Definitions & Types
- Point operation: Modifies pixel values based on its own intensity (no neighbor dependency).
- Common operations:
- Linear: (e.g., contrast stretching).
- Nonlinear: Logarithmic, power-law (gamma correction), histogram equalization.
How It Works
- Input: Original image with intensity .
- Output: Transformed image .
- Example: Dark image → contrast stretching to use full dynamic range.
Worked Example: Contrast St stretching
Given:
- Original image: 8-bit grayscale (0–255).
- Input range: , .
- Output range: 0–255.
Formula: where (for 8-bit).
Steps:
- For : .
- For : .
- For :
Visualization:
Advantages:
- Simple, fast (no neighbor computation).
- Preserves spatial relationships.
Disadvantages:
- Limited to global changes (no local adaptability).
3. Spatial Filtering (Neighborhood Operations)
Definitions
- Spatial filter: Modifies pixel values based on a kernel/mask (e.g., 3×3, 5×5).
- Types:
- Linear filters: Weighted average (e.g., mean, Gaussian blur).
- Nonlinear filters: Median filter (noise removal), max/min filters.
How It Works
- Kernel placement: Center the kernel over each pixel.
- Convolution: Multiply kernel weights by pixel values, sum results.
- Normalization: Divide by sum of kernel weights (for linear filters).
Worked Example: Mean Filter (Blurring)
Given:
- Image pixel values (3×3 neighborhood):
[100 120 150] [110 130 140] [160 170 180] - Kernel (3×3 mean filter):
Calculation for center pixel (130):
Visualization:
Advantages:
- Reduces noise (smoothing).
- Preserves edges poorly (blurring effect).
Disadvantages:
- Blurs edges and fine details.
- Slow for large kernels.
4. Morphological Operations
Definitions
- Morphology: Shapes image based on structuring elements (e.g., disk, square).
- Operations:
- Erosion: Shrinks bright regions (removes small white noise).
- Dilation: Expands bright regions (fills gaps).
- Opening: Erosion → Dilation (removes small objects).
- Closing: Dilation → Erosion (fills small holes).
How It Works
- Erosion: Replace pixel with min of neighborhood (under structuring element).
- Dilation: Replace pixel with max of neighborhood.
Worked Example: Erosion with Disk Structuring Element
Given:
- Binary image (1 = object, 0 = background):
[1 1 0] [1 0 0] [0 0 0] - Structuring element (3×3 disk):
[0 1 0] [1 1 1] [0 1 0]
Erosion of center pixel (0):
- Overlay structuring element → all 8 neighbors must be 1 (not true here).
- Result: Center becomes 0 (unchanged, but edges shrink).
Visualization:
Advantages:
- Preserves shape while removing noise.
- Useful for segmentation.
Disadvantages:
- Over-erosion can disconnect objects.
- Sensitive to structuring element size.
5. Applications in Real World
1. Medical Imaging (e.g., NAMS Hospital, Nepal)
- Use case: Enhancing X-ray images for better diagnosis.
- Technique: Histogram equalization to improve contrast in low-light X-rays.
- Impact: Helps radiologists detect fractures or tumors earlier.
2. Surveillance Systems (e.g., NTC Traffic Cameras)
- Use case: License plate recognition in poor lighting.
- Technique: Adaptive histogram equalization (AHE) to enhance plate visibility.
- Impact: Reduces false negatives in automated toll systems.
3. Agriculture (e.g., Daraz Farm Products)
- Use case: Detecting pests in crop images.
- Technique: Median filtering to remove noise from drone-captured images.
- Impact: Early pest detection → higher yield.
4. Social Media (e.g., Facebook Filters)
- Use case: Beauty filters (e.g., "Smooth Skin").
- Technique: Gaussian blur + edge-preserving filters.
- Impact: Millions of daily users rely on spatial filtering for aesthetic enhancement.
6. Comparison Table: Enhancement Techniques
| Technique | Domain | Key Use Case | Pros | Cons |
|---|---|---|---|---|
| Contrast Stretching | Spatial | Improve low-contrast images | Fast, simple | Global changes only |
| Mean Filter | Spatial | Noise reduction | Smooths noise | Blurs edges |
| Median Filter | Spatial | Salt-and-pepper noise removal | Preserves edges | Slower than mean filter |
| Erosion | Morphological | Remove small objects | Shape-preserving | Over-erosion risks |
| Histogram Equalization | Spatial | Enhance contrast globally | Adaptive to image content | May over-amplify noise |
7. Exam Tip
What Examiners Look For
- Definitions: Clearly distinguish between point operations, spatial filtering, and morphology.
- Mathematical Steps: Show full calculations for kernel applications (e.g., mean filter).
- Visual Proof: Always draw before/after for contrast stretching or filtering.
- Applications: Link techniques to real-world problems (e.g., medical imaging, surveillance).
- Trade-offs: Discuss when to use linear vs. nonlinear filters (e.g., median for impulse noise).
Common Pitfalls
- Assuming all filters are interchangeable: Mean filter ≠ median filter!
- Ignoring kernel size: Larger kernels blur more but take longer.
- Forgetting normalization: Always divide by kernel sum for linear filters.
Sample Exam Question & Answer
Q: Explain how a 3×3 mean filter works. Apply it to a 3×3 neighborhood with pixels:
[50 60 70]
[80 90 100]
[110 120 130]
A:
- Kernel: All weights = .
- Calculation for center (90): (Note: Center remains unchanged in this symmetric case.)
- Edge pixels: Use partial kernel (e.g., top-left pixel = average of its 3 neighbors).
Based on the PU BE Computer (PU) syllabus for Image Processing and Pattern Recognition (CMP362), unit 2.
Discussion
Loading…