neutompy.postproc.crop

neutompy.postproc.crop.get_circular_mask(nrow, ncol, radius=None, center=None)[source]

This function returns a boolean 2D array representing a circular mask. The values outside the circle are False, while the inner values are True.

Parameters:
  • nrow (int) – The number of rows of the mask array.
  • ncol (int) – The number of columns of the mask array.
  • radius (float, optional) – The radius of the circle in pixel. The default value is 0.5 * min(number of rows,number of columns)
  • center (tuple of float, optional (yc, xc)) – A tuple representing the coordinates of the center of the circle, i.e.: (yc, xc). The default value is the center of the input image.
Returns:

mask (2d array) – A boolean array that represents the circular mask. The values outside the circle are False, while the inner values are True.

neutompy.postproc.crop.circular_crop(img, axis=0, radius=None, center=None, cval=0)[source]

This function performs a circular crop of an image. The values outside the circle are replaced with the value cval (default cval=0).

Parameters:
  • img (2d array) – The array representing the image to crop.
  • radius (float, optional) – The radius of the circle. The default value is 0.5 * min(number of rows,number of columns)
  • center (tuple of float, optional (yc, xc)) – A tuple representing the coordinates of the center of the circle, i.e.: (yc, xc). The default value is the center of the input image.
  • cval (float, optional) – The value used to fill the region outside the circle.
Returns:

out (2d array) – The cropped image.