Reputation: 2045
I have a RGB dataset like that:
[[ 255 165 0]
[255 255 0]
[0 255 0]]
I want to show each row's color,separate 3 PNG images, each 64x64 pixels Is there some method existed in matplotlib or opencv?
Upvotes: 1
Views: 917
Reputation: 207405
In OpenCV (and most other Python imaging libraries) an image is represented by a Numpy array. So, if you want to make a 3-channel (i.e. colour) image full of [255, 165, 0] you just need:
import cv2
import numpy as np
# Make 64x64 pixel colour image
im = np.full((64,64,3), [255,165,0], dtype=np.uint8)
# Save to disk
cv2.imwrite('result.png', im)
Note that OpenCV uses BGR ordering, so if your 3 values are in fact RGB, you need:
im = np.full((64,64,3), [0,165,255], dtype=np.uint8)
Upvotes: 3