Skip to content

Instantly share code, notes, and snippets.

@bafu
Created August 28, 2018 09:58
Show Gist options
  • Save bafu/480e9b1923069c004e23aa0a04679928 to your computer and use it in GitHub Desktop.
Save bafu/480e9b1923069c004e23aa0a04679928 to your computer and use it in GitHub Desktop.
Create pure color image by given RGB values.
"""
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