nabu.cuda.medfilt module

class nabu.cuda.medfilt.MedianFilter(shape, footprint=(3, 3), mode='reflect', threshold=None, cuda_options=None, abs_diff=False)[source]

Bases: object

A class for performing median filter on GPU with CUDA

Constructor of Cuda Median Filter.

Parameters:
  • shape (tuple) – Shape of the array, in the format (n_rows, n_columns)

  • footprint (tuple) – Size of the median filter, in the format (y, x).

  • mode (str) –

    Boundary handling mode. Available modes are:
    • ”reflect”: cba|abcd|dcb

    • ”nearest”: aaa|abcd|ddd

    • ”wrap”: bcd|abcd|abc

    • ”constant”: 000|abcd|000

    Default is “reflect”.

  • threshold (float, optional) – Threshold for the “thresholded median filter”. A thresholded median filter only replaces a pixel value by the median if this pixel value is greater or equal than median + threshold.

  • abs_diff (bool, optional) – Whether to perform conditional threshold as abs(value - median)

Notes

Please refer to the documentation of the CudaProcessing class for the other parameters.

medfilt2(image, output=None)[source]

Perform a median filter on an image (or batch of images).

Parameters:
  • images (numpy.ndarray or pycuda.gpuarray) – 2D image or 3D stack of 2D images

  • output (numpy.ndarray or pycuda.gpuarray, optional) – Output of filtering. If provided, it must have the same shape as the input array.