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

The Skeletonize function output wrong figure. #7417

Open
Huizhong-Wu opened this issue May 11, 2024 · 3 comments
Open

The Skeletonize function output wrong figure. #7417

Huizhong-Wu opened this issue May 11, 2024 · 3 comments
Labels

Comments

@Huizhong-Wu
Copy link

Description:

Hi, I tried to extract the skeleton figures of some artificial conducts using the original code posted on the web: https://scikit-image.org/docs/stable/auto_examples/edges/plot_skeleton.html#sphx-glr-download-auto-examples-edges-plot-skeleton-py
But there was always a wrong hint: ValueError: arrays must be of dtype byte, short, float32 or float64.

So, I transformed the image datatype into float as below. Unfortunately, the output skeleton figure is wrong. I post it at the end of the code. I thought maybe the ball.png cannot be recognized by the skeletonize function, since it was colorful and a screenshot. So, I tried the sample horse picture using the revised code. As you see, the skeleton of horse was still wrong.

Is there anyone could tell me how to get the wright skeleton picture using the Skeletonize function?

Thanks a lot.
Huizhong

Way to reproduce:

from skimage.morphology import skeletonize
from skimage import data
import matplotlib.pyplot as plt
from skimage.util import invert, img_as_float

Invert the ball image

path = 'C:/Users/63517/anaconda3/pkgs/scikit-image-0.20.0-py311h3513d60_0/Lib/site-packages/skimage/data/ball.png'
image = plt.imread(path)
img_f = img_as_float(image, force_copy=False)

perform skeletonization

skeleton = skeletonize(img_f)
ske = img_as_float(skeleton, force_copy=False)

display results

fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4), sharex=True, sharey=True)

ax = axes.ravel()

ax[0].imshow(img_f, cmap=plt.cm.gray)
ax[0].axis('off')
ax[0].set_title('original', fontsize=20)

ax[1].imshow(ske, cmap=plt.cm.gray)
ax[1].axis('off')
ax[1].set_title('skeleton', fontsize=20)

fig.tight_layout()
plt.show()
Sample_1
Sample_horse

Version information:

No response

@soupault
Copy link
Member

soupault commented May 11, 2024

@Huizhong-Wu hi, thanks for reporting! Could you provide the versions of your scikit-image, scipy, and numpy?

@Huizhong-Wu
Copy link
Author

@soupault hi, the version of my scikit-image is 0.23.2, the scipy is 1.11.4, and the numpy is 1.26.2

I converted the color picture into gray-scale, but it still doesn't work.

ihc

@Huizhong-Wu
Copy link
Author

I also binarized the picture value, but the results were still not so good.
flower_binary
ball_binary

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

No branches or pull requests

2 participants