UnsharpMask
PhotometricTransform[TripletParams]UnsharpMask(blur_limit: tuple[int, int] = (3, 7), sigma_limit: float | tuple[float, float] = 0.0, alpha: tuple[float, float] = (0.2, 0.5), threshold: float = 10.0, p: float = 0.5)Unsharp-mask sharpen via img + alpha*(img - blur) (Albumentations UnsharpMask).
Subtracts a Gaussian-blurred copy from the original and adds the
high-frequency residual back, scaled by alpha. This is the
photographic "unsharp mask" used to enhance edges without amplifying
noise as much as a raw Laplacian sharpen would. The kernel size
k and Gaussian sigma are sampled per call from
blur_limit / sigma_limit; sigma defaults to the
OpenCV-style heuristic 0.3 * ((k - 1) * 0.5 - 1.0) + 0.8 when
the sampled value is non-positive.
Parameters
blur_limit(int, int)= (3, 7)k is
sampled (snapped to the next odd integer).sigma_limitfloat or (float, float)= 0.0s is treated as (0, s); 0 falls
back to the kernel-derived heuristic above.alpha(float, float)= (0.2, 0.5)thresholdfloat= 10.0pfloat= 0.5Examples
>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.UnsharpMask(blur_limit=(3, 7), alpha=(0.2, 0.5), p=1.0)
>>> out = tf(T.Image(lucid.rand(3, 32, 32))).data
>>> tuple(out.shape)
(3, 32, 32)Used by 1
Constructors
1Instance methods
1Sample per-call random parameters for UnsharpMask.
Parameters
imgTensorReturns
TripletParamsCarries a (residual blend weight from alpha),
b (Gaussian kernel side k stored as float so the
triplet stays homogeneous), and c (Gaussian sigma).
Notes
k is forced odd via _odd. A non-positive sigma
falls back to OpenCV's kernel-derived
0.3 * ((k - 1) * 0.5 - 1.0) + 0.8 heuristic.