-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Labels
Comments
@Huizhong-Wu hi, thanks for reporting! Could you provide the versions of your |
@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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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()
![Sample_1](https://private-user-images.githubusercontent.com/154685297/329763475-ac174fed-f0ea-4a72-8629-6d3b8bec5f4e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTU3MzIsIm5iZiI6MTcxODUxNTQzMiwicGF0aCI6Ii8xNTQ2ODUyOTcvMzI5NzYzNDc1LWFjMTc0ZmVkLWYwZWEtNGE3Mi04NjI5LTZkM2I4YmVjNWY0ZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxNlQwNTIzNTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ZTY4ZjE0MmE3MDRlMTliMTM0NDcxODEzNjhlZDIxNDlmYTZjYmU3MTgxYzk0NGZlMTc3ODY0NDhjMzVhMjIxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.YQth2rWZz7z22EATHbE6TmSVpT8PL4I4dGQfgjRDICI)
![Sample_horse](https://private-user-images.githubusercontent.com/154685297/329763496-d6ff91d6-5a01-4b75-9694-5d223f28262a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTU3MzIsIm5iZiI6MTcxODUxNTQzMiwicGF0aCI6Ii8xNTQ2ODUyOTcvMzI5NzYzNDk2LWQ2ZmY5MWQ2LTVhMDEtNGI3NS05Njk0LTVkMjIzZjI4MjYyYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxNlQwNTIzNTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iNTYzZDg5ZTVhMDNiMWEwODJlYTBiN2EwZjYzYTkxOTBlNjFlZWM0MjA0YjkzYjMxNWUzMDI1ZDk2MzA0ZmQ4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.q70X6Yd-tXMohIJCTuj0CO12hv-9zVwkYaz4fjeYn50)
plt.show()
Version information:
No response
The text was updated successfully, but these errors were encountered: