How to create an image from a Matrix using opencv python?

Viewed 7711

I have a matrix m filled as below(condensed version). Can you please help me to create a image from it. Such that I want all 10 in the matrix to be in different color.

m = np.array([[ 1 0 .... -1 10],  [ 10,0, ..... 0, 10] .... ]])

The dimension of this matrix is x rows and y columns.

To make it simple, I don't need a color image.

import cv2
import numpy as np
img = np.random.randint(222, size=(100, 100,3))
gen = np.array(img ,dtype=np.uint8)
cv2.imshow('i',img)
cv2.waitKey(0)
cv2.destroyWindow('i')
1 Answers
import cv2
import numpy as np
img = np.random.randint(222, size=(100, 100,3))
gen = np.array(img ,dtype=np.uint8)
cv2.imshow('i',gen)
cv2.waitKey(0)
cv2.destroyWindow('i')
Related