cars.applications.point_cloud_outliers_removing.outlier_removing_tools

This module contains functions used in outlier removing

Module Contents

Functions

small_components_filtering(→ Tuple[pandas.DataFrame, ...)

Filter points cloud to remove small clusters of points

detect_small_components(→ List[int])

Determine the indexes of the points of cloud_xyz to filter.

statistical_outliers_filtering(...)

Filter points cloud to remove statistical outliers

detect_statistical_outliers(→ List[int])

Determine the indexes of the points of cloud_xyz to filter.

filter_cloud(→ Tuple[pandas.DataFrame, Union[None, ...)

Filter all points of the cloud DataFrame

add_cloud_filtering_msk(clouds_list, elt_pos_infos, ...)

Add a uint16 mask labeled 'mask_label' to the clouds in clouds_list.

cars.applications.point_cloud_outliers_removing.outlier_removing_tools.small_components_filtering(cloud: pandas.DataFrame, connection_val: float, nb_pts_threshold: int, clusters_distance_threshold: float = None, filtered_elt_pos: bool = False) Tuple[pandas.DataFrame, Union[None, pandas.DataFrame]]

Filter points cloud to remove small clusters of points (see the detect_small_components function).

Parameters
  • cloud – combined cloud as returned by the create_combined_cloud function

  • connection_val – distance to use to consider that two points are connected

  • nb_pts_threshold – number of points to use to identify small clusters to filter

  • clusters_distance_threshold – distance to use to consider if two points clusters are far from each other or not (set to None to deactivate this level of filtering)

  • filtered_elt_pos – if filtered_elt_pos is set to True, the removed points positions in their original epipolar images are returned, otherwise it is set to None

Returns

Tuple made of the filtered cloud and the removed elements positions in their epipolar images

cars.applications.point_cloud_outliers_removing.outlier_removing_tools.detect_small_components(cloud_xyz: numpy.ndarray, connection_val: float, nb_pts_threshold: int, clusters_distance_threshold: float = None) List[int]

Determine the indexes of the points of cloud_xyz to filter. The clusters are made of ‘connected’ points (2 connected points have a distance smaller than connection_val)

The removed clusters are composed of less than nb_pts_threshold points and are also far from other clusters (points are further than clusters_distance_threshold).

If clusters_distance_threshold is set to None, all the clusters that are composed of less than nb_pts_threshold points are filtered.

Parameters
  • cloud_xyz – points kdTree

  • connection_val – distance to use to consider that two points are connected

  • nb_pts_threshold – number of points to use to identify small clusters to filter

  • clusters_distance_threshold – distance to use to consider if two points clusters are far from each other or not (set to None to deactivate this level of filtering)

Returns

list of the points to filter indexes

cars.applications.point_cloud_outliers_removing.outlier_removing_tools.statistical_outliers_filtering(cloud: pandas.DataFrame, k: int, dev_factor: float, use_median: bool = False, filtered_elt_pos: bool = False) Tuple[pandas.DataFrame, Union[None, pandas.DataFrame]]

Filter points cloud to remove statistical outliers (see the detect_statistical_outliers function).

Parameters
  • cloud – combined cloud as returned by the create_combined_cloud function

  • k – number of neighbors

  • dev_factor – multiplication factor of deviation used to compute the distance threshold

  • use_median – choice of statistical measure used to filter

  • filtered_elt_pos – if filtered_elt_pos is set to True, the removed points positions in their original epipolar images are returned, otherwise it is set to None

Returns

Tuple made of the filtered cloud and the removed elements positions in their epipolar images

cars.applications.point_cloud_outliers_removing.outlier_removing_tools.detect_statistical_outliers(cloud_xyz: numpy.ndarray, k: int, dev_factor: float, use_median: bool) List[int]

Determine the indexes of the points of cloud_xyz to filter. The removed points have mean distances with their k nearest neighbors that are greater than a distance threshold (dist_thresh).

This threshold is computed from the mean (or median) and standard deviation (or interquartile range) of all the points mean distances with their k nearest neighbors:

(1) dist_thresh = mean_distances + dev_factor * std_distances or (2) dist_thresh = median_distances + dev_factor * iqr_distances

Parameters
  • cloud_xyz – points kdTree

  • k – number of neighbors

  • dev_factor – multiplication factor of deviation used to compute the distance threshold

  • use_median – if True formula (2) is used for threshold, else formula (1)

Returns

list of the points to filter indexes

cars.applications.point_cloud_outliers_removing.outlier_removing_tools.filter_cloud(cloud: pandas.DataFrame, index_elt_to_remove: List[int], filtered_elt_pos: bool = False) Tuple[pandas.DataFrame, Union[None, pandas.DataFrame]]

Filter all points of the cloud DataFrame which index is in the index_elt_to_remove list.

If filtered_elt_pos is set to True, the information of the removed elements positions in their original epipolar images are returned.

To do so the cloud DataFrame has to be build with the ‘with_coords’ option activated.

Parameters
  • cloud – combined cloud as returned by the create_combined_cloud function

  • index_elt_to_remove – indexes of lines to filter in the cloud DataFrame

  • filtered_elt_pos – if filtered_elt_pos is set to True, the removed points positions in their original epipolar images are returned, otherwise it is set to None

Returns

Tuple composed of the filtered cloud DataFrame and the filtered elements epipolar position information (or None for the latter if filtered_elt_pos is set to False or if the cloud Dataframe has not been build with with_coords option)

cars.applications.point_cloud_outliers_removing.outlier_removing_tools.add_cloud_filtering_msk(clouds_list: List[xarray.Dataset], elt_pos_infos: pandas.DataFrame, mask_label: str, mask_value: int = 255)

Add a uint16 mask labeled ‘mask_label’ to the clouds in clouds_list. (in-line function)

Parameters
  • clouds_list – Input list of clouds

  • elt_pos_infos – pandas dataframe composed of cst.POINTS_CLOUD_COORD_EPI_GEOM_I, cst.POINTS_CLOUD_COORD_EPI_GEOM_J, cst.POINTS_CLOUD_ID_IM_EPI columns as computed in the create_combined_cloud function. Those information are used to retrieve the point position in its original epipolar image.

  • mask_label – label to give to the mask in the datasets

  • mask_value – filtered elements value in the mask