squidpy.im.ImageContainer.crop_corner
- ImageContainer.crop_corner(y, x, size=None, library_id=None, scale=1.0, cval=0, mask_circle=False, preserve_dtypes=True)[source]
Extract a crop from the upper-left corner.
- Parameters:
y (
int|float) – Coordinate of the crop along theheightdimension in the pixel space. If afloat, it specifies the relative position and must be in [0, 1].x (
int|float) – Coordinate of the crop along thewidthdimension in the pixel space. If afloat, it specifies the relative position and must be in [0, 1].size (
int|float|tuple[int|float,int|float] |None) – Size of the crop as(height, width). If a singleint, the crop will be a square.library_id (
str|None) – Name of the Z-dimension to be cropped. If None, all Z-dimensions are cropped.scale (
float) – Rescale the crop usingskimage.transform.rescale().cval (
int|float) – Fill value to use ifmask_circle = Trueor if crop goes out of the image boundary.mask_circle (
bool) – Whether to mask out values that are not within a circle defined by this crop. Only available ifsizedefines a square.preserve_dtypes (
bool) – Whether to preserver the data types of underlyingxarray.DataArray, even ifcvalis of different type.
- Return type:
- Returns:
The cropped image of size
size * scale.- Raises:
ValueError – If the crop would completely lie outside of the image or if
mask_circle = Trueandsizedoes not define a square.
Notes
If
preserve_dtypes = Truebutcvalcannot be safely cast,cvalwill be set to 0.