ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::ScalarFieldTools Class Reference

Several scalar field treatment algorithms (gradient, classification, etc.) More...

#include <ScalarFieldTools.h>

Inheritance diagram for cloudViewer::ScalarFieldTools:
Collaboration diagram for cloudViewer::ScalarFieldTools:

Static Public Member Functions

static ScalarType computeMeanScalarValue (GenericCloud *theCloud)
 Computes the mean value of a scalar field associated to a cloud. More...
 
static ScalarType computeMeanSquareScalarValue (GenericCloud *theCloud)
 Computes the mean square value of a scalar field associated to a cloud. More...
 
static int computeScalarFieldGradient (GenericIndexedCloudPersist *theCloud, PointCoordinateType radius, bool euclideanDistances, bool sameInAndOutScalarField=false, GenericProgressCallback *progressCb=nullptr, DgmOctree *theOctree=nullptr)
 
static bool applyScalarFieldGaussianFilter (PointCoordinateType sigma, GenericIndexedCloudPersist *theCloud, PointCoordinateType sigmaSF, GenericProgressCallback *progressCb=nullptr, DgmOctree *theOctree=nullptr)
 
static void multiplyScalarFields (GenericIndexedCloud *firstCloud, GenericIndexedCloud *secondCloud, GenericProgressCallback *progressCb=nullptr)
 Multiplies two scalar fields of the same size. More...
 
static void computeScalarFieldHistogram (const GenericCloud *theCloud, unsigned numberOfClasses, std::vector< int > &histo)
 Computes an histogram of the scalar field with a given number of classes. More...
 
static void computeScalarFieldExtremas (const GenericCloud *theCloud, ScalarType &minV, ScalarType &maxV)
 Compute the extreme values of a scalar field. More...
 
static unsigned countScalarFieldValidValues (const GenericCloud *theCloud)
 Count the number of valid values in a scalar field. More...
 
static bool computeKmeans (const GenericCloud *theCloud, unsigned char K, KMeanClass kmcc[], GenericProgressCallback *progressCb=nullptr)
 
static void SetScalarValueToNaN (const CCVector3 &P, ScalarType &scalarValue)
 Sets the distance value associated to a point. More...
 
static void SetScalarValueToZero (const CCVector3 &P, ScalarType &scalarValue)
 Sets the distance value associated to a point to zero. More...
 
static void SetScalarValueInverted (const CCVector3 &P, ScalarType &scalarValue)
 

Static Protected Member Functions

static bool computeMeanGradientOnPatch (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 
static bool computeCellGaussianFilter (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 

Detailed Description

Several scalar field treatment algorithms (gradient, classification, etc.)

This toolbox provides several algorithms to apply treatments and handle scalar fields

Definition at line 35 of file ScalarFieldTools.h.

Member Function Documentation

◆ applyScalarFieldGaussianFilter()

bool ScalarFieldTools::applyScalarFieldGaussianFilter ( PointCoordinateType  sigma,
GenericIndexedCloudPersist theCloud,
PointCoordinateType  sigmaSF,
GenericProgressCallback progressCb = nullptr,
DgmOctree theOctree = nullptr 
)
static

Computes a spatial gaussian filter on a scalar field associated to a point cloud The "amplitutde" of the Gaussian filter must be specified (sigma). As 99% of the Gaussian distribution is between -3*sigma and +3*sigma around the mean value, this filter will only look for neighbors within a sphere of radius 3*sigma. One can also use the filter as a Bilateral filter. In this case the weights are computed considering the difference of the neighbors SF values with the current point SF value (also following a Gaussian distribution). Warning: this method assumes the input scalar field is different from the output one.

Parameters
sigmafilter variance
theClouda point cloud (associated to scalar values)
sigmaSFif strictly positive, the variance for the Bilateral filter
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
theOctreethe octree, if it has already been computed
Returns
success

Definition at line 231 of file ScalarFieldTools.cpp.

References cloudViewer::DgmOctree::build(), computeCellGaussianFilter(), cloudViewer::GenericCloud::enableScalarField(), cloudViewer::DgmOctree::executeFunctionForAllCellsAtLevel(), cloudViewer::DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(), cloudViewer::GenericProgressCallback::setInfo(), cloudViewer::GenericProgressCallback::setMethodTitle(), cloudViewer::GenericCloud::size(), cloudViewer::GenericProgressCallback::textCanBeEdited(), and cloudViewer::GenericProgressCallback::update().

Referenced by cloudViewer::AutoSegmentationTools::frontPropagationBasedSegmentation(), and ccEntityAction::sfGaussianFilter().

◆ computeCellGaussianFilter()

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

"Cellular" function to apply a gaussian filter on the scalar values of points inside an octree cell This function is meant to be applied to all cells of the octree The method also permits to use a bilateral behaviour for the filter. This is automatically switched on if its sigmaSF parameter in additionalParameters is different than -1 (it is of the form DgmOctree::localFunctionPtr). See ScalarFieldTools::applyScalarFieldGaussianFilter. Method parameters (defined in "additionalParameters") are :

  • (PointCoordinateType*) sigma
  • (std::vector<ScalarType>*) the smoothed values
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

Definition at line 289 of file ScalarFieldTools.cpp.

References cloudViewer::DgmOctree::NearestNeighboursSearchStruct::alreadyVisitedNeighbourhoodSize, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::cellCenter, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::cellPos, cloudViewer::DgmOctree::computeCellCenter(), cloudViewer::DgmOctree::findNeighborsInASphereStartingFromCell(), cloudViewer::ReferenceCloud::getAssociatedCloud(), cloudViewer::DgmOctree::getCellPos(), cloudViewer::ReferenceCloud::getPoint(), cloudViewer::ReferenceCloud::getPointGlobalIndex(), cloudViewer::ReferenceCloud::getPointPersistentPtr(), cloudViewer::GenericCloud::getPointScalarValue(), cloudViewer::ReferenceCloud::getPointScalarValue(), cloudViewer::DgmOctree::NearestNeighboursSearchStruct::level, cloudViewer::DgmOctree::octreeCell::level, NAN_VALUE, nProgress, cloudViewer::NormalizedProgress::oneStep(), cloudViewer::DgmOctree::octreeCell::parentOctree, cloudViewer::DgmOctree::octreeCell::points, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::pointsInNeighbourhood, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::queryPoint, cloudViewer::ReferenceCloud::setPointScalarValue(), cloudViewer::ReferenceCloud::size(), cloudViewer::DgmOctree::octreeCell::truncatedCode, and cloudViewer::ScalarField::ValidValue().

Referenced by applyScalarFieldGaussianFilter().

◆ computeKmeans()

bool ScalarFieldTools::computeKmeans ( const GenericCloud theCloud,
unsigned char  K,
KMeanClass  kmcc[],
GenericProgressCallback progressCb = nullptr 
)
static

Classifies automaticaly a scalar field in K classes with the K-means algorithm The initial K classes positions are regularly spaced between the lowest and the highest values of the scalar field. Eventually the algorithm will converge and produce K classes.

Parameters
theClouda point cloud (associated to scalar values)
Kthe number of classes
kmccan array of size K which will be filled with the computed classes limits (see ScalarFieldTools::KmeanClass)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)

Definition at line 520 of file ScalarFieldTools.cpp.

References abs(), computeScalarFieldExtremas(), cloudViewer::GenericCloud::getPointScalarValue(), cloudViewer::KMeanClass::maxValue, cloudViewer::KMeanClass::mean, cloudViewer::KMeanClass::minValue, cloudViewer::GenericProgressCallback::setInfo(), cloudViewer::GenericProgressCallback::setMethodTitle(), cloudViewer::GenericCloud::size(), cloudViewer::GenericProgressCallback::start(), cloudViewer::GenericProgressCallback::stop(), cloudViewer::GenericProgressCallback::textCanBeEdited(), cloudViewer::GenericProgressCallback::update(), and cloudViewer::ScalarField::ValidValue().

◆ computeMeanGradientOnPatch()

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

"Cellular" function to compute the gradient norms of points inside an octree cell This function is meant to be applied to all cells of the octree (it is of the form DgmOctree::localFunctionPtr). See ScalarFieldTools::computeScalarFieldGradient. Method parameters (defined in "additionalParameters") are :

  • (GenericCloud*) the point cloud
  • (bool*) specifies if the scalar values are euclidean distances
  • (PointCoordinateType*) radius
  • (std::vector<ScalarType>*) the gradient norms container
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

Definition at line 113 of file ScalarFieldTools.cpp.

References cloudViewer::DgmOctree::NearestNeighboursSearchStruct::alreadyVisitedNeighbourhoodSize, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::cellCenter, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::cellPos, cloudViewer::DgmOctree::computeCellCenter(), cloudViewer::DgmOctree::findNeighborsInASphereStartingFromCell(), cloudViewer::ReferenceCloud::getAssociatedCloud(), cloudViewer::DgmOctree::getCellPos(), cloudViewer::DgmOctree::getCellSize(), cloudViewer::ReferenceCloud::getPoint(), cloudViewer::ReferenceCloud::getPointGlobalIndex(), cloudViewer::ReferenceCloud::getPointPersistentPtr(), cloudViewer::ReferenceCloud::getPointScalarValue(), cloudViewer::DgmOctree::NearestNeighboursSearchStruct::level, cloudViewer::DgmOctree::octreeCell::level, NAN_VALUE, cloudViewer::DgmOctree::octreeCell::parentOctree, cloudViewer::DgmOctree::octreeCell::points, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::pointsInNeighbourhood, cloudViewer::DgmOctree::NearestNeighboursSphericalSearchStruct::prepare(), cloudViewer::DgmOctree::NearestNeighboursSearchStruct::queryPoint, cloudViewer::ReferenceCloud::size(), cloudViewer::DgmOctree::octreeCell::truncatedCode, and cloudViewer::ScalarField::ValidValue().

Referenced by computeScalarFieldGradient().

◆ computeMeanScalarValue()

ScalarType ScalarFieldTools::computeMeanScalarValue ( GenericCloud theCloud)
static

Computes the mean value of a scalar field associated to a cloud.

Returns the mean of SF values associated to each point of a cloud Warning: be sure to activate an OUTPUT scalar field on the cloud

Parameters
theCloudthe point cloud
Returns
the associated scalar field mean value

Definition at line 695 of file ScalarFieldTools.cpp.

References count, cloudViewer::GenericCloud::getPointScalarValue(), NAN_VALUE, cloudViewer::GenericCloud::size(), and cloudViewer::ScalarField::ValidValue().

Referenced by cloudViewer::FastMarchingForPropagation::init().

◆ computeMeanSquareScalarValue()

ScalarType ScalarFieldTools::computeMeanSquareScalarValue ( GenericCloud theCloud)
static

Computes the mean square value of a scalar field associated to a cloud.

Returns the mean of squared SF values associated to each point of a cloud Warning: be sure to activate an OUTPUT scalar field on the cloud

Parameters
theCloudthe point cloud
Returns
the associated scalar field mean of squares value

Definition at line 716 of file ScalarFieldTools.cpp.

References count, cloudViewer::GenericCloud::getPointScalarValue(), NAN_VALUE, cloudViewer::GenericCloud::size(), and cloudViewer::ScalarField::ValidValue().

◆ computeScalarFieldExtremas()

void ScalarFieldTools::computeScalarFieldExtremas ( const GenericCloud theCloud,
ScalarType &  minV,
ScalarType &  maxV 
)
static

Compute the extreme values of a scalar field.

Parameters
theClouda point cloud, with a scalar field activated
minVa field to store the minimum value
maxVa field to store the maximum value

Definition at line 419 of file ScalarFieldTools.cpp.

References cloudViewer::GenericCloud::getPointScalarValue(), NAN_VALUE, cloudViewer::GenericCloud::size(), and cloudViewer::ScalarField::ValidValue().

Referenced by computeKmeans(), computeScalarFieldHistogram(), define_ScalarFieldTools(), and cloudViewer::CloudSamplingTools::resampleCloudSpatially().

◆ computeScalarFieldGradient()

int ScalarFieldTools::computeScalarFieldGradient ( GenericIndexedCloudPersist theCloud,
PointCoordinateType  radius,
bool  euclideanDistances,
bool  sameInAndOutScalarField = false,
GenericProgressCallback progressCb = nullptr,
DgmOctree theOctree = nullptr 
)
static

Computes the geometrical gradient of a scalar field associated to a point cloud See Daniel Girardeau-Montaut's PhD manuscript (Chapter 3, section 3.3.2) for more information. As explained in this section, if the scalar field corresponds to (euclidean) distances between the points and another entity, then it is possible to filter out aberrant values.

Parameters
theClouda point cloud (associated to scalar values)
radiusspherical neighborhood size (or 0 for automatic size)
euclideanDistancesindicates if the scalar values are euclidean distances
sameInAndOutScalarFieldspecifies that the 'in' and 'out' scalar field of the input point cloud are the same structure
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
theOctreethe octree, if it has already been computed
Returns
error code (0 if ok)

Definition at line 37 of file ScalarFieldTools.cpp.

References AVERAGE_NUMBER_OF_POINTS_FOR_GRADIENT_COMPUTATION, cloudViewer::DgmOctree::build(), computeMeanGradientOnPatch(), cloudViewer::GenericCloud::enableScalarField(), cloudViewer::DgmOctree::executeFunctionForAllCellsAtLevel(), cloudViewer::DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(), cloudViewer::DgmOctree::findBestLevelForAGivenPopulationPerCell(), cloudViewer::DgmOctree::getCellSize(), octreeLevel, CCShareable::release(), cloudViewer::ScalarField::reserveSafe(), result, and cloudViewer::GenericCloud::size().

Referenced by ccLibAlgorithms::ApplyCCLibAlgorithm(), ccTrace::buildGradientCost(), and cloudViewer::AutoSegmentationTools::frontPropagationBasedSegmentation().

◆ computeScalarFieldHistogram()

void ScalarFieldTools::computeScalarFieldHistogram ( const GenericCloud theCloud,
unsigned  numberOfClasses,
std::vector< int > &  histo 
)
static

Computes an histogram of the scalar field with a given number of classes.

The scalar values are projected in a given number of classes, regularly spaced between the lowest and the highest value of the scalar field.

Parameters
theClouda point cloud (associated to scalar values)
numberOfClassesnumber of histogram classes
histonumber of elements per histogram class

Definition at line 464 of file ScalarFieldTools.cpp.

References computeScalarFieldExtremas(), cloudViewer::GenericCloud::getPointScalarValue(), cloudViewer::GenericCloud::size(), and cloudViewer::ScalarField::ValidValue().

◆ countScalarFieldValidValues()

unsigned ScalarFieldTools::countScalarFieldValidValues ( const GenericCloud theCloud)
static

Count the number of valid values in a scalar field.

Parameters
theClouda point cloud, with a scalar field activated

Definition at line 447 of file ScalarFieldTools.cpp.

References count, cloudViewer::GenericCloud::getPointScalarValue(), cloudViewer::GenericCloud::size(), and cloudViewer::ScalarField::ValidValue().

Referenced by cloudViewer::WeibullDistribution::computeChi2Dist(), and cloudViewer::NormalDistribution::computeChi2Dist().

◆ multiplyScalarFields()

void ScalarFieldTools::multiplyScalarFields ( GenericIndexedCloud firstCloud,
GenericIndexedCloud secondCloud,
GenericProgressCallback progressCb = nullptr 
)
static

Multiplies two scalar fields of the same size.

The first scalar field is updated (S1 = S1*S2).

Parameters
firstCloudthe first point cloud (associated to scalar values)
secondCloudthe second point cloud (associated to scalar values)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)

Definition at line 399 of file ScalarFieldTools.cpp.

References cloudViewer::GenericCloud::getPointScalarValue(), NAN_VALUE, cloudViewer::GenericCloud::setPointScalarValue(), cloudViewer::GenericCloud::size(), and cloudViewer::ScalarField::ValidValue().

◆ SetScalarValueInverted()

void ScalarFieldTools::SetScalarValueInverted ( const CCVector3 P,
ScalarType &  scalarValue 
)
static

Definition at line 32 of file ScalarFieldTools.cpp.

◆ SetScalarValueToNaN()

void ScalarFieldTools::SetScalarValueToNaN ( const CCVector3 P,
ScalarType &  scalarValue 
)
static

Sets the distance value associated to a point.

Generic function that can be used with the GenericCloud::foreach() method.

Parameters
Pa 3D point
scalarValueits associated scalar value

Definition at line 22 of file ScalarFieldTools.cpp.

References NAN_VALUE.

Referenced by cloudViewer::DistanceComputationTools::computeCloud2MeshDistances(), cloudViewer::DistanceComputationTools::computeGeodesicDistances(), and define_ScalarFieldTools().

◆ SetScalarValueToZero()

void ScalarFieldTools::SetScalarValueToZero ( const CCVector3 P,
ScalarType &  scalarValue 
)
static

Sets the distance value associated to a point to zero.

Generic function that can be used with the GenericCloud::foreach() method.

Parameters
Pa 3D point
scalarValueits associated scalar value

Definition at line 27 of file ScalarFieldTools.cpp.

Referenced by cloudViewer::GeometricalAnalysisTools::FlagDuplicatePoints().


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