gpt4 book ai didi

Python 模块 Mahotas 阈值问题

转载 作者:太空狗 更新时间:2023-10-30 00:50:35 25 4
gpt4 key购买 nike

我正在使用本教程 http://pythonvision.org/basic-tutorial

但是当我传递一个 png 图像时:

T = mahotas.thresholding.otsu(dna)

我得到一个错误:

TypeError: mahotas.otsu: This function only accepts integer types (passed array of type float32)

有没有人有exp。有这个问题吗?谢谢!

最佳答案

错误基本上是说图像数组中的元素类型是 32 位 float ,而不是整数,这是必需的。文档还说这个方法需要 unsigned int。参见 here .

要将 numpy 数组转换为无符号 8 位整数,请执行以下操作:

# Assuming I is your image. Convert to 8 bit unsigned integers.
I_uint8 = I.astype('uint8')

更新:请参阅下面 Mahotas 的创建者对多 channel 图像问题的评论。

关于Python 模块 Mahotas 阈值问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20061729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com