spateo.alignment.methods.mesh_correction_utils¶
Functions¶
|
Transforms the given points by applying rotation, translation, and scaling. |
|
Extracts contours from a point cloud using OpenCV. |
|
Extracts contours from a point cloud in a slice using the alpha shape method. |
|
Smooths the contours using a moving average filter. |
|
|
|
Generates labeling values for a given parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Iterative Closest Point (ICP) algorithm for aligning two sets of points. |
Solve for the rotation matrix R and translation vector t that best align the points in X to the points in Y. |
Module Contents¶
- spateo.alignment.methods.mesh_correction_utils._transform_points(points: numpy.ndarray, rotation: numpy.ndarray | list, translation: numpy.ndarray | list, scaling: float) numpy.ndarray [source]¶
Transforms the given points by applying rotation, translation, and scaling.
- Parameters:
- points np.ndarray
The points to be transformed, with shape (N, 3).
- rotation Union[np.ndarray, list]
The rotation angles (in degrees) around x, y, and z axes.
- translation Union[np.ndarray, list]
The translation vector only for z axes.
- scaling Union[float, np.ndarray]
The scaling factor with single float.
- Returns:
The transformed points with shape (N, 3).
- Return type:
np.ndarray
- spateo.alignment.methods.mesh_correction_utils._extract_contour_opencv(points: numpy.ndarray, average_n: float = 0.2, kernel_size: int | None = None) List[numpy.ndarray] [source]¶
Extracts contours from a point cloud using OpenCV.
- Parameters:
- points np.ndarray
A numpy array of shape (N, 2) representing the point cloud in a slice.
- average_n float, optional
Average number of points per unit area. Defaults to 0.2.
- kernel_size Optional[int], optional
Size of the structuring element for morphological operations. If None, it will be computed based on the image size. Defaults to None.
- Returns:
A list of numpy arrays, each containing the contour of the points of slice.
- Return type:
List[np.ndarray]
- spateo.alignment.methods.mesh_correction_utils._extract_contour_alpha_shape(points: numpy.ndarray, alpha: float = 0.5) List[numpy.ndarray] [source]¶
Extracts contours from a point cloud in a slice using the alpha shape method.
- Parameters:
- points np.ndarray
A numpy array of shape (N, 2) representing the point cloud.
- alpha float, optional
Alpha parameter for the alpha shape algorithm. Defaults to 0.5.
- Returns:
A list of numpy arrays, each containing the vertices of a contour.
- Return type:
List[np.ndarray]
- spateo.alignment.methods.mesh_correction_utils._smooth_contours(vertex: List[numpy.ndarray], window_size: int = 5, iterations: int = 1)[source]¶
Smooths the contours using a moving average filter.
- spateo.alignment.methods.mesh_correction_utils._generate_labeling(max_value: float, number_of_steps: int, scale_type: str = 'linear') List[float] [source]¶
Generates labeling values for a given parameter.
- spateo.alignment.methods.mesh_correction_utils._update_parameter(transformation_labels, parameters)[source]¶
- spateo.alignment.methods.mesh_correction_utils._get_parameters_from_pair(pair, transformation_labels)[source]¶
- spateo.alignment.methods.mesh_correction_utils._getBinary(contours, mesh, z_values, pairs, transformation_labels, verbose: bool = False)[source]¶
- spateo.alignment.methods.mesh_correction_utils._get_binary_values(contours, mesh, z_values, pair, transformation_labels)[source]¶
- spateo.alignment.methods.mesh_correction_utils._calculate_loss(contours, mesh, transformation, z_values, method: Literal['CPD', 'ICP'] = 'ICP')[source]¶
- spateo.alignment.methods.mesh_correction_utils.ICP(contour_1: numpy.ndarray, contour_2: numpy.ndarray, max_iter: int = 20, error_threshold: float = 1e-06, inlier_threshold: float = 0.1, subsample: int = 500, allow_rotation: bool = False) Tuple[float, float, float | numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]¶
Iterative Closest Point (ICP) algorithm for aligning two sets of points.
- Parameters:
- contour_1 np.ndarray
Data points.
- contour_2 np.ndarray
Model points.
- max_iter int, optional
Maximum number of iterations. Defaults to 20.
- error_threshold float, optional
Error threshold for convergence. Defaults to 1e-6.
- inlier_threshold float, optional
Inlier threshold distance. Defaults to 0.1.
- subsample int, optional
Number of points to subsample. Defaults to 500.
- allow_rotation bool, optional
Whether to allow estimate rotation. Defaults to False.
- Returns:
Convergence ratio, sigma2 (placeholder), translation vector, original contour, transformed contour, rotation matrix.
- Return type:
Tuple[float, float, Union[float, np.ndarray], np.ndarray, np.ndarray, np.ndarray]
- spateo.alignment.methods.mesh_correction_utils.solve_RT_by_correspondence(X: numpy.ndarray, Y: numpy.ndarray, return_scale: bool = False) Tuple[numpy.ndarray, numpy.ndarray] | Tuple[numpy.ndarray, numpy.ndarray, float] [source]¶
Solve for the rotation matrix R and translation vector t that best align the points in X to the points in Y.
- Parameters:
- X np.ndarray
Source points, shape (N, D).
- Y np.ndarray
Target points, shape (N, D).
- return_scale bool, optional
Whether to return the scale factor. Defaults to False.
- Returns:
If return_scale is False, returns the rotation matrix R and translation vector t. If return_scale is True, also returns the scale factor s.
- Return type:
Union[Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray, float]]