imea.tools
General helping functions.
imea.tools.preprocess
Helping functions to preprocess 3d heightmap images for shape measurement extraction.
equalspace_3d_img
(
img_3d
,spatial_resolution_xy
,spatial_resolution_z
)
(tuple) — Create a equalspace image, i. e. dx = dy = dz.extract_and_preprocess_3d_imgs
(
img_3d
,threshold_gv
,min_object_area
,max_objects
)
(tuple) — Segment 3d image and return list of 3d images of single objects and corresponding binary images.
imea.tools.preprocess.
extract_and_preprocess_3d_imgs
(
img_3d
, threshold_gv
, min_object_area=0
, max_objects=-1
)
Segment 3d image and return list of 3d images of single objects and corresponding binary images.
img_3d
(numpy.ndarray, type float) — 2-dimensional grayscale heightmap. Pixels not showing the pixel should be 0.threshold_gv
(float) — Threshold in grayvalues for segmentation ofimg_3d
.min_object_area
(int, optional) — Minimum number of pixels for a region to be considered as an object, by default 0.max_objects
(int, optional) — Maximum number of objects to be extracted, Ifmax_objects=-1
, then all objects are extracted, by default -1.
imgs_3d
(list): List of cropped 3d images as numpy.ndarray for each object.bws
(list): List of cooresponding binary images.
imea.tools.preprocess.
equalspace_3d_img
(
img_3d
, spatial_resolution_xy
, spatial_resolution_z=1.0
)
Create a equalspace image, i. e. dx = dy = dz.
img_3d
(numpy.ndarray, type float) — 2-dimensional grayscale heightmap. Pixels not showing the pixel should be 0.spatial_resolution_xy
(float) — Spatial resolution ofimg_3d
in x and y direction in [mm/pixel].spatial_resolution_z
(float, optional) — Spatial resolution ofimg_3d
in z-direction (height) in [mm/grayvalue], by default 1.
img_3d_equalspace
(numpy.ndarray, type float): 3d image withdx = dy = dz
.spatial_resolution
(float): Spatial resolution ofimg_3d_equalspace
.
Notes
spatial_resolution
is set to spatial_resolution_xy
,
as only heights are transformed.
imea.tools.project
Helping functions to project 3D points on a 2D plane.
imea.tools.project.
xyz_to_xy
(
p_3d
)
Project 3D points to xy plane.
p_3d
(numpy.ndarray) — 3D pointcloud in shape(n,3)
, wheren
is the number of points.
p_2d
(numpy.ndarray): Projected pointcloud in shape(n, 2)
, wheren
is the number of points.
imea.tools.project.
xyz_to_xz
(
p_3d
)
Project 3D points to xy plane.
p_3d
(numpy.ndarray) — 3D pointcloud in shape(n,3)
, wheren
is the number of points.
p_2d
(numpy.ndarray): Projected pointcloud in shape(n,2)
, wheren
is the number of points.
imea.tools.project.
xyz_to_yz
(
p_3d
)
Project 3D points to xy plane.
p_3d
(numpy.ndarray) — 3D pointcloud in shape(n,3)
, wheren
is the number of points.
p_2d
(numpy.ndarray): Projected pointcloud in shape(n, 2)
, wheren
is the number of points.
imea.tools.rotate
Helping functions to rotate points around a given axis.
R_2d
(
angle_in_degrees
)
(numpy.ndarray) — 2D rotation matrix.Rx
(
angle_in_degrees
)
(numpy.ndarray) — 3D rotation matrix for rotating around x-axis.Ry
(
angle_in_degrees
)
(numpy.ndarray) — 3D rotation matrix for rotating around y-axis.Rz
(
angle_in_degrees
)
(numpy.ndarray) — 3D rotation matrix for rotating around z-axis.apply
(
pts
,R
)
(numpy.ndarray) — Apply rotation matrixR
to pointcloudpts
.
imea.tools.rotate.
apply
(
pts
, R
)
Apply rotation matrix R
to pointcloud pts
.
pts
(numpy.ndarray) — Points to be rotated of shape(n,d)
, wheren
is the number of points andd
the number of dimensions.R
(numpy.ndarray) — Rotation matrix of shape(d,d)
.
out
: numpy.ndarray Rotated points.
imea.tools.rotate.
Rx
(
angle_in_degrees
)
3D rotation matrix for rotating around x-axis.
angle_in_degrees
(float) — Rotation angle around x-axis in degrees.
Rx
(numpy.ndarray): 3D Rotation matrix.
imea.tools.rotate.
Ry
(
angle_in_degrees
)
3D rotation matrix for rotating around y-axis.
angle_in_degrees
(float) — Rotation angle around y-axis in degrees.
Ry
(numpy.ndarray): 3D Rotation matrix.
imea.tools.rotate.
Rz
(
angle_in_degrees
)
3D rotation matrix for rotating around z-axis.
angle_in_degrees
(float) — Rotation angle around z-axis in degrees.
Rz
(numpy.ndarray): 3D Rotation matrix.
imea.tools.rotate.
R_2d
(
angle_in_degrees
)
2D rotation matrix.
angle_in_degrees
(float) — Rotation angle in degrees.
R
(numpy.ndarray): 2D Rotation matrix.
imea.tools.draw
Helping functions to draw shapes on images.
circle_on_img
(
img
,center
,diameter
,color
,thickness
,mark_centroid
)
(float) — Draw circle on an image.marker_on_img
(
img
,marker_pos
,color
,marker_size
,marker_thickness
)
(float) — Draw marker on image.polyline_on_img
(
img
,polyline
,color
,thickness
,closed_line
)
(float) — Draw polyline on image.
imea.tools.draw.
polyline_on_img
(
img
, polyline
, color=(1, 0, 0)
, thickness=1
, closed_line=True
)
Draw polyline on image.
img
(numpy.ndarray, type float) — RGB image in range [0, 1].polyline
(np.ndarray, type int) — Array with points of polyline of shape [[x0, y0], [x1, y1], [x2, y2], ...].color
(tuple, type float, optional) — RGB colors of drawing in range [0,1], color format: (R, G, B), by default (1, 0, 0).thickness
(int, optional) — Thickness of drawing in pixel, by default 1.closed_line
(bool, optional) — If true line will be closed (start and end point connected), by default True.
img_with_line
(numpy.ndarray, type float): RGB image with drawn line in range [0, 1].
imea.tools.draw.
circle_on_img
(
img
, center
, diameter
, color=(1, 0, 0)
, thickness=1
, mark_centroid=True
)
Draw circle on an image.
img
(numpy.ndarray, type float) — RGB image in range [0, 1].center
(numpy.ndarray, type int) — Center of circle in shape [x, y].diameter
(int) — Diameter of circle.color
(tuple, type float, optional) — RGB colors of drawing in range [0,1], color format: (R, G, B), by default (1, 0, 0).thickness
(int, optional) — Thickness of drawing in pixel, by default 1.mark_centroid
(bool, optional) — If True, centroid will be marked, by default True.
img_with_circle
(numpy.ndarray, type float): RGB image with drawn circle in range [0,1].
imea.tools.draw.
marker_on_img
(
img
, marker_pos
, color=(1, 0, 0)
, marker_size=20
, marker_thickness=3
)
Draw marker on image.
img
(numpy.ndarray, type float) — RGB image in range [0, 1].marker_pos
(numpy.ndarray, type int) — Marker position in shape [x, y].color
(tuple, type float, optional) — RGB colors of drawing in range [0,1], color format: (R, G, B), by default (1, 0, 0).marker_size
(int, optional) — Size of marker in pixel, by default 20marker_thickness
(int, optional) — Thickness of drawing in pixel, by default 3.
img_with_marker
(numpy.ndarray, type float): RGB image with drawn circle in range [0,1].