cars_mesh.core.denoise_pcd

Denoising methods aiming at smoothing surfaces without losing genuine high-frequency information.

Module Contents

Functions

compute_pcd_normals_o3d(...)

Compute point cloud normals with open3d library

compute_point_normal(→ numpy.array)

Compute unitary normal with the PCA approach from a point and its

weight_exp(→ numpy.ndarray)

Decreasing exponential function for weighting

weight_gaussian(→ numpy.ndarray)

Decreasing function inspired by the gaussian function for weighting

compute_pcd_normals(→ cars_mesh.tools.handlers.PointCloud)

Compute the normal for each point of the cloud

bilateral_filtering(pcd, num_iterations[, ...])

Bilateral denoising

cars_mesh.core.denoise_pcd.compute_pcd_normals_o3d(pcd: cars_mesh.tools.handlers.PointCloud, neighbour_search_method: str = 'knn', knn: int = 100, radius: float = 5.0) cars_mesh.tools.handlers.PointCloud[source]

Compute point cloud normals with open3d library

Parameters:
  • pcd (PointCloud) – Point cloud instance

  • neighbour_search_method (str (default="knn")) – Neighbour search method

  • knn (int (default=30)) – If “neighbour_search_method” is “knn”, number of neighbours to consider

  • radius (float (default=5.)) – If “neighbour_search_method” is “ball”, ball radius in which to find the neighbours

cars_mesh.core.denoise_pcd.compute_point_normal(point_coordinates: numpy.array, weights: float = None) numpy.array[source]

Compute unitary normal with the PCA approach from a point and its neighbours. The normal to a point on the surface of an object is approximated to the normal to the tangent plane defined by the point and its neighbours. It becomes a least square problem. See https://pcl.readthedocs.io/projects/tutorials/en/latest/ normal_estimation.html

The normal vector corresponds to the vector associated with the smallest eigen value of the neighborhood point covariance matrix.

Parameters:
  • point_coordinates (np.array) – Point coordinates

  • weights (float (default=None)) – Absolute Weights for the covariance matrix (see numpy.cov documentation)

Returns:

normal – Local normal vector

Return type:

np.array

cars_mesh.core.denoise_pcd.weight_exp(distance: numpy.ndarray, mean_distance: numpy.ndarray) numpy.ndarray[source]

Decreasing exponential function for weighting

cars_mesh.core.denoise_pcd.weight_gaussian(distance: numpy.ndarray, sigma: numpy.ndarray) numpy.ndarray[source]

Decreasing function inspired by the gaussian function for weighting

cars_mesh.core.denoise_pcd.compute_pcd_normals(pcd: cars_mesh.tools.handlers.PointCloud, neighbour_search_method: str = 'knn', knn: int = 30, radius: float = 5.0, weights_distance: bool = False, sigma_d: float = 0.5, weights_color: bool = False, sigma_c: float = 125.0, workers: int = 1, use_open3d: bool = True) cars_mesh.tools.handlers.PointCloud[source]

Compute the normal for each point of the cloud

Parameters:
  • pcd (PointCloud) – Point cloud instance

  • neighbour_search_method (str (default="knn")) – Neighbour search method

  • knn (int (default=30)) – If “neighbour_search_method” is “knn”, number of neighbours to consider

  • radius (float (default=5.)) – If “neighbour_search_method” is “ball”, ball radius in which to find the neighbours

  • weights_distance (bool (default=False)) – Whether to add a weighting to the neighbours on the distance information It is only available if ‘use_open3d’ is False

  • sigma_d (float (default=0.5)) – If ‘weights_distance’ is True, it is the standard deviation over the spatial distance to use in the exponential weighting function

  • weights_color (bool (default=False)) – Whether to add a weighting to the neighbours on the color information It is only available if ‘use_open3d’ is False

  • sigma_c (float (default=125.)) – If ‘weights_color’ is True, it is the standard deviation over the color distance to use in the exponential weighting function

  • workers (int (default=1)) – Number of workers to query the KDtree (neighbour search)

  • use_open3d (bool (default=False)) – Whether to use open3d normal computation instead. No weighting is applied to neighbours in that case.

Returns:

pcd – Point cloud instance

Return type:

PointCloud

cars_mesh.core.denoise_pcd.bilateral_filtering(pcd: cars_mesh.tools.handlers.PointCloud, num_iterations: int, neighbour_kdtree_dict: dict = None, sigma_d: float = 0.5, sigma_n: float = 0.5, neighbour_normals_dict: dict = None, num_chunks: int = 1)[source]

Bilateral denoising

Parameters:
  • pcd (PointCloud) – Point cloud instance

  • num_iterations (int) – Number of times to apply bilateral filtering in an iterative fashion

  • neighbour_kdtree_dict (dict (default=None)) –

    Dictionary to define the kdtree options to encode the distance between points:

    • neighbour_search_method: str (default=”knn”). Neighbour search method

    • knn: int (default=30). If “neighbour_search_method” is “knn”, number of neighbours to consider

    • radius: float (default=5.). If “neighbour_search_method” is “ball”, ball radius in which to find the neighbours

    • num_workers_kdtree: int (default=1). Number of workers to query the KDtree (neighbour search)

  • sigma_d (float (default=0.5)) – Variance on the distance between a point and its neighbours

  • sigma_n (float (default=0.5)) – Variance on the normal difference between the ones of a point and the ones of its neighbours

  • neighbour_normals_dict (dict (default=None)) –

    Dictionary to define the configuration to compute normals according to the ones of the neighbours

    • neighbour_search_method_normals: str (default=”knn”). Neighbour search method to compute the normals at each point

    • knn_normals: int (default=30). If “neighbour_search_method_normals” is “knn”, number of neighbours to consider

    • radius_normals: float (default=5.). If “neighbour_search_method_normals” is “ball”, ball radius in which to find the neighbours

    • weights_distance: bool (default=False). Whether to add a weighting to the neighbours on the distance information Only available if ‘use_open3d’ is False

    • weights_color: bool (default=False). Whether to add a weighting to the neighbours on the color information. Only available if ‘use_open3d’ is False

    • use_open3d: bool (default=False). Whether to use open3d normal computation instead. No weighting is applied to neighbours in that case.

  • num_chunks (int (default=1)) – Number of chunks to apply bilateral processing (to fit in memory since it is optimized as vectorial calculus).

Returns:

pcd – Point cloud instance

Return type:

PointCloud