深度学习scipy.misc语法错误在imread.image.io上的体现

问题描述 投票:0回答:1

我有一段python代码,目的是提取字母并标记包含图像的每个区域。

我得到以下错误。

NameError Traceback (最近一次调用)

在()1

---> 2 image = imageio.imread(')https:/pbs.twimg.comrofile_images9857921117139476487YD1ZYpe_400x400.jpg。') 3 4 5

NameError: name 'imageio' is not defined````。

下面是完整的代码。

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from scipy.misc import imageio.imread,imresize
from skimage.segmentation import clear_border
from skimage.morphology import label
from skimage.measure import regionprops

image = imageio.imread('https://pbs.twimg.com/profile_images/985792111713947648/7YD1ZYpe_400x400.jpg')



#apply threshold in order to make the image binary
bw = image < 120

# remove artifacts connected to image border
cleared = bw.copy()
clear_border(cleared)

# label image regions
label_image = label(cleared,neighbors=8)
borders = np.logical_xor(bw, cleared)
label_image[borders] = -1

print(label_image.max())

fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
ax.imshow(bw, cmap='jet')


python deep-learning scipy feature-extraction
1个回答
0
投票

你使用的是一个尚未导入的包中的函数。首先你需要在你的系统中安装imageio(pip install imageio),然后在代码中包含它(并删除其他imread)。新的代码将是。

import imageio
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from skimage.segmentation import clear_border
from skimage.morphology import label

如果你要使用imresize,你需要安装枕头。

© www.soinside.com 2019 - 2024. All rights reserved.