Skip to content
class

Crop

extends_NoParamsGeometricTransform[Empty]
Crop(x_min: int = 0, y_min: int = 0, x_max: int = 1024, y_max: int = 1024, p: float = 1.0)

Crop a fixed region [x_min, y_min, x_max, y_max) (Albumentations Crop).

Deterministic — every call returns the same rectangle regardless of input size. Masks, boxes, and keypoints are translated in lock-step with the image (GeometricTransform contract).

Parameters

x_minint= 0
Top-left corner of the crop window (inclusive).
y_minint= 0
Top-left corner of the crop window (inclusive).
x_maxint= 1024
Bottom-right corner (exclusive).
y_maxint= 1024
Bottom-right corner (exclusive).
pfloat= 1.0
Probability of applying the crop. Below 1.0, the input passes through unchanged on 1 - p of calls.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.Crop(0, 0, 16, 16, p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)
The box is (x_min, y_min, x_max, y_max), so this takes the
top-left quarter rather than a 16-pixel margin.

Used by 2

Constructors

1
dunder

__init__

→None
__init__(x_min: int = 0, y_min: int = 0, x_max: int = 1024, y_max: int = 1024, p: float = 1.0)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1