MCPcopy Create free account
hub / github.com/PDAL/PDAL / filter

Method filter

filters/ApproximateCoplanarFilter.cpp:80–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79
80void ApproximateCoplanarFilter::filter(PointView& view)
81{
82 const KD3Index& kdi = view.build3dIndex();
83
84 for (PointRef p : view)
85 {
86 // find the k-nearest neighbors
87 PointIdList ids = kdi.neighbors(p, m_knn);
88
89 // compute covariance of the neighborhood
90 Matrix3d B = math::computeCovariance(view, ids);
91
92 // Check if the covariance matrix is all zeros
93 if (B.isZero())
94 {
95 log()->get(LogLevel::Info)
96 << "Skipping point " << p.pointId()
97 << ". Covariance matrix is all zeros. This suggests a large "
98 "number of redundant points. Consider using filters.sample "
99 "with a small radius to remove redundant points.\n";
100 continue;
101 }
102
103 // perform the eigen decomposition
104 Eigen::SelfAdjointEigenSolver<Matrix3d> solver(B);
105 if (solver.info() != Eigen::Success)
106 throwError("Cannot perform eigen decomposition.");
107 Vector3d ev = solver.eigenvalues();
108
109 // test eigenvalues to label points that are approximately coplanar
110 if ((ev[1] > m_thresh1 * ev[0]) && (m_thresh2 * ev[1] > ev[2]))
111 p.setField(Id::Coplanar, 1u);
112 else
113 p.setField(Id::Coplanar, 0u);
114 }
115}
116
117} // namespace pdal

Callers

nothing calls this directly

Calls 5

computeCovarianceFunction · 0.85
logFunction · 0.50
neighborsMethod · 0.45
getMethod · 0.45
setFieldMethod · 0.45

Tested by

no test coverage detected