FAILURE MAP
← Case archive

FA-91471 / Digital signal filters / Open access

Median filter accepts even kernels · case 01

K = 4 filters with an asymmetric five-sample window instead of returning "bad-kernel".

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Only non-positive kernels are rejected.

THE FAILURE

Only non-positive kernels are rejected.

Unsuccessful approach: The attempted repair rejects only K = 2.

Case contract

Input [K, samples]; K odd ("bad-kernel" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.

Why this case matters

Median filters remove impulse noise without blurring edges; window or tie handling slips shift features.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, xs = x
    if k < 1:
        return 'bad-kernel'
    h = k // 2
    out = []
    for i in range(len(xs)):
        win = sorted(xs[max(0, i - h):i + h + 1])
        m = len(win)
        if m % 2:
            out.append(str(Fraction(win[m // 2])))
        else:
            out.append(str(Fraction(win[m // 2 - 1] + win[m // 2], 2)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: unsorted window', [3, [5, 1, 9, 2]], ['3', '5', '2', '11/2']], ['control: edge even median', [3, [4, 1, 7]], ['5/2', '4', '4']], ['control: duplicates', [3, [2, 2, 5, 2]], ['2', '2', '2', '7/2']], ['control: negative odd sum', [3, [-3, 0, 5]], ['-3/2', '0', '5/2']]], [['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['control: random median 0', [3, [-2, -2, -2, 8]], ['-2', '-2', '-2', '3']], ['control: random median 1', [1, [2, 3, 4, -2]], ['2', '3', '4', '-2']], ['control: random median 2', [3, [5, 5, 3, -5, 8, -1]], ['5', '5', '3', '3', '-1', '7/2']], ['control: random median 3', [1, [2, -3, 7, 8, -2, 3, 8, 1]], ['2', '-3', '7', '8', '-2', '3', '8', '1']]], [['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: random median 4', [3, [0, -4, -4, 3]], ['-2', '-4', '-4', '-1/2']], ['control: random median 5', [3, [2, -2, -2, -2, -4, -4]], ['0', '-2', '-2', '-2', '-4', '-4']], ['control: random median 6', [3, [3, 9, 2, 4, 6, 3, -4]], ['6', '3', '4', '4', '4', '3', '-1/2']], ['control: random median 7', [1, [7, 6, 6, -2, 6, 0, 8, -4]], ['7', '6', '6', '-2', '6', '0', '8', '-4']]], [['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['control: random median 8', [1, [2, 8, -4, 9, 7, 7]], ['2', '8', '-4', '9', '7', '7']], ['control: random median 9', [1, [2, 5, 7, 9]], ['2', '5', '7', '9']], ['control: random median 10', [1, [9, 3, -5, 8]], ['9', '3', '-5', '8']], ['control: random median 11', [5, [4, 4, 3, -2, -2, 4, 2, 1]], ['4', '7/2', '3', '3', '2', '1', '3/2', '2']]], [['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: random median 12', [3, [7, 1, -5, -5, -5, 2, 5, -5]], ['4', '1', '-5', '-5', '-5', '2', '2', '0']], ['control: random median 13', [3, [1, -4, -1, 3, 9, 4, 6, 2]], ['-3/2', '-1', '-1', '3', '4', '6', '4', '4']], ['control: random median 14', [1, [2, 8, 6, 5, -4, -3, -1]], ['2', '8', '6', '5', '-4', '-3', '-1']], ['control: random median 15', [1, [8, 2]], ['8', '2']]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: even kernel['3/2', '2', '5/2']bad-kernelFailed
regression: even kernel four['2', '7/2', '7/2', '5']bad-kernelFailed
control: unsorted window['3', '5', '2', '11/2']['3', '5', '2', '11/2']Passed
control: edge even median['5/2', '4', '4']['5/2', '4', '4']Passed
control: duplicates['2', '2', '2', '7/2']['2', '2', '2', '7/2']Passed
control: negative odd sum['-3/2', '0', '5/2']['-3/2', '0', '5/2']Passed

SHA-256 / 5bb4b279e2fb0de4f903226850d33f981544f622d58762633fca2f521e9923ae

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, xs = x
    if k < 1 or k == 2:
        return 'bad-kernel'
    h = k // 2
    out = []
    for i in range(len(xs)):
        win = sorted(xs[max(0, i - h):i + h + 1])
        m = len(win)
        if m % 2:
            out.append(str(Fraction(win[m // 2])))
        else:
            out.append(str(Fraction(win[m // 2 - 1] + win[m // 2], 2)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: unsorted window', [3, [5, 1, 9, 2]], ['3', '5', '2', '11/2']], ['control: edge even median', [3, [4, 1, 7]], ['5/2', '4', '4']], ['control: duplicates', [3, [2, 2, 5, 2]], ['2', '2', '2', '7/2']], ['control: negative odd sum', [3, [-3, 0, 5]], ['-3/2', '0', '5/2']]], [['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['control: random median 0', [3, [-2, -2, -2, 8]], ['-2', '-2', '-2', '3']], ['control: random median 1', [1, [2, 3, 4, -2]], ['2', '3', '4', '-2']], ['control: random median 2', [3, [5, 5, 3, -5, 8, -1]], ['5', '5', '3', '3', '-1', '7/2']], ['control: random median 3', [1, [2, -3, 7, 8, -2, 3, 8, 1]], ['2', '-3', '7', '8', '-2', '3', '8', '1']]], [['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: random median 4', [3, [0, -4, -4, 3]], ['-2', '-4', '-4', '-1/2']], ['control: random median 5', [3, [2, -2, -2, -2, -4, -4]], ['0', '-2', '-2', '-2', '-4', '-4']], ['control: random median 6', [3, [3, 9, 2, 4, 6, 3, -4]], ['6', '3', '4', '4', '4', '3', '-1/2']], ['control: random median 7', [1, [7, 6, 6, -2, 6, 0, 8, -4]], ['7', '6', '6', '-2', '6', '0', '8', '-4']]], [['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['control: random median 8', [1, [2, 8, -4, 9, 7, 7]], ['2', '8', '-4', '9', '7', '7']], ['control: random median 9', [1, [2, 5, 7, 9]], ['2', '5', '7', '9']], ['control: random median 10', [1, [9, 3, -5, 8]], ['9', '3', '-5', '8']], ['control: random median 11', [5, [4, 4, 3, -2, -2, 4, 2, 1]], ['4', '7/2', '3', '3', '2', '1', '3/2', '2']]], [['regression: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['regression: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: random median 12', [3, [7, 1, -5, -5, -5, 2, 5, -5]], ['4', '1', '-5', '-5', '-5', '2', '2', '0']], ['control: random median 13', [3, [1, -4, -1, 3, 9, 4, 6, 2]], ['-3/2', '-1', '-1', '3', '4', '6', '4', '4']], ['control: random median 14', [1, [2, 8, 6, 5, -4, -3, -1]], ['2', '8', '6', '5', '-4', '-3', '-1']], ['control: random median 15', [1, [8, 2]], ['8', '2']]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: even kernelbad-kernelbad-kernelPassed
regression: even kernel four['2', '7/2', '7/2', '5']bad-kernelFailed
control: unsorted window['3', '5', '2', '11/2']['3', '5', '2', '11/2']Passed
control: edge even median['5/2', '4', '4']['5/2', '4', '4']Passed
control: duplicates['2', '2', '2', '7/2']['2', '2', '2', '7/2']Passed
control: negative odd sum['-3/2', '0', '5/2']['-3/2', '0', '5/2']Passed

SHA-256 / f91a09cf48e32c8e57a4aacb53999e077a576e19bd4c4de3cfad8088b10986d8

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; exact rational arithmetic or fixed-decimal rounding keeps outputs strict JSON. It is not a production DSP library and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:36.313060+00:00.

Case digest / 808fd2b4a0d183728eda0bf669d74db670923c0eb7c7b1f0a3f6ddba2213ff51