-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixgen.py
23 lines (17 loc) · 728 Bytes
/
pixgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
from PIL import Image
# Load the reference image
ref_image = Image.open('home/darkstar/pixgen/input/picture.jpg')
ref_pixels = np.array(ref_image)
# Define the amount of randomness to add
random_factor = 20 # You can adjust this value
# Generate random pixel values based on the reference image
random_pixels = ref_pixels + np.random.randint(-random_factor, random_factor,
ref_pixels.shape)
# Clip the pixel values to be within valid range (0-255)
random_pixels = np.clip(random_pixels, 0, 255)
# Create a new image from the random pixel values
new_image = Image.fromarray(random_pixels.astype('uint8'))
# Save or display the new image
new_image.save('home/darkstar/pixgen/image.jpg')
new_image.show()