mantidimaging.core.operations.median_filter.median_filter module#

class mantidimaging.core.operations.median_filter.median_filter.KernelSpinBox(on_change: Callable)[source]#

Bases: QSpinBox

validate(input: str, pos: int) tuple[State, str, int][source]#

Validate the spin box input. Returns as Intermediate state if the input is empty or contains an even number, otherwise it returns Acceptable.

class mantidimaging.core.operations.median_filter.median_filter.MedianFilter[source]#

Bases: BaseFilter

Applies Median filter to the data.

Intended to be used on: Projections or reconstructed slices

When: As a pre-processing or post-reconstruction step to reduce noise.

Note: NaN values are preserved through the filter. They are treated as negative infinity while calculating neighbouring pixels.

static compute_function(i: int, array: ndarray, params: dict[str, Any])[source]#
static execute_wrapper(size_field=None, mode_field=None, use_gpu_field=None)[source]#

Should construct a partial call to _filter_func using values taken from the widgets passed to this function as kwargs. :param kwargs: widgets which contain values required for _filter_func. :return: a partial call to _filter_func using parameters taken from the input widgets.

static filter_func(data: ImageStack, size=None, mode='reflect', progress=None, force_cpu=True)[source]#
  • data – Input data as an ImageStack object.

  • size – Size of the kernel

  • mode – The mode with which to handle the edges. One of [reflect, constant, nearest, mirror, wrap]. Modes are described in the SciPy documentation.

  • progress – The object for displaying the progress.

  • force_cpu – Whether or not to use the CPU.


Returns the processed data

filter_name = 'Median'#
static register_gui(form: QFormLayout, on_change: Callable, view) dict[str, Any][source]#

Adds any required input widgets to the given form and returns references to them.

The return values should be in a dict which can be unpacked as kwargs for a call to the operations execute_wrapper.

  • view

  • form – the layout to create input widgets in

  • on_change – the filter view action to be bound to all created inputs


the widgets bound as kwargs which are needed to call execute_wrapper