Image Processing#

vampires_dpp.image_processing.crop_to_nans_inds(data)#

Crop numpy array to min/max indices that have finite values. In other words, trims the edges off where everything is NaN.

Return type:

ndarray[tuple[int, ...], dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

Parameters:

data (ndarray[tuple[int, ...], dtype[_ScalarType_co]])

vampires_dpp.image_processing.derotate_cube(data, angles, **kwargs)#

Derotates a cube clockwise frame-by-frame with the corresponding derotation angle vector.

Parameters:
  • data (ArrayLike) – 3D cube to derotate

  • angles (ArrayLike | float) – If a vector, will derotate each frame by the corresponding angle. If a float, will derotate each frame by the same value.

Returns:

Derotated cube

Return type:

NDArray

vampires_dpp.image_processing.derotate_frame(data, angle, center=None, **kwargs)#

Rotates a single frame clockwise by the given angle in degrees.

Parameters:
  • data (ArrayLike) – 2D frame to derotate

  • angle (float) – Angle, in degrees

  • center (Optional[list | Tuple]) – Point defining the axis of rotation. If None, will use the frame center. Default is None.

  • **kwargs – Keyword arguments are passed to warp_frame

Returns:

Derotated frame

Return type:

NDArray

vampires_dpp.image_processing.shift_cube(cube, shifts, **kwargs)#

Translate each frame in a cube.

Parameters:
  • cube (ArrayLike) – 3D cube

  • shifts (ArrayLike) – Array of (dy, dx) pairs, one for each frame in the input cube

Returns:

Shifted cube

Return type:

NDArray

vampires_dpp.image_processing.shift_frame(data, shift, **kwargs)#

Shifts a single frame by the given offset

Parameters:
  • data (ArrayLike) – 2D frame to shift

  • shift (list | Tuple) – Shift (dy, dx) in pixels

  • **kwargs – Keyword arguments are passed to warp_frame

Returns:

Shifted frame

Return type:

NDArray

vampires_dpp.image_processing.warp_frame(data, matrix, antialias=False, **kwargs)#

Geometric frame warping. By default will use bicubic interpolation with NaN padding.

Parameters:
  • data (ArrayLike) – 2D image

  • matrix (ArrayLike) – Geometric transformation matrix

  • **kwargs – Keyword arguments are passed to opencv. Important keywords like borderValue, borderMode, and flags can customize the padding and interpolation behavior of the transformation.

  • antialias (bool)

Returns:

Warped frame

Return type:

NDArray