Skip to content

Commit 4dbd5c3

Browse files
committed
Fix bug in LocalMaximum filter
1 parent fa5224d commit 4dbd5c3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

filters/include/pcl/filters/impl/local_maximum.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ pcl::LocalMaximum<PointT>::applyFilterIndices (Indices &indices)
121121
// not be maximal in their own neighborhood
122122
if (point_is_visited[iii] && !point_is_max[iii])
123123
{
124+
if (negative_) {
125+
if (extract_removed_indices_) {
126+
(*removed_indices_)[rii++] = iii;
127+
}
128+
}
129+
else {
130+
indices[oii++] = iii;
131+
}
124132
continue;
125133
}
126134

@@ -146,7 +154,7 @@ pcl::LocalMaximum<PointT>::applyFilterIndices (Indices &indices)
146154

147155
// Check to see if a neighbor is higher than the query point
148156
float query_z = (*input_)[iii].z;
149-
for (std::size_t k = 1; k < radius_indices.size (); ++k) // k = 1 is the first neighbor
157+
for (std::size_t k = 0; k < radius_indices.size (); ++k) // the query point itself is in the (unsorted) radius_indices, but that is okay since we compare with ">"
150158
{
151159
if ((*input_)[radius_indices[k]].z > query_z)
152160
{
@@ -160,7 +168,7 @@ pcl::LocalMaximum<PointT>::applyFilterIndices (Indices &indices)
160168
// visited, excluding them from future consideration as local maxima
161169
if (point_is_max[iii])
162170
{
163-
for (std::size_t k = 1; k < radius_indices.size (); ++k) // k = 1 is the first neighbor
171+
for (std::size_t k = 0; k < radius_indices.size (); ++k) // the query point itself is in the (unsorted) radius_indices, but it must also be marked as visited
164172
{
165173
point_is_visited[radius_indices[k]] = true;
166174
}

0 commit comments

Comments
 (0)