pynrc.maths.image_manip.crop_image
- pynrc.maths.image_manip.crop_image(imarr, xysub, xyloc=None, **kwargs)[source]
Crop input image around center using integer offsets only
If size is exceeded, then the image is expanded and filled with 0s by default.
- Parameters:
imarr (ndarray) – Input image or image cube [nz,ny,nx].
xysub (int, tuple, or list) – Size of subarray to extract. If a single integer is provided, then a square subarray is extracted. If a tuple or list is provided, then it should be of the form (ny, nx).
xyloc (tuple or list) – (x,y) pixel location around which to crop the image. If None, then the image center is used.
- Keyword Arguments:
delx (int or float) – Integer pixel offset in x-direction. This shifts the image by some number of pixels in the x-direction. Positive values shift the image to the right.
dely (int or float) – Integer pixel offset in y-direction. This shifts the image by some number of pixels in the y-direction. Positive values shift the image up.
shift_func (function) – Function to use for shifting. Default is fourier_imshift. If delx and dely are both integers, then fshift is used.
interp (str) – Interpolation method to use for shifting. Default is ‘cubic’. Options are ‘nearest’, ‘linear’, ‘cubic’, and ‘quadratic’ for fshift.
return_xy (bool) – If True, then return the x and y indices used to crop the image prior to any shifting from delx and dely; (x1, x2, y1, y2). Default is False.
fill_val (float) – Value to use for filling in the empty pixels after shifting. Default = 0.