Q5Digital Image Processing
Question
Q.3. (a) Discuss working of order static filter and their suitable application in image processing. [8]
(b) Explain the adaptive median filter and also write its application. [8]
Answer
Order-statistic filters (median, max, min, midpoint) rank the pixel values within a neighborhood and select a specific ranked value for noise removal, and the adaptive median filter extends this by dynamically adjusting its window size based on local statistics to remove higher noise densities while preserving detail better than a fixed-size median filter.
(a) Order-Statistic Filters
Order-statistic filters are a class of nonlinear spatial filters whose response is based on ranking (ordering) the pixel intensity values contained within a defined neighborhood (typically a square window such as 3x3 or 5x5) and selecting a particular ranked value from that ordered sequence as the output pixel value. Because they operate on ranked (sorted) values rather than a weighted sum, these filters can suppress certain kinds of noise, especially impulse noise, far more effectively than linear filters such as the mean/averaging filter, while also better preserving edges.
- Median filter: selects the middle value (the 50th percentile) of the sorted neighborhood pixel values as the output. It is excellent for removing salt-and-pepper (impulse) noise because extreme outlier values (very bright 'salt' or very dark 'pepper' pixels) get pushed to the ends of the sorted list and are therefore automatically excluded from the middle position, unlike a linear averaging filter which would be skewed by such outliers. The median filter also preserves edges considerably better than linear smoothing filters because it does not blur sharp transitions the way an average does.
- Max filter: selects the maximum value (the 100th percentile) of the sorted neighborhood. It is used to find the brightest points in a local region and is particularly effective at reducing 'pepper' noise (dark impulse noise), since replacing a dark outlier pixel with the local maximum removes the dark speck, though it tends to brighten and grow bright image features.
- Min filter: selects the minimum value (the 0th percentile) of the sorted neighborhood. It is used to find the darkest points in a local region and is effective at reducing 'salt' noise (bright impulse noise), since replacing a bright outlier pixel with the local minimum removes the bright speck, though it tends to darken and grow dark image features.
- Midpoint filter: computes the average of the maximum and minimum values within the neighborhood, i.e., (max + min)/2. It combines some order-statistic robustness with an averaging step and works best for noise types with relatively random distributions such as Gaussian or uniform noise, though it is less effective than the median filter specifically against salt-and-pepper impulse noise.
These filters are typically applied by sliding the chosen window over every pixel position of the image, extracting and sorting the neighborhood values at each position, and outputting the appropriate ranked statistic in place of the original center pixel, producing a filtered output image of the same size (with suitable handling, such as zero-padding or edge replication, at the image boundaries).
(b) Adaptive Median Filter
The adaptive median filter is an enhancement of the basic fixed-window median filter that dynamically changes the size of the filtering window at each pixel position based on the local statistical characteristics of the neighborhood, rather than always using the same fixed window size across the entire image. The algorithm begins with a small window size (e.g., 3x3) centered at the pixel being processed and evaluates a set of conditions to decide whether the current window is adequate, or whether it should be enlarged.
The algorithm operates in two conceptual decision stages, commonly labeled Level A and Level B. In Level A, the algorithm computes Zmin, Zmax, and Zmed (the minimum, maximum, and median intensity values within the current window) and checks whether Zmed itself is an impulse, i.e., whether Zmin < Zmed < Zmax. If this condition holds, the median value is considered a valid, non-impulse value, and the algorithm proceeds to Level B; if not (meaning Zmed equals Zmin or Zmax, suggesting the median itself may be corrupted by noise), the window size is increased and Level A is repeated, up to a predefined maximum window size. In Level B, the algorithm checks whether the original center pixel value Zxy is itself an impulse, i.e., whether Zmin < Zxy < Zmax. If this condition holds, the center pixel is not an impulse and its original value is retained unchanged in the output (to preserve genuine image detail); if not, the center pixel is replaced by the median value Zmed (since it has been identified as an impulse/noise pixel).
This adaptive window-growing strategy allows the filter to keep searching a larger neighborhood until it finds a window in which the median value is reliably a non-impulse (genuine image) value, before deciding whether the actual center pixel needs replacement. As a result, the adaptive median filter is capable of removing considerably higher densities of salt-and-pepper noise than a fixed-size median filter can handle without excessive blurring, while also doing a much better job of preserving fine detail and avoiding unnecessary distortion of edges and thin lines, since pixels identified as genuine (non-impulse) are left completely untouched rather than being smoothed along with the noisy ones. Its primary application is therefore the removal of salt-and-pepper noise, particularly in images corrupted by high noise density, in situations such as sensor faults, transmission errors, or old/damaged scanned photographs, where preserving structural detail while removing heavy impulse noise is critical.
A further important benefit of the adaptive median filter, beyond simply tolerating higher noise densities, is that it can be configured to distinguish between genuine thin image structures (such as fine lines or small isolated features that are part of the actual scene content) and true impulse noise, something a fixed-size median filter with a large window would fail to do, since a large fixed window would treat both a thin genuine line and an isolated noise speck identically and potentially smooth away the legitimate thin line along with the noise. Because the adaptive algorithm starts with the smallest possible window and only grows the window when necessary (i.e., only when the smaller window's median is itself found to be an impulse), it uses the smallest window sufficient to make a reliable noise/non-noise decision at each individual pixel location, which is precisely why it achieves noticeably better detail preservation than any single fixed window size could achieve across an entire image with spatially varying noise density and image content.
The maximum permitted window size in the adaptive algorithm is typically capped at a chosen upper limit (for example 7x7 or 9x9); if the window has grown to this maximum size and the median is still found to be an impulse (i.e., Level A never succeeds even at the largest allowed window), the algorithm outputs the median value found at that maximum window size as a fallback, since no further enlargement is permitted. This capping ensures the algorithm always terminates in a bounded number of steps per pixel and avoids arbitrarily large, computationally expensive windows in pathological cases.