Creating an 100x100 pixel image in python using NumPy
Aug 9, 2023
This is the image I created using the code given below ,I tried to create a monster eye in python using NumPy
import numpy as np
from PIL import Image
# Image dimensions
width = 100
height = 100
# Create a NumPy array to represent the image
greeneye_image = np.zeros((height, width, 3), dtype=np.uint8)
# Set colors for the eye
eye_color = [0, 255, 0] # Green
pupil_color = [0, 0, 255] # Blue
# Draw the eye
greeneye_image[40:80, 30:70] = eye_color
# Draw the pupil
greeneye_image[60:65, 50:55] = pupil_color
# Convert NumPy array to PIL Image
image = Image.fromarray(greeneye_image)
# Save the image
image.save(“green eye_image.png”)
image.show()