很抱歉,标题不是很有描述性,但我的问题很奇怪,至少对我来说。在
image = skiio.imread("picture.png")
greyValues = []
for i in xrange(len(image)):
greyValues.append(np.uint32(image[i][xPos]))
skimage.io.imsave("image.png",np.transpose(greyValues))
现在这个方法很好,但是我想计算沿y轴的三个条的平均值:
^{pr2}$所以我得到了这个错误:
File "C:\Anaconda2_x64\lib\site-packages\skimage\util\dtype.py", line 43, in dtype_limits imin, imax = dtype_range[image.dtype.type]
键错误:<;类型'numpy.uint32'>
在灰色值中,RGB值保存为例如:[255255255] 一开始我以为我有不同的类型,因为我除以3,所以我确保把所有的东西都投给anumpy.uint32,这可能有点不必要,但这并没有解决问题,现在我有点不知道我做错了什么。在
我又检查了一遍,100%确定:
for j in xrange(len(greyValues)):
if(greyValues[j][0].dtype!='uint32'):
print j,type(greyValues[j])
没有产出
我们将不胜感激
编辑
我更深入地研究了一下,发现这里发生了键错误:
import numpy as np
dtype_range = {np.bool_: (False, True),
np.bool8: (False, True),
np.uint8: (0, 255),
np.uint16: (0, 65535),
np.int8: (-128, 127),
np.int16: (-32768, 32767),
np.int64: (-2**63, 2**63 - 1),
np.uint64: (0, 2**64 - 1),
np.int32: (-2**31, 2**31 - 1),
np.uint32: (0, 2**32 - 1),
np.float32: (-1, 1),
np.float64: (-1, 1)}
def dtype_limits(image, clip_negative=True):
"""Return intensity limits, i.e. (min, max) tuple, of the image's dtype.
Parameters
----------
image : ndarray
Input image.
clip_negative : bool
If True, clip the negative range (i.e. return 0 for min intensity)
even if the image dtype allows negative values.
"""
imin, imax = dtype_range[image.dtype.type]
if clip_negative:
imin = 0
return imin, imax`
现在当我检查我的数据时,我使用np.transpose(GreyValues).dtype.type
我得到了确切的错误
所以当我做dtype_range[numpy.uint32]
斯派德说
NameError: name 'numpy' is not defined
那么问题是它声明np.uint32
而不是{
目前没有回答
相关问题 更多 >
编程相关推荐