imea.measure_2d
2-dimensional shape measurements.
imea.measure_2d.macro
2-dimensional macrodescriptors.
area_equal_diameter
(
projection_area
)
(float) — Calculate area-equal diameter.circumscribing_and_inscribing_circle
(
centroid
,contour
)
(tuple) — Calculate circumscribing and inscribing circle of an object shape [1].convex_perimeter
(
bw_convex
)
(float) — Calculate perimeter of 2D convex hull based on an binary image of convex hull.geodeticlength_and_thickness
(
area
,perimeter
)
(tuple) — Calculate geodetic length and thickness based on area and diameter according to DIN ISO 9276-6.max_2d_dimensions
(
max_chords
,angles
)
(tuple) — Calculates the max 2d dimensions of an object shape.x_max
is the overall max chord of the object in all possible orientations.y_max
is the longest chord orthogonal tox_max
[1].max_inclosing_circle
(
bw
)
(tuple) — Calculate maximum inclosing circle of an object.min_2d_bounding_box
(
bw
)
(tuple) — Calculate minimal 2-dimensional bounding box of an binary image.min_enclosing_circle
(
contour
)
(tuple) — Calculate minimum enclosing circle of an object based on its list of coordinates.perimeter_equal_diameter
(
perimeter
)
(float) — Calculate perimeter-equal diameter.
imea.measure_2d.macro.
min_2d_bounding_box
(
bw
)
Calculate minimal 2-dimensional bounding box of an binary image.
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
length
(float): Length of minimal 2-dimensional bounding box.width
(float): Width of minimal 2-dimensional bounding box.center
(numpy.ndarray, type float): Center of 2-dimensional minimal bounding box in shape[x, y]
.cornerpoints
(numpy.ndarray, type float): 2-dimensional array of four cornerpoints of the minimal bounding box in shape[[x0, y0], [x1, y1], [x2, y2], [x3, y3]]
.
imea.measure_2d.macro.
area_equal_diameter
(
projection_area
)
Calculate area-equal diameter.
projection_area
(float) — Projection area.
area_equal_diameter
(float): 2D area-equal diameter.
imea.measure_2d.macro.
perimeter_equal_diameter
(
perimeter
)
Calculate perimeter-equal diameter.
perimeter
(float) — Perimeter.
perimeter_equal_diameter
(float): Perimeter-equal diameter.
imea.measure_2d.macro.
max_inclosing_circle
(
bw
)
Calculate maximum inclosing circle of an object.
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
center
(numpy.ndarray, type float): Center position of maximum inclosing circle in shape[x, y]
.diameter
(float): Diameter of maximum inclosing circle.
imea.measure_2d.macro.
min_enclosing_circle
(
contour
)
Calculate minimum enclosing circle of an object based on its list of coordinates.
contour
(numpy.ndarray, type int) — Array of contour points in shape[[x0, y0], [x1, y1], ...]
.
center
(numpy.ndarray, type float): Center of minimum enclosing circle.diameter
(float): Diameter of minimum enclosing circle.
imea.measure_2d.macro.
circumscribing_and_inscribing_circle
(
centroid
, contour
)
Calculate circumscribing and inscribing circle of an object shape [1].
centroid
(numpy.ndarray, type float) — Centroid of object in shape[x,y]
.contour
(numpy.ndarray, type int) — Array of contour points in shape[[x0, y0], [x1, y1], ...]
.
diameter_circumscribing_circle
(float): Diameter of circumscribing circle.diameter_inscribing_circle
(float): Diameter of inscribing circle.
[1] X. Li, Z. Wen, H. Zhu, Z. Guo and Y. Liu (2020). "An improved algorithm for evaluation of the minimum circumscribed circle and maximum inscribed circle based on the local minimax radius". In: The Review of scientific instruments 91(3), pp. 035103. DOI: https://doi.org/10.1063/5.0002233
imea.measure_2d.macro.
geodeticlength_and_thickness
(
area
, perimeter
)
Calculate geodetic length and thickness based on area and diameter according to DIN ISO 9276-6.
area
(float) — Projection area of shape.perimeter
(float) — Perimeter of shape.
geodeticlength
(float): Geodetic length of shape.thickness
(float): Thickness of shape.
Notes
Calculation according to DIN ISO 9276-6:
The geodetic lengths and thickness are approximated by an rectangle
with the same area and perimeter:
(1) area = geodeticlength * thickness
(2) perimeter = 2 * (geodetic_length + thickness)
imea.measure_2d.macro.
max_2d_dimensions
(
max_chords
, angles
)
Calculates the max 2d dimensions of an object shape.
x_max
is the overall max chord of the object in all possible orientations.
y_max
is the longest chord orthogonal to x_max
[1].
max_chords_2d
(numpy.ndarray, type float) — 1-dimensional array of max chords at different angles (angles_2d
).angles_2d
(numpy.ndarray, type float) — Respective angles to themax_chords_2d
in ascending order.
x_max
(float): Larger max dimension of object (definition see above).y_max
(float): Smaller max dimension of object (definition see above).
[1] M. Steuer (2010). "Serial classification". In: AT Mineral Processing 51(1).
imea.measure_2d.macro.
convex_perimeter
(
bw_convex
)
Calculate perimeter of 2D convex hull based on an binary image of convex hull.
bw_convex
(numpy.ndarray, type bool) — 2-dimensional binary convex image.
convex_perimeter
(float): Convex perimeter.
imea.measure_2d.meso
2-dimensional mesodescriptors.
erosions_till_erase
(
bw
,pad_width
,selem
,return_counts
)
(tuple) — Determine number of erosions that are necessary to fully erase all True elements in a binary image [1].erosions_till_erase_complement
(
bw
,bw_convex
,pad_width
,selem
,return_counts
)
(tuple) — Determine number of erosions that are necessary to erase all pixels from the complement between the binary image of an object and the binary image of its convex hull [1].
imea.measure_2d.meso.
erosions_till_erase_complement
(
bw
, bw_convex
, pad_width=1
, selem=None
, return_counts=False
)
Determine number of erosions that are necessary to erase all pixels from the complement between the binary image of an object and the binary image of its convex hull [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.bw_convex
(numpy.ndarray, type bool) — 2-dimensional binary image of convex hull corresponding tobw
.pad_width
(int, optional) — Number of false pixels to pad around the image, by default 1.selem
(numpy.ndarray, type bool, optional) — Neighborhood expressed as a 2-D array of ones and zeros, by default None. If None, use a cross-shaped structuring element (connectivity=1) is used.return_counts
(bool, optional) — If True, a list with the number of true pixels for each iteration is returned, by default False.
n_erosions_2d
(int): Number of erosions to fully erase complement betweenbw
andbw_convex
.true_pixels_per_erosion
(numpy.ndarray, optional): Number of true pixels after each erosion. Only provided ifreturn_counts
is True.
[1] Deutsches Institut für Normung e. V. (2012). DIN ISO 9276-6 - Darstellung der Ergebnisse von Par-tikelgrößenanalysen: Teil 6: Deskriptive und quantitative Darstellung der Form und Morphologie von Partikeln.
imea.measure_2d.meso.
erosions_till_erase
(
bw
, pad_width=1
, selem=None
, return_counts=False
)
Determine number of erosions that are necessary to fully erase all True elements in a binary image [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.pad_width
(int, optional) — Number of false pixels to pad around the image, by default 1.selem
(numpy.ndarray, type bool, optional) — Neighborhood expressed as a 2-D array of ones and zeros, by default None. If None, use a cross-shaped structuring element (connectivity=1) is used.return_counts
(bool, optional) — If True, a list with the number of true pixels for each iteration is returned, by default False.
n_erosions_2d
(int): Number of erosions to fully erase true pixels from image.true_pixels_per_erosion
(numpy.ndarray, optional): Number of true pixels after each erosion. Only provided ifreturn_counts
is True.
[1] Deutsches Institut für Normung e. V. (2012). DIN ISO 9276-6 - Darstellung der Ergebnisse von Par-tikelgrößenanalysen: Teil 6: Deskriptive und quantitative Darstellung der Form und Morphologie von Partikeln.
imea.measure_2d.micro
2-dimensional microdescriptors.
fractal_dimension_boxcounting
(
bw
,pad_width
)
(float) — Approximate fractal dimension by boxcounting method [1].fractal_dimension_perimeter
(
contour
,max_feret
,n_stepsizes
,step_size_min
)
(float) — Approximate fractal dimension with perimeter method. [1]
imea.measure_2d.micro.
fractal_dimension_boxcounting
(
bw
, pad_width=1
)
Approximate fractal dimension by boxcounting method [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.pad_width
(int, optional) — Width of applied zero-padding around the image, by default 1.
fractal_dimension
(float): Approximated fractal dimension.
[1] G.-B. So, H.-R. So, G.-G. Jin (2017): "Enhancement of the Box-Counting Algorithm for fractal dimension estimation". In: Pattern Recognition Letters, 98, pp. 53-58. https://doi.org/10.1016/j.patrec.2017.08.022
imea.measure_2d.micro.
fractal_dimension_perimeter
(
contour
, max_feret
, n_stepsizes=10
, step_size_min=2.0
)
Approximate fractal dimension with perimeter method. [1]
contour
(numpy.ndarray, type float) — Array of contourpoints in shape (n, 2) (e.g.[[x0, y0], [x1, y1], [x2, y2], ...]
).max_feret
(float) — Max feret diameter of object shape for norming the perimeters.n_stepsizes
(int, optional) — Number of different stepsizes to take, by default 10step_size_min
(float, optional) — Minimum stepsize, by default 2.0.
fractal_dimension
(float): Approximated fractal dimension.
Notes
Stepsizes range from step_size_min to step_size_max in a log2 grid. step_size_max is set to 0.3 * max_feret according to DIN ISO 9276-6.
[1] Deutsches Institut für Normung e. V. (2012). DIN ISO 9276-6 - Darstellung der Ergebnisse von Par-tikelgrößenanalysen: Teil 6: Deskriptive und quantitative Darstellung der Form und Morphologie von Partikeln.
imea.measure_2d.statistical_length
2-dimensional statistical length.
compute_statistical_lengths
(
bw
,daplha
)
(tuple) — Calculate statistical length distributions by rotating binary imagebw
indalpha
steps [1].distribution_parameters
(
distribution
)
(tuple) — Calculate distribution parameters of an array.feret
(
bw
)
(tuple) — Calculate Feret diameter of an object (orthogonal to y-direction) [1].find_all_chords
(
bw
)
(tuple) — Calculate chords of an object shape in y-direction [1].find_max_chord
(
bw
)
(tuple) — Calculate the maximum chords of an object shape in y-direction [1].martin
(
bw
,area_share_from_bottom
)
(tuple) — Calculate Martin diameter of an object (in y-direction) [1].nassenstein
(
bw
)
(tuple) — Calculates the Nassenstein diameter of an object shape [1].
imea.measure_2d.statistical_length.
compute_statistical_lengths
(
bw
, daplha=9
)
Calculate statistical length distributions by rotating binary image bw
in dalpha
steps [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.daplha
(number) — Rotation stepsize in degrees (0 - 180°), by default 9.
feret_diameters
(numpy.ndarray, type int): 1-dimensional array of Feret diameters for each rotation angle [1].martin_diameters
(numpy.ndarray, type int): 1-dimensional array of Martin diameters for each rotation [1].nassenstein_diameters
(numpy.ndarray, type int): 1-dimensional array of Nassenstein diameters for each rotation.max_chords
(numpy.ndarray, type int): 1-dimensional array of maximum chord for each rotation [1].all_chords
(numpy.ndarray, type int): 1-dimensional array of all chords for each rotation [1].angles
(numpy.ndarray, type float): 1-dimensional array of measured angles in degree as determinated bydaplha
.
[1] M. Pahl, G. Schädel und H. Rumpf (1973a). "Zusammenstellung von Teilchenformbeschreibungsmethoden: 1. Teil". In: Aufbereitungstechnik, 14(5), pp. 257–264.
imea.measure_2d.statistical_length.
nassenstein
(
bw
)
Calculates the Nassenstein diameter of an object shape [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
nassenstein_diameter
(int): Nassenstein diameter.idx
(numpy.ndarray, type int): Indexes of the start (0) and endpoint (1) of the Nassenstein diameter in shape[[x0,y0], [x1,y1]]
.
[1] M. Pahl, G. Schädel und H. Rumpf (1973a). "Zusammenstellung von Teilchenformbeschreibungsmethoden: 1. Teil". In: Aufbereitungstechnik, 14(5), pp. 257–264.
Notes
There might be several touching points in the lowest row. In this implementation we will evaluate the Nassenstein Durchmesser at the middle of the first continuous contact surface from left.
imea.measure_2d.statistical_length.
feret
(
bw
)
Calculate Feret diameter of an object (orthogonal to y-direction) [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
feret_diameter
(int): 2D Feret diameter.idx_x
(numpy.ndarray, type int): x-coordinates of the two Feret calipers in shape[x0, x1]
.
[1] M. Pahl, G. Schädel und H. Rumpf (1973a). "Zusammenstellung von Teilchenformbeschreibungsmethoden: 1. Teil". In: Aufbereitungstechnik, 14(5), pp. 257–264.
imea.measure_2d.statistical_length.
martin
(
bw
, area_share_from_bottom=0.5
)
Calculate Martin diameter of an object (in y-direction) [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.area_share_from_bottom
(float, optional) — Area share, where the Martin diameter is measured, by default 0.5 (original definition of the Martin diameter.)
martin_diameter
(int): Martin diameter.idx
(numpy.ndarray, type int): Indexes of the start (0) and endpoint (1) of the Martin diameter in shape[[x0,y0], [x1,y1]]
.
[1] M. Pahl, G. Schädel und H. Rumpf (1973a). "Zusammenstellung von Teilchenformbeschreibungsmethoden: 1. Teil". In: Aufbereitungstechnik, 14(5), pp. 257–264.
Notes
The original Martin diameter is is measured at the x-position,
where the object is split into 50% / 50% area share.
However, we can also calculate a diameter at a flexible area share.
This is given by area_share_from_bottom
:
area_share_from_bottom = 1 - area_share_from_top
imea.measure_2d.statistical_length.
find_all_chords
(
bw
)
Calculate chords of an object shape in y-direction [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
all_chords
(numpy.ndarray, type int): 1-dimensional array of found chordsc
in shape[c0, c1, ...]
.all_edgepoints
(numpy.ndarray, type int): 2-dimensional array of edgepoints corresponding toall_chords
in shape[[x0a, y0a], [x0b, y0b], [x1a, y1a], [x1b, y1b], ...]
, wherea
is the start andb
is the endpoint of the corresponding edge and0, 1, ...
the index of the corresponing chords.
[1] M. Pahl, G. Schädel und H. Rumpf (1973a). "Zusammenstellung von Teilchenformbeschreibungsmethoden: 1. Teil". In: Aufbereitungstechnik, 14(5), pp. 257–264.
imea.measure_2d.statistical_length.
find_max_chord
(
bw
)
Calculate the maximum chords of an object shape in y-direction [1].
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
max_chord
(int): Maximum chord in y-direction.idx
(numpy.ndarray, type int): Start (0) and endpoint (1) of max chord in shape[[x0, y0], [x0, y0]]
.
[1] M. Pahl, G. Schädel und H. Rumpf (1973a). "Zusammenstellung von Teilchenformbeschreibungsmethoden: 1. Teil". In: Aufbereitungstechnik, 14(5), pp. 257–264.
imea.measure_2d.statistical_length.
distribution_parameters
(
distribution
)
Calculate distribution parameters of an array.
distribution
(numpy.ndarray, type float) — An array.
max_value
(float): Max value indistribution
.min_value
(float): Min value indistribution
.median_value
(float): Median value indistribution
.mean_value
(float): Mean value indistribution
.mode
(float): Mode value indistribution
.std
(float): Standard deviation ofdistribution
.
imea.measure_2d.utils
Helping functions for 2-dimensional shape measurements.
find_contour
(
bw
)
(numpy.ndarray, type int) — Find external contour points of an object shape.skimage_measurements
(
bw
)
(tuple) — Calculate object shape measurements based onskimage.measure.regionprops
.
imea.measure_2d.utils.
find_contour
(
bw
)
Find external contour points of an object shape.
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
contour
(numpy.ndarray, type int): 2-dimensional array of contourpoints in shape[[x0, y0], [x1, y1], [x2, y2], ...]
.
imea.measure_2d.utils.
skimage_measurements
(
bw
)
Calculate object shape measurements based on skimage.measure.regionprops
.
bw
(numpy.ndarray, type bool) — 2-dimensional binary image.
area_projection
(int): Projection area.perimeter
(float): Perimeter.area_filled
(int): Filled area.area_convex
(int): Convex area.major_axis_length
(float): Major axis length.minor_axis_length
(float): Minor axis length.centroid
(numpy.ndarray, type float): Centroid in shape[x, y]
.coords
(numpy.ndarray, type int): 2-dimensional array of object coordinates in shape[[x0, y0], [x1, y1], ...]
.bw_cropped
(numpy.ndarray, type bool): Cropped version ofbw
.bw_convex
(numpy.ndarray, type bool): Cropped 2-dimensional convex binary image ofbw
.
Notes
Extracts only shape measurement of largest object in bw_org
,
since multi object shape extraction is handled by higher
functions in imea.