medianfilter
: OpenCL median filter¶
A module for performing the 1d, 2d and 3d median filter …
The target is to mimic the signature of scipy.signal.medfilt and scipy.medfilt2
The first implementation targets 2D implementation where this operation is costly (~10s/2kx2k image)
-
class
MedianFilter2D
(shape, kernel_size=(3, 3), ctx=None, devicetype='all', platformid=None, deviceid=None, block_size=None, profile=False)[source]¶ A class for doing median filtering using OpenCL
-
send_buffer
(data, dest)[source]¶ Send a numpy array to the device, including the cast on the device if possible
Parameters: - data – numpy array with data
- dest – name of the buffer as registered in the class
-
calc_wg
(kernel_size)[source]¶ calculate and return the optimal workgroup size for the first dimension, taking into account the 8-height band
Parameters: kernel_size – 2-tuple of int, shape of the median window Returns: optimal workgroup size
-
medfilt2d
(image, kernel_size=None)[source]¶ Actually apply the median filtering on the image
Parameters: - image – numpy array with the image
- kernel_size – 2-tuple if
Returns: median-filtered 2D image
- Nota: for window size 1x1 -> 7x7 up to 49 / 64 elements in 8 threads, 8elt/th
- 9x9 -> 15x15 up to 225 / 256 elements in 32 threads, 8elt/th 17x17 -> 21x21 up to 441 / 512 elements in 64 threads, 8elt/th
TODO: change window size on the fly,
-