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 the
heightdimension 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 the
widthdimension 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(default:None) Size of the crop as
(height, width). If a singleint, the crop will be a square.- library_id
str|None(default:None) Name of the Z-dimension to be cropped. If None, all Z-dimensions are cropped.
- scale
float(default:1.0) Rescale the crop using
skimage.transform.rescale().- cval
int|float(default:0) Fill value to use if
mask_circle = Trueor if crop goes out of the image boundary.- mask_circle
bool(default:False) Whether to mask out values that are not within a circle defined by this crop. Only available if
sizedefines a square.- preserve_dtypes
bool(default:True) Whether to preserver the data types of underlying
xarray.DataArray, even ifcvalis of different type.
- y
- Returns:
ImageContainer– The cropped image of sizesize * 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.