Skip to content
class

Defocus

extendsPhotometricTransform[RadiusParam]
Defocus(radius: tuple[int, int] = (3, 10), p: float = 0.5)

Disk-kernel (out-of-focus) blur (Albumentations Defocus).

Samples an integer radius r from radius (inclusive) and convolves with a normalised disk of radius r — pixels inside the disk get weight 1 / area, those outside get zero. Approximates the bokeh circle of an out-of-focus lens better than Gaussian blur.

Parameters

radius(int, int)= (3, 10)
Inclusive sampling range for the disk radius in pixels. Larger radii produce more aggressive defocus.
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.Defocus(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__(radius: tuple[int, int] = (3, 10), p: float = 0.5)

Instance methods

1
fn

make_params

→RadiusParam
make_params(img: Tensor)

Sample per-call random parameters for Defocus.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

RadiusParam

Carries radius — the disk-kernel radius in pixels drawn uniformly from the constructor's radius range.

Dunder methods

1