属性错误:模块'skimage'没有'filters'属性。

3
我有以下代码:
import cv2
import numpy as np
from PIL import Image
import skimage

my_image = cv2.imread('my_image.jpeg', 1)

gray = cv2.cvtColor(my_image, cv2.COLOR_BGR2GRAY)
b = skimage.filters.threshold_local(gray,19,offset=10)
b = Image.fromarray(b)
b = b.convert("L")
b.save('adaptive_output.png')

但是我收到了以下错误:

b = skimage.filters.threshold_local(gray,19,offset=10)
AttributeError: module 'skimage' has no attribute 'filters'

我正在使用 Python 3.8 版本,我的系统中安装的 scikit-image 版本是 0.18.1。我已经尝试在不同的集成开发环境中运行该代码,但仍然无法解决错误。

我还查看了 问题1问题2问题3,但它们的答案都无法解决我的问题。


1
你的项目中是否有另一个名为 skimage.py 的文件? - Random Davis
@RandomDavis 我已经检查过了,确认我的项目中没有名为 skimage.py 的文件。它应该存在还是不应该存在? - plpm
1个回答

5

尝试导入特定的属性。就像这样:

from skimage import filters

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接