Differentiate#
The splineops.differentiate.differentials
class implements a suite of functions to compute image differentials using cubic B‑spline interpolation, including:
Gradient Magnitude – the rate of intensity change.
Gradient Direction – the orientation of maximum change.
Laplacian – the sum of second-order derivatives.
Largest Hessian Eigenvalue – the maximal curvature.
Smallest Hessian Eigenvalue – the minimal curvature.
Hessian Orientation – the principal direction of curvature.
- class splineops.differentiate.differentials.differentials(image)#
Bases:
object
Class for computing image differentials using cubic B-spline interpolation.
This class provides methods to compute first- and second-order derivatives of a grayscale image by reconstructing the image as a continuous function using cubic B-spline interpolation. Supported operations include gradient magnitude, gradient direction, Laplacian, largest and smallest Hessian eigenvalues, and Hessian orientation.
- __init__(image)#
Initialize a new differentials instance.
- Parameters:
image (ndarray) – Input grayscale image as a 2D numpy array.
- run(operation=None)#
Execute the selected differential operation on the image.
- Parameters:
operation (int, optional) – Operation to perform. If None, the default operation (Laplacian) is used.
- get_cross_hessian(image, tolerance)#
Compute the cross (mixed) Hessian term of the image.
- Parameters:
image (ndarray) – Input image array.
tolerance (float) – Tolerance parameter for spline coefficient computation.
- Returns:
Element-wise cross hessian.
- Return type:
ndarray
- get_horizontal_gradient(image, tolerance)#
Compute the horizontal gradient of the image.
- Parameters:
image (ndarray) – Input image array.
tolerance (float) – Tolerance parameter for spline coefficient computation.
- Returns:
Horizontal gradient of the image.
- Return type:
ndarray
- get_horizontal_hessian(image, tolerance)#
Compute the horizontal second derivative (Hessian) of the image.
- Parameters:
image (ndarray) – Input image array.
tolerance (float) – Tolerance parameter for spline coefficient computation.
- Returns:
Horizontal Hessian of the image.
- Return type:
ndarray
- get_vertical_gradient(image, tolerance)#
Compute the vertical gradient of the image.
- Parameters:
image (ndarray) – Input image array.
tolerance (float) – Tolerance parameter for spline coefficient computation.
- Returns:
Vertical gradient of the image.
- Return type:
ndarray
- get_vertical_hessian(image, tolerance)#
Compute the vertical second derivative (Hessian) of the image.
- Parameters:
image (ndarray) – Input image array.
tolerance (float) – Tolerance parameter for spline coefficient computation.
- Returns:
Vertical Hessian of the image.
- Return type:
ndarray
- anti_symmetric_fir_mirror_on_bounds(h, c)#
Apply an anti-symmetric FIR filter with mirror boundary extension.
- Parameters:
h (ndarray) – Filter coefficients (expected length 2, with h[0] == 0.0).
c (ndarray) – Signal (or coefficient array) to be filtered.
- Returns:
Filtered signal.
- Return type:
ndarray
- symmetric_fir_mirror_on_bounds(h, c)#
Apply a symmetric FIR filter with mirror boundary extension.
- Parameters:
h (ndarray) – Filter coefficients (expected length 2).
c (ndarray) – Signal (or coefficient array) to be filtered.
- Returns:
Filtered signal.
- Return type:
ndarray
- get_gradient(c)#
Compute the first derivative (gradient) of a 1D signal using an anti-symmetric filter.
- Parameters:
c (ndarray) – 1D array of spline coefficients.
- Returns:
Computed gradient of the input signal.
- Return type:
ndarray
- get_hessian(c)#
Compute the second derivative (Hessian) of a 1D signal using a symmetric filter.
- Parameters:
c (ndarray) – 1D array of spline coefficients.
- Returns:
Computed Hessian of the input signal.
- Return type:
ndarray
- get_spline_interpolation_coefficients(c, tolerance)#
Compute the cubic B-spline interpolation coefficients for a 1D signal.
This method adjusts the input signal c in place using a recursive scheme based on a cubic B-spline and a specified tolerance.
- Parameters:
c (ndarray) – 1D array representing the signal to be interpolated.
tolerance (float) – Tolerance parameter controlling the trade-off between speed and accuracy.
- get_initial_causal_coefficient_mirror_on_bounds(c, z, tolerance)#
Compute the initial causal coefficient for spline interpolation with mirror boundary conditions.
- get_initial_anti_causal_coefficient_mirror_on_bounds(c, z, tolerance)#
Compute the initial anti-causal coefficient for spline interpolation with mirror boundary conditions.
- gradient_magnitude()#
Compute the gradient magnitude of the image.
- Returns:
Image representing the gradient magnitude.
- Return type:
ndarray
- gradient_direction()#
Compute the gradient direction of the image.
- Returns:
Image representing the gradient direction (in radians).
- Return type:
ndarray
- laplacian()#
Compute the Laplacian of the image.
- Returns:
Image representing the Laplacian.
- Return type:
ndarray
- largest_hessian()#
Compute the largest eigenvalue of the Hessian matrix of the image.
- Returns:
Image representing the largest Hessian eigenvalue.
- Return type:
ndarray
- smallest_hessian()#
Compute the smallest eigenvalue of the Hessian matrix of the image.
- Returns:
Image representing the smallest Hessian eigenvalue.
- Return type:
ndarray
- hessian_orientation()#
Compute the orientation of the Hessian of the image.
- Returns:
Image representing the Hessian orientation (in radians).
- Return type:
ndarray