Single image analysis (darsia.single_image_analysis)#
Post-processing tools for physical data.
Submodules#
darsia.single_image_analysis.contouranalysis module#
Module containing analysis tools for segmented images.
This includes measuring lengths of contours, weighted sums (generalized mass analysis).
- class ContourAnalysis(verbosity=False)[source]#
Bases:
objectContour analysis object.
- contours()[source]#
Determine contour of loaded labeled image.
- Returns:
- list of contours, where each contour is given as an
array of pixels.
- Return type:
list[np.ndarray]
- fingers(direction=array([0., -1.]))[source]#
Determine local extrema of the contour, where the extremality is defined by a direction.
- Parameters:
contours (np.ndarray | None) – contours to analyze. If None, contours are determined from the mask; default is None.
direction (np.ndarray) – direction vector with orientation
- Returns:
pixels of peaks. array: pixels of valleys.
- Return type:
array
- length()[source]#
Determine length of loaded labeled image.
- Returns:
- length of the interface between values of interest and others.
Output in metric units.
- Return type:
float
- load(img, mask, roi=None, fill_holes=True)[source]#
Read labeled image and restrict to values of interest.
- Parameters:
img (Image) – labeled image.
roi (array, optional) – set of points defining a box.
values_of_interest (int, list of int, optional) – label values of interest.
fill_holes (bool) – flag controlling whether holes in labels are filles.
- load_labels(img, roi=None, values_of_interest=None, fill_holes=True)[source]#
Read labeled image and restrict to values of interest.
- Parameters:
img (Image) – labeled image.
roi (array, optional) – set of points defining a box.
values_of_interest (int, list of int, optional) – label values of interest.
fill_holes (bool) – flag controlling whether holes in labels are filles.
- plot_finger_peaks(img, peaks_pixels, roi=None, contours=None, path=None, show=True, **kwargs)[source]#
Plot peaks on top of the provided image.
- Parameters:
img (darsia.Image) – image to plot on.
peaks_pixels (np.ndarray) – pixels of peaks.
contours (list[np.ndarray], optional) – contours to plot; if None, no contours are plotted; default is None.
roi (darsia.CoordinateArray | None) – region of interest. If provided, peaks are translated to the top left corner of the ROI; default is None.
path (Path, optional) – path to save the plot; if None, no saving is performed.
show (bool) – flag controlling whether the plot is shown; default is True.
**kwargs – additional keyword arguments for plotting. - color (str): color for the peaks; default is “r”. - size (int): size for the peaks; default is 20.
- verbosity#
Vebosity flag.
- class PathUnit(time, peak, position)#
Bases:
tuple- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- peak#
Alias for field number 1
- position#
Alias for field number 2
- time#
Alias for field number 0
- contour_length(img, roi=None, values_of_interest=None, fill_holes=True, verbosity=False)[source]#
Calculation of the contour length of a segmented region.
- Parameters:
img (darsia.Image) – segmented image with boolean or integer values.
roi (np.ndarray) – set of points, for which a bounding box defines a ROI.
values_of_interest (int or list of int) – only active if integer-valued image provided; defines the values of interest, i.e., which part of the image is treated as active.
fill_holes (bool) – flag controlling whether holes in the determined mask are filled before the contour length is computed; if not, holes are treated as contour; default is True.
verbosity (bool) – flag controlling whether intermediate results are plotted; default is False.
- Returns:
- contour length in metric units based on the coordinate system of the
input image.
- Return type:
float