Sliding median filter
Choose a local middle value while preserving the original input for every window.
Adult planning suggestion: about 9–12 · Logic & rule checking
- Players
- 2–3 per group
- Time
- 15–25 minutes
- Materials
- Seven-number strip and a three-slot window.
Prepare
Write input 1,1,9,1,1,4,4 in seven positions. Output goes on a separate row. Copy positions 1 and 7 unchanged. At every interior position use that position and its two immediate neighbours from the original input, sort the three values and write their middle value.
Follow the rule
Slide the window one position at a time, keeping overlaps. Do not replace the old strip as you go, and do not use the arithmetic average. A median is one of the window's ordered values; the mean of 1,1,9 is not its median.
Check each step
Windows centred at 2,3,4,5,6 are (1,1,9),(1,9,1),(9,1,1),(1,1,4),(1,4,4). Their sorted middle values are 1,1,1,1,4. Including copied endpoints, output is 1,1,1,1,1,4,4.
Worked example
Test the separate input 0,9,0 with the same endpoint-copy rule: its centre becomes 0 and output is 0,0,0. A zero-padding software default is a different boundary policy, so do not silently compare its endpoint results with ours as if one answer must be wrong.
Finish and adapt
Ten trios rotate window reader, sorter and original-row auditor. Finish after all seven output positions have a recorded reason. Use numerals rather than pixels or actual personal measurements. This one-dimensional paper task does not claim to implement a full image-restoration tool or always preserve important signals.
Purpose, observation and provenance
Within this activity: Choose a local middle value while preserving the original input for every window.
Ask for the sorted three-value window before accepting its middle value.
Our rules, examples and printable diagrams are separately prepared. The earliest inventor of the broader mechanism is not established here.
SciPy — medfilt — Local median filtering is background; our boundary rule copies endpoints and deliberately differs from this function’s zero padding.
Secondary practice: Cooperation and explaining a check.
For a class of 30, use ten groups of three. Prepare one player-material set per group and keep the host key with the adult. Rotate operator, recorder and checker after each worked example; a reader or scribe may help without choosing answers. Avoid public ranking or diagnostic labels.
Age bands are planning suggestions. Background references may address older learners and do not validate suitability for this age band. Goals describe observable actions, not measured long-term gains or institutional endorsement.
Free alternative: Copy the supplied grids, labels and cards onto reused paper. No specialist product is needed. Adults may prepare pieces or act as a scribe.
Printable materials
Preview at 100% scale, with browser headers and footers off. Cut with suitable help. Keep host keys separate. This is a manual tabletop kit, not an online opponent, automatic judge or solver.
Sliding median filter · Player materials
Before you start
Write input 1,1,9,1,1,4,4 in seven positions. Output goes on a separate row. Copy positions 1 and 7 unchanged. At every interior position use that position and its two immediate neighbours from the original input, sort the three values and write their middle value.
Slide the window one position at a time, keeping overlaps. Do not replace the old strip as you go, and do not use the arithmetic average. A median is one of the window's ordered values; the mean of 1,1,9 is not its median.
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| Old | 1 | 1 | 9 | 1 | 1 | 4 | 4 |
| New |
| Centre | Old triple / sorted | Median |
|---|---|---|
| ________ | ________ | ________ |
| ________ | ________ | ________ |
| ________ | ________ | ________ |
| ________ | ________ | ________ |
| ________ | ________ | ________ |
Sliding median filter · Host key — keep separate
Input 1,1,9,1,1,4,4 gives 1,1,1,1,1,4,4; 0,9,0 gives 0,0,0 under copied endpoints.
Run and audit
Write input 1,1,9,1,1,4,4 in seven positions. Output goes on a separate row. Copy positions 1 and 7 unchanged. At every interior position use that position and its two immediate neighbours from the original input, sort the three values and write their middle value.
Slide the window one position at a time, keeping overlaps. Do not replace the old strip as you go, and do not use the arithmetic average. A median is one of the window's ordered values; the mean of 1,1,9 is not its median.
Windows centred at 2,3,4,5,6 are (1,1,9),(1,9,1),(9,1,1),(1,1,4),(1,4,4). Their sorted middle values are 1,1,1,1,4. Including copied endpoints, output is 1,1,1,1,1,4,4.
Test the separate input 0,9,0 with the same endpoint-copy rule: its centre becomes 0 and output is 0,0,0. A zero-padding software default is a different boundary policy, so do not silently compare its endpoint results with ours as if one answer must be wrong.
Ten trios rotate window reader, sorter and original-row auditor. Finish after all seven output positions have a recorded reason. Use numerals rather than pixels or actual personal measurements. This one-dimensional paper task does not claim to implement a full image-restoration tool or always preserve important signals.
Observe and support
Ask for the sorted three-value window before accepting its middle value.
Use large paper marks or a scribe when needed. A valid example is not a uniqueness or long-term learning claim.