abots/abots/tools/pixels.py

19 lines
478 B
Python

from numpy import zeros, uint8
from PIL import Image
from random import randint
def make_pixels(width, height):
return zeros((height, width, 3), dtype=uint8)
def get_random_pixels(width, height):
pixels = make_pixels(width, height)
for y in range(height):
for x in range(width):
pixels[y, x] = [randint(0, 255), randint(0, 255), randint(0, 255)]
return pixels
def show_pixels(pixels):
image = Image.fromarray(pixels)
image.show()