NOTE: This is a school-related assignment and I am in no capacity looking for a direct answer. Looking for support on coming up with algorithms as this is my first time with such a question
Programs Intended Purpose: Take a command line provided image and scale it up by a unit of 5. Use the RGB values from the original image to re-create it in a randomized fashion.
Algorithm Attempts:
- Test image is 250x250 scaling up to 1250x1250. I've tried to break this into sections of 50(original image side divided by 5) and then use (r + g + b)/5 number of circles to generate the color needed. Ex: Color: (100,50,5) would use 20 red circles, 10 green circles, 1 blue circle in the 50x50 space, (100+50+5)/5 = 31, 20 + 10 + 1 = 31. The x and y coordinates of these circles inside the 50x50 space should be random.
My main issue here has been putting this into code.
Code Attempt 1: Is not related to algorithm, is simply attempt to print image using pygame.draw.circle(this is what I am required to use to make the circle)
import pygame
import sys
import random
image_name = sys.argv[1]
#Import Image
src_image = pygame.image.load(image_name)
(w,h) = src_image.get_size()
window = pygame.display.set_mode((w*5,h*5))
#Nested Loop To Iterate Through Rows And Columns Of Pixels
for y in range(h):
for x in range(w):
(r,g,b,_) = src_image.get_at((x,y))
print(f"{r},{g},{b},x:{x},y:{y}")
pygame.draw.circle(window,(r,g,b),(x*5,y*5),2)
pygame.display.update()
pygame.time.delay(5000)
Aucun commentaire:
Enregistrer un commentaire