【发布时间】:2017-10-13 23:04:17
【问题描述】:
图像在 opencv 中存储为多维数组。但是这些数组看起来如何? (我正在提供答案,这样这个话题就永远关闭了:D)
【问题讨论】:
图像在 opencv 中存储为多维数组。但是这些数组看起来如何? (我正在提供答案,这样这个话题就永远关闭了:D)
【问题讨论】:
2d 图像(通常是我们大部分时间工作的图像)只是 array 的数组。让我创建一个灰度图像让您理解。
myArray = [[236, 189, 0],[236, 80, 189],
[236, 0, 189],
[236, 189, 0]]
myArray 是列表(或数组数组)的列表,表示宽度为 3 和高度为 4 的图像。 IE。在这个嵌套数组中,每个列表代表图像的每一行。 这是一个以图表方式显示 myarray 的代码:
myArray = [[255, 0, 189],
[236, 80, 200],
[255, 0, 200],
[200, 100, 255]]
import numpy
imgArray = numpy.array(myArray) #because normal array is not recognized , dont know why , if you know please comment
import cv2
cv2.imwrite("test.png",imgArray)
输出图像是:
【讨论】: