Algorithms (cdl.algorithms
)#
This package contains the algorithms used by the DataLab project. Those algorithms operate directly on NumPy arrays and are designed to be used in the DataLab pipeline, but can be used independently as well.
See also
The cdl.algorithms
package is the main entry point for the DataLab
algorithms when manipulating NumPy arrays. See the cdl.computation
package for algorithms that operate directly on DataLab objects (i.e.
cdl.obj.SignalObj
and cdl.obj.ImageObj
).
The algorithms are organized in subpackages according to their purpose. The following subpackages are available:
cdl.algorithms.signal
: Signal processing algorithmscdl.algorithms.image
: Image processing algorithmscdl.algorithms.datatypes
: Data type conversion algorithmscdl.algorithms.coordinates
: Coordinate conversion algorithms
Signal Processing Algorithms#
- cdl.algorithms.signal.normalize(yin: ndarray, parameter: Literal['maximum', 'amplitude', 'area', 'energy', 'rms'] = 'maximum') ndarray [source]#
Normalize input array to a given parameter.
- Parameters:
yin β Input array
parameter β Normalization parameter. Defaults to βmaximumβ
- Returns:
Normalized array
- cdl.algorithms.signal.fft1d(x: ndarray, y: ndarray, shift: bool = True) tuple[ndarray, ndarray] [source]#
Compute FFT on X,Y data.
- Parameters:
x β X data
y β Y data
shift β Shift the zero frequency to the center of the spectrum. Defaults to True.
- Returns:
X data, Y data (tuple)
- cdl.algorithms.signal.ifft1d(x: ndarray, y: ndarray, shift: bool = True) tuple[ndarray, ndarray] [source]#
Compute iFFT on X,Y data.
- Parameters:
x β X data
y β Y data
shift β Shift the zero frequency to the center of the spectrum. Defaults to True.
- Returns:
X data, Y data (tuple)
- cdl.algorithms.signal.magnitude_spectrum(x: ndarray, y: ndarray, log_scale: bool = False) tuple[ndarray, ndarray] [source]#
Compute magnitude spectrum.
- Parameters:
x β X data
y β Y data
log_scale β Use log scale. Defaults to False.
- Returns:
Magnitude spectrum (X data, Y data)
- cdl.algorithms.signal.phase_spectrum(x: ndarray, y: ndarray) tuple[ndarray, ndarray] [source]#
Compute phase spectrum.
- Parameters:
x β X data
y β Y data
- Returns:
Phase spectrum in degrees (X data, Y data)
- cdl.algorithms.signal.psd(x: ndarray, y: ndarray, log_scale: bool = False) tuple[ndarray, ndarray] [source]#
Compute Power Spectral Density (PSD), using the Welch method.
- Parameters:
x β X data
y β Y data
log_scale β Use log scale. Defaults to False.
- Returns:
X data, Y data (tuple)
- Return type:
Power Spectral Density (PSD)
- cdl.algorithms.signal.sort_frequencies(x: ndarray, y: ndarray) ndarray [source]#
Sort from X,Y data by computing FFT(y).
- Parameters:
x β X data
y β Y data
- Returns:
Sorted frequencies in ascending order
- cdl.algorithms.signal.peak_indexes(y, thres: float = 0.3, min_dist: int = 1, thres_abs: bool = False) ndarray [source]#
Peak detection routine.
Finds the numeric index of the peaks in y by taking its first order difference. By using thres and min_dist parameters, it is possible to reduce the number of detected peaks. y must be signed.
- Parameters:
y (ndarray (signed)) β 1D amplitude data to search for peaks.
thres (float between [0., 1.]) β Normalized threshold. Only the peaks with amplitude higher than the threshold will be detected.
min_dist (int) β Minimum distance between each detected peak. The peak with the highest amplitude is preferred to satisfy this constraint.
thres_abs (boolean) β If True, the thres value will be interpreted as an absolute value, instead of a normalized threshold.
- Returns:
Array containing the numeric indexes of the peaks that were detected
- Return type:
ndarray
- cdl.algorithms.signal.xpeak(x: ndarray, y: ndarray) float [source]#
Return default peak X-position (assuming a single peak).
- Parameters:
x β X data
y β Y data
- Returns:
Peak X-position
- cdl.algorithms.signal.interpolate(x: ndarray, y: ndarray, xnew: ndarray, method: Literal['linear', 'spline', 'quadratic', 'cubic', 'barycentric', 'pchip'], fill_value: float | None = None) ndarray [source]#
Interpolate data.
- Parameters:
x β X data
y β Y data
xnew β New X data
method β Interpolation method
fill_value β Fill value. Defaults to None. This value is used to fill in for requested points outside of the X data range. It is only used if the method argument is βlinearβ, βcubicβ or βpchipβ.
- Returns:
Interpolated Y data
- cdl.algorithms.signal.windowing(y: ndarray, method: Literal['barthann', 'bartlett', 'blackman', 'blackman-harris', 'bohman', 'boxcar', 'cosine', 'exponential', 'flat-top', 'hamming', 'hanning', 'lanczos', 'nuttall', 'parzen', 'rectangular', 'taylor', 'tukey', 'kaiser', 'gaussian'] = 'hamming', alpha: float = 0.5, beta: float = 14.0, sigma: float = 7.0) ndarray [source]#
Apply windowing to the input data.
- Parameters:
x β X data
y β Y data
method β Windowing function. Defaults to βhammingβ.
alpha β Tukey window parameter. Defaults to 0.5.
beta β Kaiser window parameter. Defaults to 14.0.
sigma β Gaussian window parameter. Defaults to 7.0.
- Returns:
Windowed Y data
- class cdl.algorithms.signal.FitModel[source]#
Curve fitting model base class
- class cdl.algorithms.signal.GaussianModel[source]#
1-dimensional Gaussian fit model
- class cdl.algorithms.signal.LorentzianModel[source]#
1-dimensional Lorentzian fit model
- cdl.algorithms.signal.find_nearest_zero_point_idx(y: ndarray) ndarray [source]#
Find the x indexes where the corresponding y is the closest to zero
- Parameters:
y β Y data
- Returns:
Indexes of the points right before or at zero crossing
- cdl.algorithms.signal.find_x_at_value(x: ndarray, y: ndarray, value: float) ndarray [source]#
Find the x value where the y value is the closest to the given value using linear interpolation to deduce the precise x value.
- Parameters:
x β X data
y β Y data
value β Value to find
- Returns:
X value where the Y value is the closest to the given value
- cdl.algorithms.signal.bandwidth(data: ndarray, level: float = 3.0) float [source]#
Compute the bandwidth of the signal at a given level.
- Parameters:
data β X,Y data
level β Level in dB at which the bandwidth is computed. Defaults to 3.0.
- Returns:
segment coordinates
- Return type:
Bandwidth of the signal at the given level
- cdl.algorithms.signal.contrast(y: ndarray) float [source]#
Compute contrast
- Parameters:
y β Input array
- Returns:
Contrast
- cdl.algorithms.signal.sinusoidal_model(x: ndarray, a: float, f: float, phi: float, offset: float) ndarray [source]#
Sinusoidal model function.
- cdl.algorithms.signal.sinusoidal_fit(x: ndarray, y: ndarray) tuple[tuple[float, float, float, float], float] [source]#
Fit a sinusoidal model to the input data.
- Parameters:
x β X data
y β Y data
- Returns:
A tuple containing the fit parameters (amplitude, frequency, phase, offset) and the residuals
- cdl.algorithms.signal.sinus_frequency(x: ndarray, y: ndarray) float [source]#
Compute the frequency of a sinusoidal signal.
- Parameters:
x β x signal data
y β y signal data
- Returns:
Frequency of the sinusoidal signal
- cdl.algorithms.signal.enob(x: ndarray, y: ndarray, full_scale: float = 1.0) float [source]#
Compute Effective Number of Bits (ENOB).
- Parameters:
x β x signal data
y β y signal data
full_scale β Full scale(V). Defaults to 1.0.
- Returns:
Effective Number of Bits (ENOB)
- cdl.algorithms.signal.sinad(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc') float [source]#
Compute Signal-to-Noise and Distortion Ratio (SINAD).
- Parameters:
x β x signal data
y β y signal data
full_scale β Full scale(V). Defaults to 1.0.
unit β Unit of the input data. Valid values are βdBcβ and βdBFSβ. Defaults to βdBcβ.
- Returns:
Signal-to-Noise and Distortion Ratio (SINAD)
- cdl.algorithms.signal.thd(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc', nb_harm: int = 5) float [source]#
Compute Total Harmonic Distortion (THD).
- Parameters:
x β x signal data
y β y signal data
full_scale β Full scale(V). Defaults to 1.0.
unit β Unit of the input data. Valid values are βdBcβ and βdBFSβ. Defaults to βdBcβ.
nb_harm β Number of harmonics to consider. Defaults to 5.
- Returns:
Total Harmonic Distortion (THD)
- cdl.algorithms.signal.sfdr(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc') float [source]#
Compute Spurious-Free Dynamic Range (SFDR).
- Parameters:
x β x signal data
y β y signal data
full_scale β Full scale(V). Defaults to 1.0.
unit β Unit of the input data. Valid values are βdBcβ and βdBFSβ. Defaults to βdBcβ.
- Returns:
Spurious-Free Dynamic Range (SFDR)
- cdl.algorithms.signal.snr(x: ndarray, y: ndarray, full_scale: float = 1.0, unit: Literal['dBc', 'dBFS'] = 'dBc') float [source]#
Compute Signal-to-Noise Ratio (SNR).
- Parameters:
x β x signal data
y β y signal data
full_scale β Full scale(V). Defaults to 1.0.
unit β Unit of the input data. Valid values are βdBcβ and βdBFSβ. Defaults to βdBcβ.
- Returns:
Signal-to-Noise Ratio (SNR)
- cdl.algorithms.signal.sampling_period(x: ndarray) float [source]#
Compute sampling period
- Parameters:
x β X data
- Returns:
Sampling period
- cdl.algorithms.signal.sampling_rate(x: ndarray) float [source]#
Compute mean sampling rate
- Parameters:
x β X data
- Returns:
Sampling rate
- cdl.algorithms.signal.fwhm(data: ndarray, method: Literal['zero-crossing', 'gauss', 'lorentz', 'voigt'] = 'zero-crossing', xmin: float | None = None, xmax: float | None = None) tuple[float, float, float, float] [source]#
Compute Full Width at Half Maximum (FWHM) of the input data
- Parameters:
data β X,Y data
method β Calculation method. Two types of methods are supported: a zero-crossing method and fitting methods (based on various models: Gauss, Lorentz, Voigt). Defaults to βzero-crossingβ.
xmin β Lower X bound for the fitting. Defaults to None (no lower bound, i.e. the fitting starts from the first point).
xmax β Upper X bound for the fitting. Defaults to None (no upper bound, i.e. the fitting ends at the last point)
- Returns:
FWHM segment coordinates
Image Processing Algorithms#
- cdl.algorithms.image.scale_data_to_min_max(data: ndarray, zmin: float | int, zmax: float | int) ndarray [source]#
Scale array data to fit [zmin, zmax] dynamic range
- Parameters:
data β Input data
zmin β Minimum value of output data
zmax β Maximum value of output data
- Returns:
Scaled data
- cdl.algorithms.image.normalize(data: ndarray, parameter: Literal['maximum', 'amplitude', 'area', 'energy', 'rms'] = 'maximum') ndarray [source]#
Normalize input array to a given parameter.
- Parameters:
data β Input data
parameter β Normalization parameter (default: βmaximumβ)
- Returns:
Normalized array
- cdl.algorithms.image.fft2d(z: ndarray, shift: bool = True) ndarray [source]#
Compute FFT of complex array z
- Parameters:
z β Input data
shift β Shift zero frequency to center (default: True)
- Returns:
FFT of input data
- cdl.algorithms.image.ifft2d(z: ndarray, shift: bool = True) ndarray [source]#
Compute inverse FFT of complex array z
- Parameters:
z β Input data
shift β Shift zero frequency to center (default: True)
- Returns:
Inverse FFT of input data
- cdl.algorithms.image.magnitude_spectrum(z: ndarray, log_scale: bool = False) ndarray [source]#
Compute magnitude spectrum of complex array z
- Parameters:
z β Input data
log_scale β Use log scale (default: False)
- Returns:
Magnitude spectrum of input data
- cdl.algorithms.image.phase_spectrum(z: ndarray) ndarray [source]#
Compute phase spectrum of complex array z
- Parameters:
z β Input data
- Returns:
Phase spectrum of input data (in degrees)
- cdl.algorithms.image.psd(z: ndarray, log_scale: bool = False) ndarray [source]#
Compute power spectral density of complex array z
- Parameters:
z β Input data
log_scale β Use log scale (default: False)
- Returns:
Power spectral density of input data
- cdl.algorithms.image.binning(data: ndarray, sx: int, sy: int, operation: Literal['sum', 'average', 'median', 'min', 'max'], dtype=None) ndarray [source]#
Perform image pixel binning
- Parameters:
data β Input data
sx β Binning size along x (number of pixels to bin together)
sy β Binning size along y (number of pixels to bin together)
operation β Binning operation
dtype β Output data type (default: None, i.e. same as input)
- Returns:
Binned data
- cdl.algorithms.image.flatfield(rawdata: ndarray, flatdata: ndarray, threshold: float | None = None) ndarray [source]#
Compute flat-field correction
- Parameters:
rawdata β Raw data
flatdata β Flat-field data
threshold β Threshold for flat-field correction (default: None)
- Returns:
Flat-field corrected data
- cdl.algorithms.image.get_centroid_fourier(data: ndarray) tuple[float, float] [source]#
Return image centroid using Fourier algorithm
- Parameters:
data β Input data
- Returns:
Centroid coordinates (row, col)
- cdl.algorithms.image.get_absolute_level(data: ndarray, level: float) float [source]#
Return absolute level
- Parameters:
data β Input data
level β Relative level (0.0 to 1.0)
- Returns:
Absolute level
- cdl.algorithms.image.get_enclosing_circle(data: ndarray, level: float = 0.5) tuple[int, int, float] [source]#
Return (x, y, radius) for the circle contour enclosing image values above threshold relative level (.5 means FWHM)
- Parameters:
data β Input data
level β Relative level (default: 0.5)
- Returns:
A tuple (x, y, radius)
- Raises:
ValueError β No contour was found
- cdl.algorithms.image.get_radial_profile(data: ndarray, center: tuple[int, int]) tuple[ndarray, ndarray] [source]#
Return radial profile of image data
- Parameters:
data β Input data (2D array)
center β Coordinates of the center of the profile (x, y)
- Returns:
Radial profile (X, Y) where X is the distance from the center (1D array) and Y is the average value of pixels at this distance (1D array)
- cdl.algorithms.image.distance_matrix(coords: list) ndarray [source]#
Return distance matrix from coords
- Parameters:
coords β List of coordinates
- Returns:
Distance matrix
- cdl.algorithms.image.get_2d_peaks_coords(data: ndarray, size: int | None = None, level: float = 0.5) ndarray [source]#
Detect peaks in image data, return coordinates.
If neighborhoods size is None, default value is the highest value between 50 pixels and the 1/40th of the smallest image dimension.
Detection threshold level is relative to difference between data maximum and minimum values.
- Parameters:
data β Input data
size β Neighborhood size (default: None)
level β Relative level (default: 0.5)
- Returns:
Coordinates of peaks
- cdl.algorithms.image.get_contour_shapes(data: ndarray | MaskedArray, shape: Literal['circle', 'ellipse', 'polygon'] = 'ellipse', level: float = 0.5) ndarray [source]#
Find iso-valued contours in a 2D array, above relative level (.5 means FWHM), then fit contours with shape (βellipseβ or βcircleβ)
- Parameters:
data β Input data
shape β Shape to fit. Default is βellipseβ
level β Relative level (default: 0.5)
- Returns:
Coordinates of shapes
- cdl.algorithms.image.get_hough_circle_peaks(data: ndarray, min_radius: float | None = None, max_radius: float | None = None, nb_radius: int | None = None, min_distance: int = 1) ndarray [source]#
Detect peaks in image from circle Hough transform, return circle coordinates.
- Parameters:
data β Input data
min_radius β Minimum radius (default: None)
max_radius β Maximum radius (default: None)
nb_radius β Number of radii (default: None)
min_distance β Minimum distance between circles (default: 1)
- Returns:
Coordinates of circles
- cdl.algorithms.image.find_blobs_dog(data: ndarray, min_sigma: float = 1, max_sigma: float = 30, overlap: float = 0.5, threshold_rel: float = 0.2, exclude_border: bool = True) ndarray [source]#
Finds blobs in the given grayscale image using the Difference of Gaussians (DoG) method.
- Parameters:
data β The grayscale input image.
min_sigma β The minimum blob radius in pixels.
max_sigma β The maximum blob radius in pixels.
overlap β The minimum overlap between two blobs in pixels. For instance, if two blobs are detected with radii of 10 and 12 respectively, and the
overlap
is set to 0.5, then the area of the smaller blob will be ignored and only the area of the larger blob will be returned.threshold_rel β The absolute lower bound for scale space maxima. Local maxima smaller than
threshold_rel
are ignored. Reduce this to detect blobs with less intensities.exclude_border β If
True
, exclude blobs from detection if they are too close to the border of the image. Border size ismin_sigma
.
- Returns:
Coordinates of blobs
- cdl.algorithms.image.find_blobs_doh(data: ndarray, min_sigma: float = 1, max_sigma: float = 30, overlap: float = 0.5, log_scale: bool = False, threshold_rel: float = 0.2) ndarray [source]#
Finds blobs in the given grayscale image using the Determinant of Hessian (DoH) method.
- Parameters:
data β The grayscale input image.
min_sigma β The minimum blob radius in pixels.
max_sigma β The maximum blob radius in pixels.
overlap β The minimum overlap between two blobs in pixels. For instance, if two blobs are detected with radii of 10 and 12 respectively, and the
overlap
is set to 0.5, then the area of the smaller blob will be ignored and only the area of the larger blob will be returned.log_scale β If
True
, the radius of each blob is returned assqrt(sigma)
for each detected blob.threshold_rel β The absolute lower bound for scale space maxima. Local maxima smaller than
threshold_rel
are ignored. Reduce this to detect blobs with less intensities.
- Returns:
Coordinates of blobs
- cdl.algorithms.image.find_blobs_log(data: ndarray, min_sigma: float = 1, max_sigma: float = 30, overlap: float = 0.5, log_scale: bool = False, threshold_rel: float = 0.2, exclude_border: bool = True) ndarray [source]#
Finds blobs in the given grayscale image using the Laplacian of Gaussian (LoG) method.
- Parameters:
data β The grayscale input image.
min_sigma β The minimum blob radius in pixels.
max_sigma β The maximum blob radius in pixels.
overlap β The minimum overlap between two blobs in pixels. For instance, if two blobs are detected with radii of 10 and 12 respectively, and the
overlap
is set to 0.5, then the area of the smaller blob will be ignored and only the area of the larger blob will be returned.log_scale β If
True
, the radius of each blob is returned assqrt(sigma)
for each detected blob.threshold_rel β The absolute lower bound for scale space maxima. Local maxima smaller than
threshold_rel
are ignored. Reduce this to detect blobs with less intensities.exclude_border β If
True
, exclude blobs from detection if they are too close to the border of the image. Border size ismin_sigma
.
- Returns:
Coordinates of blobs
- cdl.algorithms.image.remove_overlapping_disks(coords: ndarray) ndarray [source]#
Remove overlapping disks among coordinates
- Parameters:
coords β The coordinates of the disks
- Returns:
The coordinates of the disks with overlapping disks removed
- cdl.algorithms.image.find_blobs_opencv(data: ndarray, min_threshold: float | None = None, max_threshold: float | None = None, min_repeatability: int | None = None, min_dist_between_blobs: float | None = None, filter_by_color: bool | None = None, blob_color: int | None = None, filter_by_area: bool | None = None, min_area: float | None = None, max_area: float | None = None, filter_by_circularity: bool | None = None, min_circularity: float | None = None, max_circularity: float | None = None, filter_by_inertia: bool | None = None, min_inertia_ratio: float | None = None, max_inertia_ratio: float | None = None, filter_by_convexity: bool | None = None, min_convexity: float | None = None, max_convexity: float | None = None) ndarray [source]#
Finds blobs in the given grayscale image using OpenCVβs SimpleBlobDetector.
- Parameters:
data β The grayscale input image.
min_threshold β The minimum blob intensity.
max_threshold β The maximum blob intensity.
min_repeatability β The minimum number of times a blob is detected before it is reported.
min_dist_between_blobs β The minimum distance between blobs.
filter_by_color β If
True
, blobs are filtered by color.blob_color β The color of the blobs to filter by.
filter_by_area β If
True
, blobs are filtered by area.min_area β The minimum blob area.
max_area β The maximum blob area.
filter_by_circularity β If
True
, blobs are filtered by circularity.min_circularity β The minimum blob circularity.
max_circularity β The maximum blob circularity.
filter_by_inertia β If
True
, blobs are filtered by inertia.min_inertia_ratio β The minimum blob inertia ratio.
max_inertia_ratio β The maximum blob inertia ratio.
filter_by_convexity β If
True
, blobs are filtered by convexity.min_convexity β The minimum blob convexity.
max_convexity β The maximum blob convexity.
- Returns:
Coordinates of blobs
Data Type Conversion Algorithms#
- cdl.algorithms.datatypes.is_integer_dtype(dtype: dtype) bool [source]#
Return True if data type is an integer type
- Parameters:
dtype β Data type to check
- Returns:
True if data type is an integer type
- cdl.algorithms.datatypes.is_complex_dtype(dtype: dtype) bool [source]#
Return True if data type is a complex type
- Parameters:
dtype β Data type to check
- Returns:
True if data type is a complex type
- cdl.algorithms.datatypes.clip_astype(data: ndarray, dtype: dtype) ndarray [source]#
Convert array to a new data type, after having clipped values to the new data typeβs range if it is an integer type. If data type is not integer, this is equivalent to
data.astype(dtype)
.- Parameters:
data β Array to convert
dtype β Data type to convert to
- Returns:
Array converted to new data type
Coordinate Conversion Algorithms#
- cdl.algorithms.coordinates.circle_to_diameter(xc: float, yc: float, r: float) tuple[float, float, float, float] [source]#
Convert circle center and radius to X diameter coordinates
- Parameters:
xc β Circle center X coordinate
yc β Circle center Y coordinate
r β Circle radius
- Returns:
Circle X diameter coordinates
- Return type:
- cdl.algorithms.coordinates.array_circle_to_diameter(data: ndarray) ndarray [source]#
Convert circle center and radius to X diameter coordinates (array version)
- Parameters:
data β Circle center and radius, in the form of a 2D array (N, 3)
- Returns:
Circle X diameter coordinates, in the form of a 2D array (N, 4)
- cdl.algorithms.coordinates.circle_to_center_radius(x0: float, y0: float, x1: float, y1: float) tuple[float, float, float] [source]#
Convert circle X diameter coordinates to center and radius
- Parameters:
x0 β Diameter start X coordinate
y0 β Diameter start Y coordinate
x1 β Diameter end X coordinate
y1 β Diameter end Y coordinate
- Returns:
Circle center and radius
- Return type:
- cdl.algorithms.coordinates.array_circle_to_center_radius(data: ndarray) ndarray [source]#
Convert circle X diameter coordinates to center and radius (array version)
- Parameters:
data β Circle X diameter coordinates, in the form of a 2D array (N, 4)
- Returns:
Circle center and radius, in the form of a 2D array (N, 3)
- cdl.algorithms.coordinates.ellipse_to_diameters(xc: float, yc: float, a: float, b: float, theta: float) tuple[float, float, float, float, float, float, float, float] [source]#
Convert ellipse center, axes and angle to X/Y diameters coordinates
- Parameters:
xc β Ellipse center X coordinate
yc β Ellipse center Y coordinate
a β Ellipse half larger axis
b β Ellipse half smaller axis
theta β Ellipse angle
- Returns:
Ellipse X/Y diameters (major/minor axes) coordinates
- cdl.algorithms.coordinates.array_ellipse_to_diameters(data: ndarray) ndarray [source]#
Convert ellipse center, axes and angle to X/Y diameters coordinates (array version)
- Parameters:
data β Ellipse center, axes and angle, in the form of a 2D array (N, 5)
- Returns:
- Ellipse X/Y diameters (major/minor axes) coordinates,
in the form of a 2D array (N, 8)
- cdl.algorithms.coordinates.ellipse_to_center_axes_angle(x0: float, y0: float, x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) tuple[float, float, float, float, float] [source]#
Convert ellipse X/Y diameters coordinates to center, axes and angle
- Parameters:
x0 β major axis start X coordinate
y0 β major axis start Y coordinate
x1 β major axis end X coordinate
y1 β major axis end Y coordinate
x2 β minor axis start X coordinate
y2 β minor axis start Y coordinate
x3 β minor axis end X coordinate
y3 β minor axis end Y coordinate
- Returns:
Ellipse center, axes and angle
- cdl.algorithms.coordinates.array_ellipse_to_center_axes_angle(data: ndarray) ndarray [source]#
Convert ellipse X/Y diameters coordinates to center, axes and angle (array version)
- Parameters:
data β Ellipse X/Y diameters coordinates, in the form of a 2D array (N, 8)
- Returns:
Ellipse center, axes and angle, in the form of a 2D array (N, 5)