class
LongestMaxSize
extends
_MaxSizeResizeLongestMaxSize(max_size: int, interpolation: int | str | Interpolation = 1, p: float = 1.0)Scale so the longer side equals max_size (Albumentations LongestMaxSize).
Computes the scale factor max_size / max(H, W) and applies it
to both axes — the aspect ratio is preserved and the shorter side
ends up at most as large as max_size. Image uses
interpolation, masks use nearest.
Parameters
max_sizeintTarget length of the longer side after resize.
Image resampling mode (OpenCV codes accepted).
pfloat= 1.0Probability of applying the transform.
Examples
>>> import lucid, lucid.utils.transforms as T
>>> tf = T.LongestMaxSize(16, p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)
The aspect ratio is kept, so a non-square image comes back with
its longest side at the limit and the other one shorter.