I have a 2D python list named image
, the array contain only integer in the range from 0-255.
For example, the list is like this
image = [[0, 39, 57], [255, 182, 124], [19, 223, 200], [176, 190, 100]]
I have read How to convert a python numpy array to an RGB image with Opencv 2.4?, so i converted the python list to numpy array
image = np.asarray(image)
I could run the following
cv2.imwrite('image.jpg', image)
But how do i load the array as image directly without saving it to file ? something like this
opencvImage = cv2.imread(image, 0)
The above code obviously don't work, so how do i load python list or numpy array directly to opencv without saving it as file? the expected image output is rgb image or greyscale image, and the expected shape is the shape of the list/array itself.
The following code also don't work, i also don't understand why i can save the numpy array as image file but opencv cannot show it directly
cv2.imshow("image", image)
The code above throws assertionfailed error from opencv