我尝试将多行的cv2图像数组转换为单行一个数组! 这是我的代码:
im =[]
img = cv2.imread('.jpg',0)
for i in img :
im.append(np.array(i))
print (im)
我有这个结果: [array([0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,25,255,255,255,255],dtype = uint8),array([0,0,0,0,0,0,0,0,025,05,025,055,055] ,255,255,255, 255,255,255,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0
但我需要一个行数组: ['0','0','0','255','255','255','255','254','255','255','253','255',' 254','255','254','255','254','254','255','255','255','255','255','255','255' ,'255','253','253 ........]
我做错了什么?!也许有一些基本的函数可以从cv2数组转换成单个数组?
答案 0 :(得分:1)
newarray = np.hstack(img)
print (newarray)