module

imea.extract

imea core functions to extract 2D and/or 3D shape measurements from images.

Functions
  • shape_measurements_2d(bw, spatial_resolution_xy, dalpha, return_statistical_lengths, return_all_chords) (tuple) Extract 2D rotation and translation invariant shape measurements from a binary image.
  • shape_measurements_3d(img_3d, threshold_mm, spatial_resolution_xy, spatial_resolution_z, dalpha, min_object_area, n_objects_max) (tuple) Extract 2D and 3D rotation and translation invariant shape measurements from a 3d grayscale image.
function

imea.extract.shape_measurements_3d(img_3d, threshold_mm, spatial_resolution_xy, spatial_resolution_z, dalpha=9, min_object_area=10, n_objects_max=-1)

Extract 2D and 3D rotation and translation invariant shape measurements from a 3d grayscale image.

Parameters
  • img_3d (numpy.ndarray, type float) 3d image in grayscale representation (background is zero, grayvalues represent height).
  • threshold_mm (float) Threshold in millimeters for segmentation of img_3d. Pixels <= threshold are considered as background, pixels > threshold_mm as object (foreground).
  • spatial_resolution_xy (float) Spatial resolution of img_3d in x and y direction in [mm/pixel]. Assumes image is already calibrated, i.e. dx = dy, see Notes.
  • spatial_resolution_z (float) Spatial resolution of img_3d in z-direction (height) in [mm/grayvalue].
  • dalpha (float, optional) Angle in degrees by which object is rotated at each iteration, (e. g. for statistical length), by default 9.
  • min_object_area (int, optional) Minimum area in pixels of a region to be considered as an object, by default 10.
  • n_objects_max (int, optional) Maximum number of objects to be extracted. If n_objects_max=-1, then all objects are extracted, by default -1.
Returns (tuple)
  • df_2d (pandas.DataFrame): Pandas dataframe including all 2D shape measurements currently supported by imea objects are represented row-wise, shape measurements area returned column-wise.
  • df_3d (pandas.DataFrame): Pandas dataframe including all 3D shape measurements currently supported by imea objects are represented row-wise, shape measurements area returned column-wise.

Notes

You might want to use skimage.transform.rescale before calling this function if your image is not already calibrated, i. e. dx != dy.

function

imea.extract.shape_measurements_2d(bw, spatial_resolution_xy=1, dalpha=9, return_statistical_lengths=False, return_all_chords=False)

Extract 2D rotation and translation invariant shape measurements from a binary image.

Parameters
  • bw (numpy.ndarray, type bool) 2-dimensional binary image.
  • spatial_resolution_xy (float, optional) Spatial resolution of image in [mm/pixel] to return values in metric values [mm]. If spatial_resolution_xy is 1 measurements are returned in [pixels], by default 1.
  • dalpha (int, optional) Angle in degrees [°] to rotate bw at each iteration. Should be a fraction of 180° (180°/n), where n is a natural number, by default 9.
  • return_statistical_lengths (bool, optional) If True, original statistical lengths distributions are returned, by default False.
  • return_all_chords (bool, optional) If True, an array with all found chords are returned, by default False.
Returns (tuple)
  • df_2d (pandas.DataFrame): Pandas dataframe including all 2D shape measurements currently supported by imea objects are represented row-wise, shape measurements area returned column-wise.
  • statistical_lengths (list, optional): List of n pandas.DataFrames, where each dataframe includes statistical lengths (columns) for all iterated angles (0° : dalpha : 180°). Only provided if return_statistical_lengths is True.
  • all_chords (numpy.ndarray, optional): 1-dimensional array with all found chords for all angles. Only provided if return_all_chords is True.