Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change k =1 to k = 0 #5051

Conversation

ArkaprabhaChakraborty
Copy link
Contributor

Fixes #4999
Signed-off-by: ArkaprabhaChakraborty [email protected]

Signed-off-by: ArkaprabhaChakraborty <[email protected]>
@mvieth
Copy link
Member

mvieth commented Nov 29, 2021

Are you also going to push new tests which show that the previous implementation was wrong, and your changes fix it?

@ArkaprabhaChakraborty
Copy link
Contributor Author

Are you also going to push new tests which show that the previous implementation was wrong, and your changes fix it?

I need to check a new test. And then I can push the tests. By fixing I mean this bug was confirmed right :). So the testcase or use case where it triggered could be used.

@kunaltyagi kunaltyagi added the needs: more work Specify why not closed/merged yet label Dec 3, 2021
Signed-off-by: ArkaprabhaChakraborty <[email protected]>
test/filters/test_local_maximum.cpp Outdated Show resolved Hide resolved
cloud_in.height = 4;
cloud_in.width = 3;
cloud_in.is_dense = true;
cloud_in.resize (6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set the height and width if you're resizing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you resize to 6 points but you add 7 below 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes :) bad mistake :)

Copy link
Contributor Author

@ArkaprabhaChakraborty ArkaprabhaChakraborty Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set the height and width if you're resizing?

I wanted to keep some similarity with the previous test :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Older tests are not modernised. Write modern code using the features added in PCL since then. Eg: transient_push_back for all non-final points, and push_back for the final point

Signed-off-by: ArkaprabhaChakraborty <[email protected]>
@ArkaprabhaChakraborty ArkaprabhaChakraborty force-pushed the arkaprabha/fix-local-maximum branch from 906b3df to 387094b Compare December 4, 2021 08:03
@@ -146,7 +146,7 @@ pcl::LocalMaximum<PointT>::applyFilterIndices (Indices &indices)

// Check to see if a neighbor is higher than the query point
float query_z = (*input_)[iii].z;
for (std::size_t k = 1; k < radius_indices.size (); ++k) // k = 1 is the first neighbor
for (std::size_t k = 0; k < radius_indices.size (); ++k) // k = 1 is the first neighbor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the bad comment completely.

Since we are now working with all indices, we can also use a range-for loop:

for (const auto& idx: radius_indices) {
  if ((*input_)[idx].z > query.z)  // 1st loop
  point_is_visited[idx] = true;  // 2nd loop
}


LocalMaximum<PointXYZ> lm;
lm.setInputCloud (cloud_in.makeShared ());
lm.setRadius (1.0f);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mark the points (via comments) which we expect to be removed

test/filters/test_local_maximum.cpp Show resolved Hide resolved
@ArkaprabhaChakraborty
Copy link
Contributor Author

Looks like the build failed for something that is not my change :).

@ArkaprabhaChakraborty
Copy link
Contributor Author

Well nevermind :)

@mvieth
Copy link
Member

mvieth commented Dec 18, 2021

@ArkaprabhaChakraborty Could you explain briefly what your new test does, that the existing test doesn't already cover? I ran your new test with the old version of LocalMaximum, and it passes - we would like a test that shows what LocalMaximum currently does wrong, so it should fail with old, not-yet-fixed version of LocalMaximum.
Side note: you didn't address all of Kunal's review comments yet

@ArkaprabhaChakraborty
Copy link
Contributor Author

ArkaprabhaChakraborty commented Dec 18, 2021

@ArkaprabhaChakraborty Could you explain briefly what your new test does, that the existing test doesn't already cover? I ran your new test with the old version of LocalMaximum, and it passes - we would like a test that shows what LocalMaximum currently does wrong, so it should fail with old, not-yet-fixed version of LocalMaximum. Side note: you didn't address all of Kunal's review comments yet

Yes I need to adjust the tests. Also I need more info on this filter's working :) as I'm having some conceptual problems. So any links will do me good.

@mvieth
Copy link
Member

mvieth commented Dec 28, 2021

Yes I need to adjust the tests. Also I need more info on this filter's working :) as I'm having some conceptual problems. So any links will do me good.

I don't think that there is any paper, blog post, or similar describing the local maximum filter, but I assume you read the documentation? Paraphrasing that: for every point p, the filter searches the neighbours of p (all points within a radius), and compares the z-values of the neighbours with the z-value of p. If p has the highest z-value of all, it is removed

@ArkaprabhaChakraborty
Copy link
Contributor Author

Yes I need to adjust the tests. Also I need more info on this filter's working :) as I'm having some conceptual problems. So any links will do me good.

I don't think that there is any paper, blog post, or similar describing the local maximum filter, but I assume you read the documentation? Paraphrasing that: for every point p, the filter searches the neighbours of p (all points within a radius), and compares the z-values of the neighbours with the z-value of p. If p has the highest z-value of all, it is removed

I read the documentation. So I gotta figure out a test case which breaks the "older" Filter :) without the help of any blogs or such :). I'll report it soon. :)

@ArkaprabhaChakraborty
Copy link
Contributor Author

ArkaprabhaChakraborty commented Jan 18, 2022

@mvieth @kunaltyagi sorry for such a late reply. I did try out some tests but none of them seems to "break" the older condition. :)
Maybe some do which I couldn't figure out.

@mvieth
Copy link
Member

mvieth commented Jan 19, 2022

@mvieth @kunaltyagi sorry for such a late reply. I did try out some tests but none of them seems to "break" the older condition. :) Maybe some do which I couldn't figure out.

Could you describe what kind of tests you tried out? Then maybe we can suggest something you missed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: more work Specify why not closed/merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

the localmaximum filter bug
4 participants