class
CenterCrop
extends
_NoParamsGeometricTransform[Empty]CenterCrop(height: int, width: int, offset: Literal['round', 'floor'] = 'round', p: float = 1.0)Crop a centred height x width window (Albumentations CenterCrop).
Computes a deterministic crop centred on the input — top-left at
(round((H - height) / 2), round((W - width) / 2)) — and applies the same
offsets to mask / boxes / keypoints so every target stays aligned.
Parameters
heightintTarget crop height in pixels.
widthintTarget crop width in pixels.
offset(round, floor)= "round"Where the window sits when the margin is odd.
"round" is
the default and matches Albumentations and the reference vision
package; "floor" matches Hugging Face's fast processors, and
a checkpoint published through one expects that placement.pfloat= 1.0Probability of applying the transform.
Examples
>>> import lucid, lucid.utils.transforms as T
>>> tf = T.CenterCrop(16, 16, p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)