1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkStatisticalOutlierRemoval.h 5 6 Copyright (c) Kitware, Inc. 7 All rights reserved. 8 See LICENSE file for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkStatisticalOutlierRemoval 17 * @brief remove sparse outlier points 18 * 19 * 20 * The vtkStatisticalOutlierRemoval filter removes sparse outlier points 21 * through statistical analysis. The average (mean) distance between points 22 * in the point cloud is computed (taking a local sample size around each 23 * point); followed by computation of the global standard deviation of 24 * distances between points. This global, statistical information is compared 25 * against the mean separation distance for each point; those points whose 26 * average separation is greater than the user-specified variation in 27 * a multiple of standard deviation are removed. 28 * 29 * Note that while any vtkPointSet type can be provided as input, the output is 30 * represented by an explicit representation of points via a 31 * vtkPolyData. This output polydata will populate its instance of vtkPoints, 32 * but no cells will be defined (i.e., no vtkVertex or vtkPolyVertex are 33 * contained in the output). Also, after filter execution, the user can 34 * request a vtkIdType* map which indicates how the input points were mapped 35 * to the output. A value of map[i] (where i is the ith input point) less 36 * than 0 means that the ith input point was removed. (See also the 37 * superclass documentation for accessing the removed points through the 38 * filter's second output.) 39 * 40 * @warning 41 * This class has been threaded with vtkSMPTools. Using TBB or other 42 * non-sequential type (set in the CMake variable 43 * VTK_SMP_IMPLEMENTATION_TYPE) may improve performance significantly. 44 * 45 * @sa 46 * vtkPointCloudFilter vtkRadiusOutlierRemoval vtkExtractPoints 47 * vtkThresholdPoints 48 */ 49 50 #ifndef vtkStatisticalOutlierRemoval_h 51 #define vtkStatisticalOutlierRemoval_h 52 53 #include "vtkFiltersPointsModule.h" // For export macro 54 #include "vtkPointCloudFilter.h" 55 56 class vtkAbstractPointLocator; 57 class vtkPointSet; 58 59 60 class VTKFILTERSPOINTS_EXPORT vtkStatisticalOutlierRemoval : public vtkPointCloudFilter 61 { 62 public: 63 //@{ 64 /** 65 * Standard methods for instantiating, obtaining type information, and 66 * printing information. 67 */ 68 static vtkStatisticalOutlierRemoval *New(); 69 vtkTypeMacro(vtkStatisticalOutlierRemoval,vtkPointCloudFilter); 70 void PrintSelf(ostream& os, vtkIndent indent) override; 71 //@} 72 73 //@{ 74 /** 75 * For each point sampled, specify the number of the closest, surrounding 76 * points used to compute statistics. By default 25 points are used. Smaller 77 * numbers may speed performance. 78 */ 79 vtkSetClampMacro(SampleSize,int,1,VTK_INT_MAX); 80 vtkGetMacro(SampleSize,int); 81 //@} 82 83 //@{ 84 /** 85 * The filter uses this specified standard deviation factor to extract 86 * points. By default, points within 1.0 standard deviations (i.e., a 87 * StandardDeviationFactor=1.0) of the mean distance to neighboring 88 * points are retained. 89 */ 90 vtkSetClampMacro(StandardDeviationFactor,double,0.0,VTK_FLOAT_MAX); 91 vtkGetMacro(StandardDeviationFactor,double); 92 //@} 93 94 //@{ 95 /** 96 * Specify a point locator. By default a vtkStaticPointLocator is 97 * used. The locator performs efficient searches to locate points 98 * surroinding a sample point. 99 */ 100 void SetLocator(vtkAbstractPointLocator *locator); 101 vtkGetObjectMacro(Locator,vtkAbstractPointLocator); 102 //@} 103 104 //@{ 105 /** 106 * After execution, return the value of the computed mean. Before execution 107 * the value returned is invalid. 108 */ 109 vtkSetClampMacro(ComputedMean,double,0.0,VTK_FLOAT_MAX); 110 vtkGetMacro(ComputedMean,double); 111 //@} 112 113 //@{ 114 /** 115 * After execution, return the value of the computed sigma (standard 116 * deviation). Before execution the value returned is invalid. 117 */ 118 vtkSetClampMacro(ComputedStandardDeviation,double,0.0,VTK_FLOAT_MAX); 119 vtkGetMacro(ComputedStandardDeviation,double); 120 //@} 121 122 protected: 123 vtkStatisticalOutlierRemoval(); 124 ~vtkStatisticalOutlierRemoval() override; 125 126 int SampleSize; 127 double StandardDeviationFactor; 128 vtkAbstractPointLocator *Locator; 129 130 // Derived quantities 131 double ComputedMean; 132 double ComputedStandardDeviation; 133 134 // All derived classes must implement this method. Note that a side effect of 135 // the class is to populate the PointMap. Zero is returned if there is a failure. 136 int FilterPoints(vtkPointSet *input) override; 137 138 private: 139 vtkStatisticalOutlierRemoval(const vtkStatisticalOutlierRemoval&) = delete; 140 void operator=(const vtkStatisticalOutlierRemoval&) = delete; 141 142 }; 143 144 #endif 145