从skimage.filter导入threshold_yen和threshold_isodata

0 投票
1 回答
1568 浏览
提问于 2025-04-18 07:29

我正在使用SKimage库中的不同阈值算法,当我尝试导入某些包时出现了错误,但导入其他包却没有问题。例如:

from skimage.filter import threshold_adaptive, threshold_isodata 会返回错误信息: ImportError: cannot import name threshold_isodata。我使用的是Python 2.7,并且参考了这里的文档:http://scikit-image.org/docs/dev/api/skimage.filter.html#skimage.filter.threshold_isodata

具体来说,我希望使用threshold_isodata和threshold_yen。有没有人能给我一些解决这个错误的建议?或者,有没有其他包使用相同的算法?

1 个回答

2

正如评论中提到的,threshold_isodata 这个功能只在主代码库里有,也就是说在 v0.9 版本中并没有正式发布,所以会出现导入错误。

实际上,threshold_yen 在 v0.9 版本中没有正确导入到 filter 这个子包里。(这个问题在主代码库中已经修复。)在 v0.10 发布之前,你应该这样导入 threshold_yen

from skimage.filter.thresholding import threshold_yen

编辑:请注意,这个问题和答案是针对 非常旧的版本 的 scikit-image。skimage.filter 模块在 v0.11 版本中被改名为 skimage.filters

撰写回答