我无法让skimage函数在Python上使用mark_boundaries创建轮廓蒙版
import skimage.segmentation as seg
import skimage.color as color
from skimage import restoration
from skimage import img_as_float
%matplotlib inline
image=io.imread('C:\\...\\...\\input.png')
im_float = img_as_float ( image )
im_denoised = restoration.denoise_nl_means(im_float, h=0.05)
plt . imshow ( im_denoised , cmap = 'gray' )
def image_show(image, nrows=1, ncols=1, cmap='gray'):
fig, ax = plt.subplots(nrows=nrows, ncols=ncols, figsize=(25, 14))
ax.imshow(image, cmap='gray')
ax.axis('off')
return fig, ax
image_show(color.label2rgb(image_slic,im_denoised,kind='avg'))
image_felzenszwalb=seg.felzenszwalb(im_denoised)
image_felzenszwalb_colored=color.label2rgb(image_felzenszwalb,im_denoised,
kind='avg')
image_show(image_felzenszwalb_colored)
#mark_boundaries
mask=seg.mark_boundaries(image_felzenszwalb_colored,label_img
('segmentation_mask'),
color=1,1,1),background_label=None)
我收到了:
〜\ Anaconda3 \ envs \ py37 \ lib \ site-packages \ skimage \ segmentation \ boundaries.py在find_boundaries中(label_img,连接性,模式,背景)156 [False,True,True,False,False]],dtype = bool)157“”“-> 158,如果label_img.dtype =='bool':159 label_img = label_img.astype(np.uint8)160 ndim = label_img.ndim AttributeError:'str'对象没有属性'dtype < / p>
怎么了?