我正在尝试创建一个16位的图像,如下所示:
import skimage
import random
from random import randint
xrow=raw_input("Enter the number of rows to be present in image.=>")
row=int(xrow)
ycolumn=raw_input("Enter the number of columns to be present in image.=>")
column=int(ycolumn)
A={}
for x in xrange(1,row):
for y in xrange(1,column):
a=randint(0,65535)
A[x,y]=a
imshow(A)
但是我得到了错误TypeError: Image data can not convert to float
。
发布于 2018-02-21 17:02:49
这个问题首先出现在Google搜索中,查找此类型错误,但没有关于错误原因的一般答案。发帖者的独特问题是使用了不适当的对象类型作为plt.imshow()
的主要参数。更普遍的答案是,plt.imshow()
需要一个浮点数组,如果不指定float
、numpy、pandas或其他任何类型,可能会推断出一种不同的数据类型。可以通过为对象的构造函数dtype
参数指定一个float
来避免这种情况。
发布于 2017-06-14 19:39:23
当我试图绘制imagePath而不是图像本身时,就会发生这种情况。修复方法是加载图像并绘制它。
发布于 2018-09-12 03:23:45
当我无意中尝试绘制图像路径而不是图像时,出现了错误。
我的代码:
import cv2 as cv
from matplotlib import pyplot as plt
import pytesseract
from resizeimage import resizeimage
img = cv.imread("D:\TemplateMatch\\fitting.png") ------>"THIS IS THE WRONG USAGE"
#cv.rectangle(img,(29,2496),(604,2992),(255,0,0),5)
plt.imshow(img)
更正:img = cv.imread("fitting.png")
->这是正确的用法“
https://stackoverflow.com/questions/32302180
复制相似问题