CCCoreLib 31 May 2022
CloudCompare Core algorithms
Classes | Public Types | Static Public Member Functions | Static Protected Member Functions | List of all members
CCCoreLib::CloudSamplingTools Class Reference

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

#include <CloudSamplingTools.h>

Inheritance diagram for CCCoreLib::CloudSamplingTools:
Inheritance graph
[legend]
Collaboration diagram for CCCoreLib::CloudSamplingTools:
Collaboration graph
[legend]

Classes

struct  SFModulationParams
 Parameters for the scalar-field based modulation of a parameter. More...
 

Public Types

enum  RESAMPLING_CELL_METHOD { CELL_CENTER , CELL_GRAVITY_CENTER }
 Octree cell resampling methods (see CloudSamplingTools::resampleCloudWithOctree)
 
enum  SUBSAMPLING_CELL_METHOD { RANDOM_POINT , NEAREST_POINT_TO_CELL_CENTER }
 Octree cell simplifying methods (see CloudSamplingTools::subsampleCloudWithOctree)
 

Static Public Member Functions

static PointCloudresampleCloudWithOctreeAtLevel (GenericIndexedCloudPersist *cloud, unsigned char octreeLevel, RESAMPLING_CELL_METHOD resamplingMethod, GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Resamples a point cloud (process based on the octree) More...
 
static GenericIndexedCloudresampleCloudWithOctree (GenericIndexedCloudPersist *cloud, int newNumberOfPoints, RESAMPLING_CELL_METHOD resamplingMethod, GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Resamples a point cloud (process based on the octree) More...
 
static ReferenceCloudsubsampleCloudWithOctreeAtLevel (GenericIndexedCloudPersist *cloud, unsigned char octreeLevel, SUBSAMPLING_CELL_METHOD subsamplingMethod, GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Subsamples a point cloud (process based on the octree) More...
 
static ReferenceCloudsubsampleCloudWithOctree (GenericIndexedCloudPersist *cloud, int newNumberOfPoints, SUBSAMPLING_CELL_METHOD subsamplingMethod, GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Subsamples a point cloud (process based on the octree) More...
 
static ReferenceCloudsubsampleCloudRandomly (GenericIndexedCloudPersist *cloud, unsigned newNumberOfPoints, GenericProgressCallback *progressCb=nullptr)
 Subsamples a point cloud (process based on random selections) More...
 
static ReferenceCloudresampleCloudSpatially (GenericIndexedCloudPersist *cloud, PointCoordinateType minDistance, const SFModulationParams &modParams, DgmOctree *octree=nullptr, GenericProgressCallback *progressCb=nullptr)
 Resamples a point cloud (process based on inter point distance) More...
 
static ReferenceCloudsorFilter (GenericIndexedCloudPersist *cloud, int knn=6, double nSigma=1.0, DgmOctree *octree=nullptr, GenericProgressCallback *progressCb=nullptr)
 Statistical Outliers Removal (SOR) filter. More...
 
static ReferenceCloudnoiseFilter (GenericIndexedCloudPersist *cloud, PointCoordinateType kernelRadius, double nSigma, bool removeIsolatedPoints=false, bool useKnn=false, int knn=6, bool useAbsoluteError=true, double absoluteError=0.0, DgmOctree *octree=nullptr, GenericProgressCallback *progressCb=nullptr)
 Noise filter based on the distance to the approximate local surface. More...
 

Static Protected Member Functions

static bool resampleCellAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 "Cellular" function to replace one set of points (contained in an octree cell) by a unique point More...
 
static bool subsampleCellAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 "Cellular" function to select a unique point inside an octree cell More...
 
static bool applyNoiseFilterAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 "Cellular" function to apply the noise filter inside an octree cell More...
 
static bool applySORFilterAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 "Cellular" function to apply the SOR filter inside an octree cell More...
 

Detailed Description

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

Member Function Documentation

◆ applyNoiseFilterAtLevel()

bool CloudSamplingTools::applyNoiseFilterAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

"Cellular" function to apply the noise filter inside an octree cell

This function is meant to be applied to all cells of the octree (it is of the form DgmOctree::localFunctionPtr).

Parameters
cellstructure describing the cell on which processing is applied
additionalParameterssee method description
nProgressoptional (normalized) progress notification (per-point)

◆ applySORFilterAtLevel()

bool CloudSamplingTools::applySORFilterAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

"Cellular" function to apply the SOR filter inside an octree cell

This function is meant to be applied to all cells of the octree (it is of the form DgmOctree::localFunctionPtr).

Parameters
cellstructure describing the cell on which processing is applied
additionalParameterssee method description
nProgressoptional (normalized) progress notification (per-point)

◆ noiseFilter()

ReferenceCloud * CloudSamplingTools::noiseFilter ( GenericIndexedCloudPersist cloud,
PointCoordinateType  kernelRadius,
double  nSigma,
bool  removeIsolatedPoints = false,
bool  useKnn = false,
int  knn = 6,
bool  useAbsoluteError = true,
double  absoluteError = 0.0,
DgmOctree octree = nullptr,
GenericProgressCallback progressCb = nullptr 
)
static

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
cloudthe point cloud to resample
kernelRadiusneighborhood radius
nSigmanumber of sigmas under which the points should be kept
removeIsolatedPointswhether to remove isolated points (i.e. with 3 points or less in the neighborhood)
useKnnwhether to use a constant number of neighbors instead of a radius
knnnumber of neighbors (if useKnn is true)
useAbsoluteErrorwhether to use an absolute error instead of 'n' sigmas
absoluteErrorabsolute error (if useAbsoluteError is true)
octreeassociated octree if available
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
a reference cloud corresponding to the filtered cloud

◆ resampleCellAtLevel()

bool CloudSamplingTools::resampleCellAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

"Cellular" function to replace one set of points (contained in an octree cell) by a unique point

This function is meant to be applied to all cells of the octree (it is of the form DgmOctree::localFunctionPtr). It replaces all points in a cell by a unique one, according to different rules. Method parameters (defined in "additionalParameters") are :

  • (PointCloud*) point cloud to store new points
  • (RESAMPLING_CELL_METHOD*) resampling method
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

◆ resampleCloudSpatially()

ReferenceCloud * CloudSamplingTools::resampleCloudSpatially ( GenericIndexedCloudPersist cloud,
PointCoordinateType  minDistance,
const SFModulationParams modParams,
DgmOctree octree = nullptr,
GenericProgressCallback progressCb = nullptr 
)
static

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
cloudthe point cloud to resample
minDistancethe distance under which a point in the resulting cloud cannot have any neighbour
modParamsparameters of the subsampling behavior modulation with a scalar field (optional)
octreeassociated octree if available
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
a reference cloud corresponding to the resampling 'selection'

◆ resampleCloudWithOctree()

GenericIndexedCloud * CloudSamplingTools::resampleCloudWithOctree ( GenericIndexedCloudPersist cloud,
int  newNumberOfPoints,
RESAMPLING_CELL_METHOD  resamplingMethod,
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

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
cloudthe point cloud to resample
newNumberOfPointsdesired number of points (approximative)
resamplingMethodresampling method (applied to each octree cell)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif the octree has been already computed, it can be used by the process (avoid recomputation)
Returns
the resampled cloud (new cloud)

◆ resampleCloudWithOctreeAtLevel()

PointCloud * CloudSamplingTools::resampleCloudWithOctreeAtLevel ( GenericIndexedCloudPersist cloud,
unsigned char  octreeLevel,
RESAMPLING_CELL_METHOD  resamplingMethod,
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

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
cloudthe point cloud to resample
octreeLevelthe octree level at which to perform the resampling process
resamplingMethodresampling method (applied to each octree cell)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif the octree has been already computed, it can be used by the process (avoid recomputation)
Returns
the resampled cloud (new cloud)

◆ sorFilter()

ReferenceCloud * CloudSamplingTools::sorFilter ( GenericIndexedCloudPersist cloud,
int  knn = 6,
double  nSigma = 1.0,
DgmOctree octree = nullptr,
GenericProgressCallback progressCb = nullptr 
)
static

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 http://pointclouds.org/documentation/tutorials/statistical_outlier.php)

Parameters
cloudthe point cloud to resample
knnnumber of neighbors
nSigmanumber of sigmas under which the points should be kept
octreeassociated octree if available
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
a reference cloud corresponding to the filtered cloud

◆ subsampleCellAtLevel()

bool CloudSamplingTools::subsampleCellAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

"Cellular" function to select a unique point inside an octree cell

This function is meant to be applied to all cells of the octree (it is of the form DgmOctree::localFunctionPtr). It chooses one point from the set of points inside a cell, according to different rules. Method parameters (defined in "additionalParameters") are :

  • (ReferenceCloud*) reference point cloud to store selected points
  • (SUBSAMPLING_CELL_METHOD*) subampling method
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

◆ subsampleCloudRandomly()

ReferenceCloud * CloudSamplingTools::subsampleCloudRandomly ( GenericIndexedCloudPersist cloud,
unsigned  newNumberOfPoints,
GenericProgressCallback progressCb = nullptr 
)
static

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
cloudpoint cloud to subsample
newNumberOfPointsdesired number of points (exact)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
a reference cloud corresponding to the subsampling 'selection'

◆ subsampleCloudWithOctree()

ReferenceCloud * CloudSamplingTools::subsampleCloudWithOctree ( GenericIndexedCloudPersist cloud,
int  newNumberOfPoints,
SUBSAMPLING_CELL_METHOD  subsamplingMethod,
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

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
cloudpoint cloud to subsample
newNumberOfPointsdesired number of points (approximative)
subsamplingMethodresampling method (applied to each octree cell)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif the octree has been already computed, it can be used by the process (avoid recomputation)
Returns
a reference cloud corresponding to the subsampling 'selection'

◆ subsampleCloudWithOctreeAtLevel()

ReferenceCloud * CloudSamplingTools::subsampleCloudWithOctreeAtLevel ( GenericIndexedCloudPersist cloud,
unsigned char  octreeLevel,
SUBSAMPLING_CELL_METHOD  subsamplingMethod,
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

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
cloudpoint cloud to subsample
octreeLeveloctree level at which to perform the subsampling process
subsamplingMethodsubsampling method (applied to each octree cell)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif the octree has been already computed, it can be used by the process (avoid recomputation)
Returns
a reference cloud corresponding to the subsampling 'selection'

The documentation for this class was generated from the following files: