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

Point (0,0) appears falsely in pixel coordinates when using skeleton_to_csgraph #93

Open
theo258 opened this issue Aug 22, 2020 · 1 comment

Comments

@theo258
Copy link
Contributor

theo258 commented Aug 22, 2020

When we take a look at the attached image, we can observe that in the upper left corner no line/branch is present. Nevertheless with the following code the coordinates list contains the point (0,0) within the pixel coordinates, which for my understanding shouldn't be. I also think that such a behavior is not documented in the docs, although there it says that pixel_coordinates is an array of shape (Nnz + 1, skel.ndim). Is this +1 mentioned there the point (0,0)?

import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from skan import skeleton_to_csgraph

sk = io.imread('https://user-images.githubusercontent.com/60721219/90833952-67b11e00-e349-11ea-9e4b-c2ea9ae8c426.png').astype(bool)

plt.figure()
plt.imshow(sk)

graph, pixel_coordinates, degree_image = skeleton_to_csgraph(sk)

test_sk

I'm using version Skan version: 0.8 installed from conda.

@jni
Copy link
Owner

jni commented Sep 1, 2020

@theo258 apologies for the delay in responding!

Yes, this is the +1. Indeed if that point was actually part of the skeleton it would appear twice.

The reason is that the pixels in the skeleton are numbered 1..Nnz, and we want to use them to index directly into the coordinates.

Possibly, it's best to produce a number -> index map and then have exactly those coordinates in the coordinates array. scikit-image 0.17 has a new map_array function that could make this very fast. In the meantime, it might be useful to document this behaviour.

I would welcome a pull request to fix these things if you have the bandwidth, otherwise, I'll try to get to it soon. Thanks for reporting!

theo258 added a commit to theo258/skan that referenced this issue Sep 1, 2020
Added a remark that the first entry in the returning pixel_coordinates is always zero to match the index of the pixels (c.f. jni#93).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants