package

imea.tools

General helping functions.

module

imea.tools.preprocess

Helping functions to preprocess 3d heightmap images for shape measurement extraction.

Functions
  • 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.
function

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.

Parameters
  • 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 of img_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, If max_objects=-1, then all objects are extracted, by default -1.
Returns (tuple)
  • imgs_3d (list): List of cropped 3d images as numpy.ndarray for each object.
  • bws (list): List of cooresponding binary images.
function

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.

Parameters
  • img_3d (numpy.ndarray, type float) 2-dimensional grayscale heightmap. Pixels not showing the pixel should be 0.
  • spatial_resolution_xy (float) Spatial resolution of img_3d in x and y direction in [mm/pixel].
  • spatial_resolution_z (float, optional) Spatial resolution of img_3d in z-direction (height) in [mm/grayvalue], by default 1.
Returns (tuple)
  • img_3d_equalspace (numpy.ndarray, type float): 3d image with dx = dy = dz.
  • spatial_resolution (float): Spatial resolution of img_3d_equalspace.

Notes

spatial_resolution is set to spatial_resolution_xy, as only heights are transformed.

module

imea.tools.project

Helping functions to project 3D points on a 2D plane.

Functions
  • xyz_to_xy(p_3d) (numpy.ndarray) Project 3D points to xy plane.
  • xyz_to_xz(p_3d) (numpy.ndarray) Project 3D points to xy plane.
  • xyz_to_yz(p_3d) (numpy.ndarray) Project 3D points to xy plane.
function

imea.tools.project.xyz_to_xy(p_3d)

Project 3D points to xy plane.

Parameters
  • p_3d (numpy.ndarray) 3D pointcloud in shape (n,3), where n is the number of points.
Returns (numpy.ndarray)
  • p_2d (numpy.ndarray): Projected pointcloud in shape (n, 2), where n is the number of points.
function

imea.tools.project.xyz_to_xz(p_3d)

Project 3D points to xy plane.

Parameters
  • p_3d (numpy.ndarray) 3D pointcloud in shape (n,3), where n is the number of points.
Returns (numpy.ndarray)
  • p_2d (numpy.ndarray): Projected pointcloud in shape (n,2), where n is the number of points.
function

imea.tools.project.xyz_to_yz(p_3d)

Project 3D points to xy plane.

Parameters
  • p_3d (numpy.ndarray) 3D pointcloud in shape (n,3), where n is the number of points.
Returns (numpy.ndarray)
  • p_2d (numpy.ndarray): Projected pointcloud in shape (n, 2), where n is the number of points.
module

imea.tools.rotate

Helping functions to rotate points around a given axis.

Functions
  • 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 matrix R to pointcloud pts.
function

imea.tools.rotate.apply(pts, R)

Apply rotation matrix R to pointcloud pts.

Parameters
  • pts (numpy.ndarray) Points to be rotated of shape (n,d), where n is the number of points and d the number of dimensions.
  • R (numpy.ndarray) Rotation matrix of shape (d,d).
Returns (numpy.ndarray)
  • out : numpy.ndarray Rotated points.
function

imea.tools.rotate.Rx(angle_in_degrees)

3D rotation matrix for rotating around x-axis.

Parameters
  • angle_in_degrees (float) Rotation angle around x-axis in degrees.
Returns (numpy.ndarray)
  • Rx (numpy.ndarray): 3D Rotation matrix.
function

imea.tools.rotate.Ry(angle_in_degrees)

3D rotation matrix for rotating around y-axis.

Parameters
  • angle_in_degrees (float) Rotation angle around y-axis in degrees.
Returns (numpy.ndarray)
  • Ry (numpy.ndarray): 3D Rotation matrix.
function

imea.tools.rotate.Rz(angle_in_degrees)

3D rotation matrix for rotating around z-axis.

Parameters
  • angle_in_degrees (float) Rotation angle around z-axis in degrees.
Returns (numpy.ndarray)
  • Rz (numpy.ndarray): 3D Rotation matrix.
function

imea.tools.rotate.R_2d(angle_in_degrees)

2D rotation matrix.

Parameters
  • angle_in_degrees (float) Rotation angle in degrees.
Returns (numpy.ndarray)
  • R (numpy.ndarray): 2D Rotation matrix.
module

imea.tools.draw

Helping functions to draw shapes on images.

Functions
  • 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.
function

imea.tools.draw.polyline_on_img(img, polyline, color=(1, 0, 0), thickness=1, closed_line=True)

Draw polyline on image.

Parameters
  • 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.
Returns (float)
  • img_with_line (numpy.ndarray, type float): RGB image with drawn line in range [0, 1].
function

imea.tools.draw.circle_on_img(img, center, diameter, color=(1, 0, 0), thickness=1, mark_centroid=True)

Draw circle on an image.

Parameters
  • 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.
Returns (float)
  • img_with_circle (numpy.ndarray, type float): RGB image with drawn circle in range [0,1].
function

imea.tools.draw.marker_on_img(img, marker_pos, color=(1, 0, 0), marker_size=20, marker_thickness=3)

Draw marker on image.

Parameters
  • 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 20
  • marker_thickness (int, optional) Thickness of drawing in pixel, by default 3.
Returns (float)
  • img_with_marker (numpy.ndarray, type float): RGB image with drawn circle in range [0,1].