Median Filtering
Detects whether an image was processed with a median filter, a smoothing operation often applied to remove noise or to erase the traces of a manipulation. A median filter outputs an actual pixel value from each neighbourhood rather than a new average, so it leaves a characteristic streaking artefact: adjacent pixels take identical values far more often than in a natural image. The indicator measures that identical-neighbour ratio as the median-specific signature, and uses the lag-1 autocorrelation only as corroboration, because correlation alone is raised by any smoothing. It works on the pixels alone, with no model.
Technical description
M10 is a deterministic, generator-agnostic screen for median filtering. Unlike a linear filter, which replaces each pixel with a weighted average and so produces new intermediate values, a median filter replaces each pixel with the median of its neighbourhood, which is always a value that already exists in that neighbourhood. The consequence, known since Bovik analysed it, is streaking: the output contains runs and patches of identical pixel values, so the proportion of pixels equal to one of their neighbours rises far above the chance level of a natural image. M10 measures this identical-neighbour ratio as the primary, median-specific signal. It also measures the lag-1 autocorrelation of adjacent pixels, but treats it only as a corroborating cue, because smoothing of any kind, linear or median, raises autocorrelation. The image must be at least 64 by 64 pixels, or the indicator returns a zero score and records that it was skipped.
How it works
The image is converted to grayscale. For every interior pixel the indicator checks whether it equals any of its four neighbours, and the identical-neighbour ratio is the fraction of interior pixels that do. A natural image has a ratio near the chance level, a few percent, while median filtering drives it up sharply because the filter repeatedly emits the same neighbourhood median. A ratio above 0.15 contributes a streaking score, ratio_score = min(2.5, 20 (ratio - 0.15)).
The lag-1 autocorrelation is computed as the mean Pearson correlation between horizontally adjacent pixels over all rows and between vertically adjacent pixels over all columns, averaged. Smoothing raises it toward one. It contributes a corroborating score only when it exceeds 0.5 and the streaking ratio also exceeds 0.15, autocorr_score = min(2.5, 5 (autocorr - 0.5)); when the streaking artefact is absent, a high autocorrelation is attributed to ordinary smoothing rather than median filtering and adds nothing. This gating is the difference that keeps a genuinely smooth or blurred image from being misread as median-filtered. The final score is min(5.0, ratio_score + autocorr_score). Findings report a high identical-neighbour ratio and, when corroborated, a high autocorrelation. The metadata records the identical-neighbour ratio, the mean autocorrelation and its row and column parts, and the two score components.
Score thresholds
| Score | Meaning |
|---|---|
| 0 to 1 | The identical-neighbour ratio is near the natural chance level, no median-filtering trace. |
| 2 to 3 | A raised identical-neighbour ratio, indicating likely median filtering. |
| 4 to 5 | A strongly raised identical-neighbour ratio corroborated by high adjacent-pixel correlation. Consistent with median filtering. |
Why this matters
Median filtering is a favourite of image manipulators precisely because it is good at hiding other traces: it suppresses the noise inconsistencies, the resampling periodicity, and the compression history that other detectors rely on, so detecting the median filter itself is a way to recover evidence that an image was scrubbed. The defining artefact is value-preserving streaking, which Bovik characterised in his analysis of why median filters produce constant runs that linear filters do not [1]. Forensic detectors build on exactly this distinction: Kirchner and Fridrich showed that median filtering leaves a robust trace in the statistics of neighbouring pixels and first-order differences, detectable even after recompression [2], and Cao and colleagues quantified the same effect through the probability that first-order differences vanish, the streaking made numerical [3]. The autocorrelation that M10 also measures is a real consequence of median smoothing but is not unique to it, since any low-pass operation raises it, which is why M10 leans on the value-preserving streaking as the median-specific signal and uses correlation only to corroborate. By reading the streaking, M10 flags that an image was median-filtered and therefore that other forensic traces may have been deliberately removed.
Limitations
The identical-neighbour ratio is the median-specific signal in principle, but it is not perfectly exclusive: any operation that strongly compresses the tonal range, such as heavy blur followed by quantisation, downscaling, or a low-bit-depth source, can also raise the number of repeated adjacent values, so on already-smooth or low-entropy content M10 cannot fully separate median filtering from other smoothing. It is most reliable on natural, full-entropy images, where a median filter's value-preserving runs are distinctive. The autocorrelation cue is gated to avoid flagging ordinary smoothing, but the gating also means a very light median filter that barely streaks may be missed. The screen returns a single global verdict and does not localize the filtered region or estimate the kernel size. The thresholds are directional rather than exact. Resampling traces are handled by indicator M9 and compression history by the JPEG-ghost indicator I7; M10 stays on the median-filter streaking signature, so the three corroborate each other when an image has been post-processed.
Theoretical background
M10 rests on the order-statistic nature of the median. A linear filter forms a weighted sum of neighbourhood values and therefore generically produces an output that equals none of its inputs, spreading the histogram and creating new intermediate levels. The median, by contrast, selects the middle value of the sorted neighbourhood, which is by definition one of the input pixels, so the output is drawn from the existing values and neighbouring windows that share most of their pixels frequently select the same median. The visible result is streaking: connected runs of identical output values, a structural fingerprint that linear smoothing does not leave. The identical-neighbour ratio measures this directly, counting how often a pixel coincides with a neighbour, which the value-selecting median inflates while a value-averaging filter does not. Autocorrelation, the tendency of adjacent pixels to be similar, is raised by both kinds of smoothing and so cannot distinguish them on its own, which is why it serves only to corroborate the streaking. Reading the streaking turns the order-statistic mechanism of the median into a test of whether the image passed through one.
References
- Bovik AC. Streaking in median filtered images. IEEE Transactions on Acoustics, Speech, and Signal Processing. 1987;35(4):493-503. DOI: 10.1109/TASSP.1987.1165153
- Kirchner M, Fridrich J. On detection of median filtering in digital images. Proceedings of SPIE 7541, Media Forensics and Security II. 2010:754110. DOI: 10.1117/12.839100
- Cao G, Zhao Y, Ni R, Yu L, Tian H. Forensic detection of median filtering in digital images. Proceedings of the 2010 IEEE International Conference on Multimedia and Expo (ICME). 2010:89-94. DOI: 10.1109/ICME.2010.5583869