Last active
September 3, 2016 18:34
-
-
Save pat36/1376ee4438db155ac7b0f084e644ad7f to your computer and use it in GitHub Desktop.
działający generator obrazów
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
import numpy as np | |
from random import randint | |
from PIL import Image as img | |
height = int(input("Podaj wysokosc obrazu: ")) | |
width = int(input("Podaj szerokosc obrazu: ")) | |
image = np.zeros(shape=(width, height), dtype="S6") | |
for i in range(0, height): | |
for j in range(0, width): | |
r = randint(0,255) | |
g = randint(0,255) | |
b = randint(0,255) | |
rgb = r * 65536 + g * 256 + b | |
image[i][j] = hex(rgb)[2:] | |
tmpImg = img.fromarray(image, "RGB") | |
tmpImg.save("obrazek.jpg") | |
tmpImg.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment