Last active
March 16, 2017 02:27
-
-
Save lucrib/c13dd13efbab4ba4db61fd70b06b8398 to your computer and use it in GitHub Desktop.
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
from random import randint | |
from PIL import Image | |
import numpy as np | |
W, H, = 1920, 1080 | |
def shades_of(color): | |
if color == 'red': | |
return rand_rgb(0, 255, 0, 0, 0, 0) | |
if color == 'green': | |
return rand_rgb(0, 0, 0, 255, 0, 0) | |
if color == 'blue': | |
return rand_rgb(0, 0, 0, 0, 0, 255) | |
def rand_rgb(red_min=0, red_max=255, green_min=0, green_max=255, blue_min=0, blue_max=255): | |
return [randint(red_min, red_max), randint(green_min, green_max), randint(blue_min, blue_max)] | |
def mode2(): | |
a = [[rand_rgb() for x in range(W)] for y in range(H)] | |
return a | |
def mode1(): | |
img_matrix = list() | |
for x in range(H): | |
pixel_array = [] | |
for y in range(W): | |
pixel = rand_rgb() | |
pixel_array.append(pixel) | |
img_matrix.append(pixel_array) | |
return img_matrix | |
if __name__ == '__main__': | |
IMG_MATRIX = mode2() | |
arr = np.asarray(IMG_MATRIX) | |
gen_img = Image.fromarray(arr, 'RGB') | |
gen_img.save('teste.jpg') | |
gen_img.show() | |
print gen_img.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment