You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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()
Version information:
No response
The text was updated successfully, but these errors were encountered: