12. Cloud Sampling Tools

12.1. cloud sampling

class cloudComPy.CloudSamplingTools

Bases: pybind11_object

Several point cloud resampling algorithms (octree-based, random, etc.)

__init__(*args, **kwargs)
static noiseFilter(cloud: _cloudComPy.GenericIndexedCloudPersist, kernelRadius: float, nSigma: float, removeIsolatedPoints: bool = False, useKnn: bool = False, knn: int = 6, useAbsoluteError: bool = True, absoluteError: float = 0, octree: _cloudComPy.DgmOctree = None, progressCb: _cloudComPy.GenericProgressCallback = None) _cloudComPy.ReferenceCloud

Noise filter based on the distance to the approximate local surface

This filter removes points based on their distance relatively to the best fit plane computed on their neighbors.

Parameters
  • cloud (GenericIndexedCloudPersist) – the point cloud to resample

  • kernelRadius (float) – neighborhood radius

  • nSigma (float) – number of sigmas under which the points should be kept

  • removeIsolatedPoints (bool,optional) – default False, whether to remove isolated points (i.e. with 3 points or less in the neighborhood)

  • useKnn (bool,optional) – default False, whether to use a constant number of neighbors instead of a radius

  • knn (int,optional) – default 6, number of neighbors (if useKnn is true)

  • useAbsoluteError (bool,optional) – default True, whether to use an absolute error instead of ‘n’ sigmas

  • absoluteError (float,optional) – default 0.0, absolute error (if useAbsoluteError is true)

  • octree (DgmOctree,optional) – default None, associated octree if available

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

Returns

a reference cloud corresponding to the filtered cloud

Return type

ReferenceCloud

static resampleCloudSpatially(cloud: _cloudComPy.GenericIndexedCloudPersist, minDistance: float, modParams: _cloudComPy.SFModulationParams = <_cloudComPy.SFModulationParams object at 0x7f6e61ebb2b0>, octree: _cloudComPy.DgmOctree = None, progressCb: _cloudComPy.GenericProgressCallback = None) _cloudComPy.ReferenceCloud

Resamples a point cloud (process based on inter point distance)

The cloud is resampled so that there is no point nearer than a given distance to other points It works by picking a reference point, removing all points which are to close to this point, and repeating these two steps until the result is reached

Parameters
  • cloud (GenericIndexedCloudPersist) – the point cloud to resample

  • minDistance (float) – the distance under which a point in the resulting cloud cannot have any neighbour

  • modParams (SFModulationParams) – parameters of the subsampling behavior modulation with a scalar field (optional)

  • octree (DgmOctree,optional) – default None, associated octree if available

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

Returns

a reference cloud corresponding to the resampling ‘selection’

Return type

ReferenceCloud

static resampleCloudWithOctree(cloud: _cloudComPy.ccPointCloud, newNumberOfPoints: int, resamplingMethod: _cloudComPy.RESAMPLING_CELL_METHOD, progressCb: _cloudComPy.GenericProgressCallback = None, inputOctree: _cloudComPy.DgmOctree = None) _cloudComPy.ccPointCloud

Resamples a point cloud (process based on the octree)

Same as resampleCloudWithOctreeAtLevel() method, apart the fact that instead of giving a specific octree subdivision level as input parameter, one can specify an approximative number of points for the resulting cloud (algorithm will automatically determine the corresponding octree level).

Parameters
  • cloud (GenericIndexedCloudPersist) – the point cloud to resample

  • newNumberOfPoints (int) – desired number of points (approximative)

  • resamplingMethod (RESAMPLING_CELL_METHOD) – resampling method (applied to each octree cell) value from RESAMPLING_CELL_METHOD.CELL_CENTER, RESAMPLING_CELL_METHOD.CELL_GRAVITY_CENTER

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

  • inputOctree (DgmOctree,optional) – default None, if the octree has been already computed, it can be used by the process (avoid recomputation)

Returns

the resampled cloud (new cloud)

Return type

ccPointCloud

static resampleCloudWithOctreeAtLevel(cloud: _cloudComPy.GenericIndexedCloudPersist, octreeLevel: int, resamplingMethod: _cloudComPy.RESAMPLING_CELL_METHOD, progressCb: _cloudComPy.GenericProgressCallback = None, inputOctree: _cloudComPy.DgmOctree = None) _cloudComPy.ccPointCloud

Resamples a point cloud (process based on the octree)

A resampling algorithm is applied inside each cell of the octree. The different resampling methods are represented as an enumerator (see RESAMPLING_CELL_METHOD) and consist in simple processes such as replacing all the points lying in a cell by the cell center or by the points gravity center.

Parameters
  • cloud (GenericIndexedCloudPersist) – the point cloud to resample

  • octreeLevel (int) – the octree level at which to perform the resampling process

  • resamplingMethod (RESAMPLING_CELL_METHOD) – resampling method (applied to each octree cell) value from RESAMPLING_CELL_METHOD.CELL_CENTER, RESAMPLING_CELL_METHOD.CELL_GRAVITY_CENTER

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

  • inputOctree (DgmOctree,optional) – default None, if the octree has been already computed, it can be used by the process (avoid recomputation)

Returns

the resampled cloud (new cloud)

Return type

ccPointCloud

static sorFilter(cloud: _cloudComPy.GenericIndexedCloudPersist, knn: int = 6, nSigma: float = 1.0, octree: _cloudComPy.DgmOctree = None, progressCb: _cloudComPy.GenericProgressCallback = None) _cloudComPy.ReferenceCloud

Statistical Outliers Removal (SOR) filter

This filter removes points based on their mean distance to their distance (by comparing it to the average distance of all points to their neighbors). It is equivalent to PCL StatisticalOutlierRemoval filter (see Removing outliers using a StatisticalOutlierRemoval filter)

Parameters
  • cloud (GenericIndexedCloudPersist) – the point cloud to resample

  • knn (int,optional) – default 6,number of neighbors

  • nSigma (float,optional) – default 1.0, number of sigmas under which the points should be kept

  • octree (DgmOctree,optional) – default None, associated octree if available

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

Returns

a reference cloud corresponding to the filtered cloud

Return type

ReferenceCloud

static subsampleCloudRandomly(cloud: _cloudComPy.GenericIndexedCloudPersist, newNumberOfPoints: int, progressCb: _cloudComPy.GenericProgressCallback = None) _cloudComPy.ReferenceCloud

Subsamples a point cloud (process based on random selections)

A very simple subsampling algorithm that simply consists in selecting “n” different points, in a random way.

Parameters
  • cloud (GenericIndexedCloudPersist) – point cloud to subsample

  • newNumberOfPoints (int) – desired number of points (exact)

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

Returns

a reference cloud corresponding to the subsampling ‘selection’

Return type

ReferenceCloud

static subsampleCloudWithOctree(cloud: _cloudComPy.GenericIndexedCloudPersist, newNumberOfPoints: int, subsamplingMethod: _cloudComPy.SUBSAMPLING_CELL_METHOD, progressCb: _cloudComPy.GenericProgressCallback = None, inputOctree: _cloudComPy.DgmOctree = None) _cloudComPy.ReferenceCloud

Subsamples a point cloud (process based on the octree)

Same as subsampleCloudWithOctreeAtLevel() method, apart the fact that instead of giving a specific octree subdivision level as input parameter, one can specify an approximative number of points for the resulting cloud (algorithm will automatically determine the corresponding octree level).

Parameters
  • cloud (GenericIndexedCloudPersist) – point cloud to subsample

  • newNumberOfPoints (int) – desired number of points (approximative)

  • subsamplingMethod (SUBSAMPLING_CELL_METHOD) – resampling method (applied to each octree cell) value from SUBSAMPLING_CELL_METHOD.RANDOM_POINT, SUBSAMPLING_CELL_METHOD.NEAREST_POINT_TO_CELL_CENTER

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

  • inputOctree (DgmOctree,optional) – default None, if the octree has been already computed, it can be used by the process (avoid recomputation)

Returns

a reference cloud corresponding to the subsampling ‘selection’

Return type

ReferenceCloud

static subsampleCloudWithOctreeAtLevel(cloud: _cloudComPy.GenericIndexedCloudPersist, octreeLevel: int, subsamplingMethod: _cloudComPy.SUBSAMPLING_CELL_METHOD, progressCb: _cloudComPy.GenericProgressCallback = None, inputOctree: _cloudComPy.DgmOctree = None) _cloudComPy.ReferenceCloud

Subsamples a point cloud (process based on the octree)

A subsampling algorithm is applied inside each cell of the octree. The different subsampling methods are represented as an enumerator (see SUBSAMPLING_CELL_METHOD) and consist in simple processes such as choosing a random point, or the one closest to the cell center.

Parameters
  • cloud (GenericIndexedCloudPersist) – point cloud to subsample

  • octreeLevel (int) – octree level at which to perform the subsampling process

  • subsamplingMethod (SUBSAMPLING_CELL_METHOD) – subsampling method (applied to each octree cell) value from SUBSAMPLING_CELL_METHOD.RANDOM_POINT, SUBSAMPLING_CELL_METHOD.NEAREST_POINT_TO_CELL_CENTER

  • progressCb (GenericProgressCallback,optional) – default None, the client application can get some notification of the process progress through this callback mechanism (not available yet)

  • inputOctree (DgmOctree,optional) – default None, if the octree has been already computed, it can be used by the process (avoid recomputation)

Returns

a reference cloud corresponding to the subsampling ‘selection’

Return type

ReferenceCloud

12.2. cloud sampling parameters

class cloudComPy.SFModulationParams

Bases: pybind11_object

Parameters for the scalar-field based modulation of a parameter

__init__(self: _cloudComPy.SFModulationParams) None

default constructor

property a

Modulation scheme: y = a.sf + b, float a, default 0.0

property b

Modulation scheme: y = a.sf + b, float b, default 1.0

property enabled

Whether the modulation is enabled or not, default False

class cloudComPy.RESAMPLING_CELL_METHOD

Members:

CELL_CENTER

CELL_GRAVITY_CENTER

CELL_CENTER = <RESAMPLING_CELL_METHOD.CELL_CENTER: 0>
CELL_GRAVITY_CENTER = <RESAMPLING_CELL_METHOD.CELL_GRAVITY_CENTER: 1>
__init__(self: _cloudComPy.RESAMPLING_CELL_METHOD, value: int) None
property name
property value
class cloudComPy.SUBSAMPLING_CELL_METHOD

Members:

RANDOM_POINT

NEAREST_POINT_TO_CELL_CENTER

NEAREST_POINT_TO_CELL_CENTER = <SUBSAMPLING_CELL_METHOD.NEAREST_POINT_TO_CELL_CENTER: 1>
RANDOM_POINT = <SUBSAMPLING_CELL_METHOD.RANDOM_POINT: 0>
__init__(self: _cloudComPy.SUBSAMPLING_CELL_METHOD, value: int) None
property name
property value