Image Processing#
- vampires_dpp.image_processing.adaptive_sigma_clip_mask(data, sigma=10, boxsize=8)#
Compute a sigma-clip bad pixel mask using non-overlapping local blocks.
- Parameters:
data (NDArray) – 2D image
sigma (float) – Sigma threshold for clipping
boxsize (int) – Size of the local block for computing statistics
- Returns:
Boolean mask, True where pixels are clipped
- Return type:
NDArray
- 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)#
Derotate a cube clockwise frame-by-frame with the corresponding 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)#
Rotate 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)#
Translate each frame in a cube using vectorized Fourier-domain shifting.
Processes the entire cube in a single FFT call with no Python loop. NaN values are filled per-frame before the FFT and the NaN boundary is restored by shifting the NaN mask through the same transform.
- Parameters:
cube (ArrayLike) – 3D cube (nframes, ny, nx)
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)#
Shift a single frame by the given offset using Fourier-domain shifting.
Supports sub-pixel shifts. Uses periodic boundary conditions. NaN values are filled before the FFT and the NaN boundary is restored by shifting the NaN mask through the same transform.
- Parameters:
data (ArrayLike) – 2D frame to shift
shift (tuple[float, float]) – Shift (dy, dx) in pixels
- Returns:
Shifted frame
- Return type:
NDArray
- vampires_dpp.image_processing.warp_frame(data, matrix, antialias=False, **kwargs)#
Geometric frame warping using Lanczos4 interpolation with NaN padding by default.
- Parameters:
data (ArrayLike) – 2D image
matrix (ArrayLike) – Geometric transformation matrix
antialias (bool) – Apply Gaussian blur before warping to reduce aliasing when downsampling.
**kwargs – Keyword arguments passed to opencv (e.g. borderValue, borderMode).
- Returns:
Warped frame
- Return type:
NDArray