Created
August 28, 2018 09:58
-
-
Save bafu/480e9b1923069c004e23aa0a04679928 to your computer and use it in GitHub Desktop.
Create pure color image by given RGB values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create pure color JPEG by given RGB values. | |
""" | |
import cv2 | |
import numpy as np | |
def paint_it_color(rgb=(0, 0, 0), shape=(720, 1280, 3), filename='black'): | |
img = np.zeros(shape) | |
img[:, :, 0] = np.ones((shape[0], shape[1])) * rgb[2] | |
img[:, :, 1] = np.ones((shape[0], shape[1])) * rgb[1] | |
img[:, :, 2] = np.ones((shape[0], shape[1])) * rgb[0] | |
cv2.imwrite(filename + '.jpg', img) | |
def paint_it_black(shape=(720, 1280, 3)): | |
paint_it_color(rgb=(0, 0, 0), shape=shape, filename='black') | |
if __name__ == '__main__': | |
paint_it_black(shape=(1080, 1920, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment