| 119 | |
| 120 | |
| 121 | void NeighborClassifierFilter::doOneNoDomain(PointRef &point, PointRef &temp, |
| 122 | KD3Index &kdi) |
| 123 | { |
| 124 | PointIdList iSrc = kdi.neighbors(point, m_k); |
| 125 | double thresh = iSrc.size()/2.0; |
| 126 | |
| 127 | // vote NNs |
| 128 | using CountMap = std::map<int, unsigned int>; |
| 129 | CountMap counts; |
| 130 | //std::map<int, unsigned int> counts; |
| 131 | for (PointId id : iSrc) |
| 132 | { |
| 133 | temp.setPointId(id); |
| 134 | counts[temp.getFieldAs<int>(m_dimId)]++; |
| 135 | } |
| 136 | |
| 137 | // pick winner of the vote |
| 138 | auto pr = *std::max_element(counts.begin(), counts.end(), |
| 139 | [](CountMap::const_reference p1, CountMap::const_reference p2) |
| 140 | { return p1.second < p2.second; }); |
| 141 | |
| 142 | // update point |
| 143 | auto oldclass = point.getFieldAs<int>(m_dimId); |
| 144 | auto newclass = pr.first; |
| 145 | if (pr.second > thresh && oldclass != newclass) |
| 146 | m_newClass[point.pointId()] = newclass; |
| 147 | } |
| 148 | |
| 149 | // update point. kdi and temp both reference the NN point cloud |
| 150 | bool NeighborClassifierFilter::doOne(PointRef& point, PointRef &temp, |
nothing calls this directly
no test coverage detected