darsia.ContourAnalysis#
- class ContourAnalysis(verbosity=False, contour_smoother=None, reduce_to_main_contour=False)[source]#
Bases:
objectContour analysis object.
Constructor.
- Parameters:
- verbositybool
Verbosity flag.
Methods
contours()Determine contour of loaded labeled image.
length()Determine length of loaded labeled image.
load(img, mask[, roi, fill_holes])Read labeled image and restrict to values of interest.
local_extrema([direction, contours])Determine local extrema of the contour, where the extremality is defined by a direction.
Determine number of peaks.
Determine number of valleys.
plot_peaks(img, peaks_pixels[, roi, ...])Plot peaks on top of the provided image.
plot_valleys(img, valleys_pixels[, roi, ...])Plot valleys on top of the provided image.
Attributes
Vebosity flag.
Optional contour smoother for the contours determined from the mask.
Whether to reduce to main contour.
- contours()[source]#
Determine contour of loaded labeled image.
- Returns:
list[np.ndarray]List of contours, where each contour is given as an array of pixels.
- length()[source]#
Determine length of loaded labeled image.
- Returns:
floatLength of the interface between values of interest and others. Output in metric units.
- load(img, mask, roi=None, fill_holes=False)[source]#
Read labeled image and restrict to values of interest.
- local_extrema(direction=array([0., -1.]), contours=None)[source]#
Determine local extrema of the contour, where the extremality is defined by a direction.
- Parameters:
- direction
np.ndarray Direction vector with orientation. # TODO do not allow for contours as input, make Contour analysis. Provide # possiblility to use contour as input in a different way.
- contours
np.ndarray|None Contours to analyze. If None, contours are determined from the mask; default is None.
- direction
- Returns:
- plot_peaks(img, peaks_pixels, roi=None, contours=None, path=None, show=True, dpi=1000, **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.
- roi
darsia.CoordinateArray|None Region of interest. If provided, peaks are translated to the top left corner of the ROI; default is None.
- contours
list[np.ndarray],optional Contours to plot; if None, no contours are plotted; default is None.
- path
Path,optional Path to save the plot; if None, no saving is performed.
- showbool
Flag controlling whether the plot is shown; default is True.
- dpi
int Dots per inch for the saved plot; default is 1000.
- **kwargs
Additional keyword arguments for plotting. - color (str): color for the peaks; default is “r”. - size (int): size for the peaks; default is 20.
- img
- plot_valleys(img, valleys_pixels, roi=None, contours=None, path=None, show=True, dpi=1000, **kwargs)[source]#
Plot valleys on top of the provided image.
- Parameters:
- img
darsia.Image Image to plot on.
- valleys_pixels
np.ndarray Pixels of valleys.
- roi
darsia.CoordinateArray|None Region of interest. If provided, valleys are translated to the top left corner of the ROI; default is None.
- contours
list[np.ndarray],optional Contours to plot; if None, no contours are plotted; default is None.
- path
Path,optional Path to save the plot; if None, no saving is performed.
- showbool
Flag controlling whether the plot is shown; default is True.
- dpi
int Dots per inch for the saved plot; default is 1000.
- **kwargs
Additional keyword arguments for plotting. - valley_color (str): color for valley lines; default is “c”. - valley_linewidth (float): line width for valley lines; default is 1. - y_min (float): lower y-limit for valley lines; default is top of ROI. - y_max (float): upper y-limit for valley lines; default is bottom of ROI. - plot_valley_dots (bool): if True, valley dots are added; default is False. - valley_dot_color (str): color for valley dots; default is valley_color. - valley_dot_size (float): dot size for valley dots; default is 20.
- img
- contour_smoother#
Optional contour smoother for the contours determined from the mask.
- reduce_to_main_contour#
Whether to reduce to main contour.
- verbosity#
Vebosity flag.