Mil*_*les 5 python threshold mahotas
我正在使用本教程 http://pythonvision.org/basic-tutorial
但是当我传递一个png图像时:
T = mahotas.thresholding.otsu(dna)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
TypeError:mahotas.otsu:此函数只接受整数类型(传递float32类型的数组)
有没有人有exp.这个问题?谢谢!
该错误基本上表示图像数组中元素的类型是32位浮点数,而不是整数,这是必需的.文档还说这个方法需要unsigned int.看到这里.
要将numpy数组转换为无符号8位整数,请执行以下操作:
# Assuming I is your image. Convert to 8 bit unsigned integers.
I_uint8 = I.astype('uint8')
Run Code Online (Sandbox Code Playgroud)
更新:请参阅Mahotas的创建者关于多通道图像问题的评论.