8000 Feature request: points to labels · Issue #5087 · scikit-image/scikit-image · GitHub
[go: up one dir, main page]

Skip to content

Feature request: points to labels #5087

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
jni opened this issue Nov 29, 2020 · 5 comments
Closed

Feature request: points to labels #5087

jni opened this issue Nov 29, 2020 · 5 comments
Labels
🔰 Good first issue A good task for those new to the library 🙏 Feature request

Comments

@jni
Copy link
Member
jni commented Nov 29, 2020

Description

I find myself repeating the following lines very often:

coords = ... # something that gives me an (npoints, ndim) array
indices = tuple(np.transpose(np.round(coords).astype(int)))
labels = np.zeros_like(image, dtype=np.uint32)
labels[indices] = np.arange(1, len(coords) + 1)

This is required for example to take a set of centroids and turn them into markers for watershed.

I think it would be great for skimage to provide a utility function to do this.

@jni jni added 🔰 Good first issue A good task for those new to the library type: new feature labels Nov 29, 2020
@emmanuelle
Copy link
Member

Good idea. Should it be in segmentation or in utils?

@jni
Copy link
Member Author
jni commented Dec 2, 2020

A great question. I don't have a strong preference. Maybe we reopen #1608? =P

@harish-vnkt
Copy link
Contributor

Hi, @jni. First timer in open source and would like to work on this issue. :)
Would it be enough to have a function that takes centroid coordinates and the image as arguments and uses ndi.label to assign labels to the centroids? Also, any idea on which module this function belongs to?

@jni
Copy link
Member Author
jni commented Dec 23, 2020

@harish-vnkt Hello! I think that approach will be slower than using the direct assignment in the above code snippet.

Regarding module, I'm not sure, nor do I know what the best name is. skimage.util.points_to_labels? skimage.segmentation.points_to_label_image? Some combination of the above? But, might as well open the PR and get the ball rolling! 😊

@jni
Copy link
Member Author
jni commented Feb 1, 2021

Closed by #5180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔰 Good first issue A good task for those new to the library 🙏 Feature request
Projects
None yet
Development

No branches or pull requests

4 participants
0