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
Implementation of the Modified Hausdorff Distance (MHD) metric #5581
Conversation
Hello @robinthibaut! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-01-05 17:41:34 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good addition and should be simple to maintain. The method seems well known (the conference publication has >1800 citations on google scholar).
The code itself looks good, my only comment was whether we should incorporate it as an option in the existing function to reduce duplication.
skimage/metrics/set_metrics.py
Outdated
np.mean(cKDTree(a_points).query(b_points, k=1)[0]), | ||
np.mean(cKDTree(b_points).query(a_points, k=1)[0]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am mistaken, the only difference with the existing function is the change from np.max
to np.mean
here.
Given, that I am wondering if it would be better to just add an optional modified
keyword-only argument to the existing function instead? (defaulting to False for backwards compatibility). What do others think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, and I concur with your suggestion that adding a modified
keyword to the original function would be more pythonic.
What course of action should we take? Should I combine the two functions as described above and commit the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robinthibaut, sorry I had missed this question. Yes, please just add the kwarg
and code path to the original function and then remove this new function.
A "Notes" section in the docstring can be used to describe the difference for the "modified" case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grlee77 I made the changes, and I hope it is now satisfactory.
Co-authored-by: Gregory R. Lee <grlee77@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @robinthibaut, this looks good to me now. I just made two small stylistic commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @robinthibaut, LGTM. I just left a style suggestion 😉
Thank you @rfezzani ! I made the changes according to your suggestion 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Merging! Thank you @robinthibaut 👏
Description
Greetings,
In the file
skimage/metrics/set metric.py
, I included the Modified Hausdorff Distance function. This brilliant library, I believe, would benefit greatly from the addition of this function. Dubuisson et al. [1] demonstrated that the Modified Hausdorff Distance (MHD) outperforms the directed Hausdorff Distance (HD).I implemented unit tests and the benchmark for the new function in accordance with the contributing guidelines.
Best,
Robin
Reference
[1] M. P. Dubuisson and A. K. Jain. A Modified Hausdorff distance for object
matching. In ICPR94, pages A:566-568, Jerusalem, Israel, 1994.
http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=576361
Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.