Filters

1. What is a Filter?

  • Definition: A small matrix (kernel) used to modify an image by performing a mathematical operation called convolution.
  • Mechanism: The filter slides across the image, pixel by pixel, applying its operation to each pixel neighborhood.
  • Analogy: Think of it like a “sliding window” that transforms the image as it moves.

2. Purpose of Filters

Filters are fundamental in image processing and computer vision, used for:

  • Feature Extraction:
    • Highlighting patterns like edges, corners, textures, blobs.
  • Image Enhancement:
    • Noise reduction
    • Sharpening details
    • Contrast adjustment
  • Image Transformation:
    • Blurring
    • Embossing
    • Creating artistic effects

3. Types of Filters

A. Linear Filters

  • Definition: Perform a weighted sum of pixel values in the neighborhood defined by the kernel. Output pixel = Linear combination of input pixel values.

  • Properties: Computationally efficient Easy to understand and implement

  • Subtypes:

    1. Smoothing/Blurring Filters:

      • Purpose:
        • Smooth out edges
        • Create a blurring effect
        • Reduce noise
      • Effect:
        • Less sharp image
        • Removes fine details
      • Examples:
        • Mean Filter (Box Blur): Each pixel becomes the average of its neighbors.
          • Note: Larger kernel = more blur.
        • Gaussian Filter: Weights neighbors using a Gaussian function (bell curve).
          • Note: Closer pixels have higher weights, resulting in a more natural blur.

B. Non-linear Filters

  • Definition: Output is based on a non-linear function applied to the pixel neighborhood (not just a weighted sum).

  • Properties:

    • Can be better at preserving edges while removing noise
    • Can handle specific types of features
    • Computationally more expensive than linear filters
  • Subtypes:

    1. Median Filter:

      • Purpose:
        • Excellent for removing “salt-and-pepper” noise (random bright and dark pixels)
      • Effect:
        • Replaces each pixel with the median value of its neighbors
        • Preserves edges better than mean filtering
    2. Min Filter:

      • Purpose:
        • Enhance dark features
        • Remove bright noise
      • Effect:
        • Replaces each pixel with the minimum value in its neighborhood
        • Darkens the image
    3. Max Filter:

      • Purpose:
        • Enhance bright features
        • Remove dark noise
      • Effect:
        • Replaces each pixel with the maximum value in its neighborhood
        • Brightens the image
    4. Morphological Filters:

      • Purpose:
        • Shape analysis
        • Object manipulation
      • Effect:
        • Modify object shapes and structures based on a structuring element (a small shape used as a probe)
      • Examples:
        • Erosion
        • Dilation
        • Opening
        • Closing

4. Filter Summary Table

Filter TypeSubtypePurposeEffect
LinearSmoothing/BlurringReduce noise, smooth edgesLess sharp, blurred image
SharpeningEnhance edges, fine detailsIncreased edge contrast, sharper image
Edge DetectionDetect edgesHighlights sharp changes in intensity
Non-linearMedianRemove salt-and-pepper noisePreserves edges, reduces noise
MinEnhance dark features, remove bright noiseDarker image, emphasizes dark areas
MaxEnhance bright features, remove dark noiseBrighter image, emphasizes bright areas
MorphologicalShape analysis, object manipulationModifies object shapes and structure based on kernel

NOTE

Median Filter is not linear filter

NOTE

Gaussian Filter is similar to human vision