8000 [WIP] Hausdorff Distance (new) by clementkng · Pull Request #4005 · scikit-image/scikit-image · GitHub
[go: up one dir, main page]

Skip to content

[WIP] Hausdorff Distance (new) #4005

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

Closed
wants to merge 712 commits into from

Conversation

clementkng
Copy link
Contributor
@clementkng clementkng commented Jul 11, 2019

Description

Supersedes gh-742.

This is my attempt to fix the feedback on @josteinbf 's Hausdorff distance PR and add docs, examples, and extra tests. I've changed the methods to a single hausdorff_distance method to be more clear.

Existing discussion at gh-738. WIP b/c I still need to add benchmarks and gallery examples.

Pinging the original people that still had feedback open on the original PR: @stefanv @tonysyu @ahojnnes @emmanuelle @jni @alexandrejaguar

Checklist

Gallery Example Output

image

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

@clementkng
Copy link
Contributor Author

Is this considered a new feature/do I need to provide a gallery example for this?

@clementkng
Copy link
Contributor Author

Hi, I'm not sure under what existing gallery section should I put the gallery example?

@jni
Copy link
Member
jni commented Jul 25, 2019

@clementkng possibly the function should now be moved to the new metrics module. You could potentially use an example comparing two binary segmentations?

@pep8speaks
Copy link
pep8speaks commented Jul 25, 2019

Hello @clementkng! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-06 23:51:54 UTC

@clementkng
Copy link
Contributor Author

@jni Thanks! Just to be clear, I would put the hausdorff algo in the metrics section, then start a new section under doc/examples to show the gallery example? I'm not exactly sure what you mean by "two binary segmentations". I was able to put a gallery example together based on the other examples I saw, and was also wondering whether I was in the right ballpark w/ what I got so far. I've pushed it as a WIP.

coords_b[(x, y)] = True

# Call the hausdorff function on the coordinates
measure.set_metrics.hausdorff_distance(coords_a, coords_b)
Copy link
Member

Choose a reason for hiding this comment

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

I would change this to

from skimage import metrics

metrics.hausdorff_distance(coords_a, coords_b)

I'm also confused that you have given images as input instead of coordinates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put image in because for now, the hausdorff_distance algorithm takes in coordinates. I then use the image to render a plot of the the points passed in.


ax.imshow(image, cmap=plt.cm.gray)
ax.axis((0, 600, 600, 0))
plt.show()
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a screenshot of the output as a comment?

8000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean a comment w/i the code (I'm not fully sure how to do that) or w/i the issue i.e. in the PR description?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jni I've added the output into the description of the PR for now. Let me know if you meant something else.

Copy link
Member

Choose a reason for hiding this comment

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

This was right, sorry that I didn't respond at the time!

@jni
8000 Copy link
Member
jni commented Aug 1, 2019

@clementkng there's definitely something wrong with that drawing. The Hausdorff distance is the largest shortest distance between points in either set. The wikipedia page has a clear drawing. In this case, the point at the top of the kite clearly has closer neighbours in the diamond!

@@ -0,0 +1,70 @@
from __future__ import print_function, division
Copy link
Member

Choose a reason for hiding this comment

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

These can be removed since we don't support Python 2 anymore.

b_points = np.transpose(np.nonzero(b))

if a_points.ndim != 2 or b_points.ndim != 2:
raise ValueError('Both input arrays must be two-dimensional')
Copy link
Member

Choose a reason for hiding this comment

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

This will never happen, so it can be removed.

@clementkng
Copy link
Contributor Author

@jni Thanks for the feedback! In that case, I suspect there's something wrong w/ the original algorithm or my understanding of it, but thank you for confirming my suspicions.

@clementkng
Copy link
Contributor Author

Hi @jni, I've fixed up the gallery example and code. Hopefully it's more clear this time around!

@clementkng
Copy link
Contributor Author

@jni I was also able to clear up the bento issue that was failing the Travis builds.

@clementkng
Copy link
Contributor Author
clementkng commented Dec 30, 2019

Hi @jni, I was wondering if scikit image was still interested in having this feature? I accidentally messed up this PR due to git issues, but can work to get an updated PR out.

@jni
Copy link
Member
jni commented Dec 30, 2019

@clementkng we absolutely are! I have often stopped on this PR to check whether I could update it myself, but other priorities drew me away. If you can submit a clean PR I'll push it to the top of my stack. =) Thank you!

@clementkng clementkng mentioned this pull request Dec 31, 2019
9 tasks
@clementkng
Copy link
Contributor Author

Thanks @jni! The updated PR is here 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0