Skip to content

denoise_median_2d

Square median filter over ctx.image, optionally banded by rows.

Category Preprocessing (2-D image)
Backend scipy - implemented here on top of scipy primitives
Version 1.0.0
Reads ctx.image (an ImageFrame)
Writes image

scipy.ndimage.median_filter(size=kernel_size) over rows [row_lo, row_hi). Outside the band the original pixels are kept.

Parameters

Parameter Default Required Description
kernel_size 3 - Square kernel size, odd integer ≥ 3.
row_lo 0 - First row (inclusive); 0 ⇒ top of image.
row_hi 0 - Last row (exclusive); 0 ⇒ bottom of image.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("denoise_median_2d", ctx, {
    "kernel_size": 3,
    "row_lo": 0,
    "row_hi": 0
})

The CLI loads a single 1-D spectrum with --input; this algorithm needs ctx.image (an ImageFrame). Run it from Python or as a step of a pipeline preset.

{
  "tool": "denoise_median_2d",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "kernel_size": 3,
      "row_lo": 0,
      "row_hi": 0
    }
  }
}

Every algorithm is an MCP tool of the same name; describe_algorithm returns this page's metadata as JSON.

References

  • Tukey 1977, Exploratory Data Analysis (Addison-Wesley) — rank-order filtering for impulse noise.
  • scipy.ndimage.median_filter — multi-dim median implementation.