Skip to content
class

MedianBlur

extendsPhotometricTransform[KSizeParam]
MedianBlur(blur_limit: int = 7, p: float = 0.5)

Median filter with a random odd kernel (Albumentations MedianBlur).

Samples an odd kernel size k uniformly from [3, blur_limit], builds the k * k shifted-neighbour stack via lucid.roll, sorts along the stack axis, and returns the median element — an impulse-noise denoiser that preserves edges better than Blur.

Parameters

blur_limitint= 7
Inclusive upper bound on the sampled kernel size; rounded up to the next odd integer so the window is centred.
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.MedianBlur(p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 32, 32)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(blur_limit: int = 7, p: float = 0.5)

Instance methods

1
fn

make_params

→KSizeParam
make_params(img: Tensor)

Sample per-call random parameters for MedianBlur.

Parameters

Image tensor; not inspected, only carried through for the transform dispatch.

Returns

KSizeParam

Carries ksize — the odd window side length sampled uniformly from [3, blur_limit].

Notes

Even draws are forced to the next odd integer so the median window is centred on each output pixel.

Dunder methods

1