What I am trying to achieve is that whenever I get the same rgb value the pixel coordinates are stored in a list for every different rgb value
Code:
from PIL import Image,ImageOps
file_name = "test.png"
og_image = Image.open(file_name)
gray_image = ImageOps.grayscale(og_image)
gray_scalefile = f"{file_name[:-3]}gray.png"
gray_image.save(gray_scalefile)
img = Image.open(gray_scalefile).convert('RGB')
pixels = img.load()
width, height = img.size
for x in range(width):
for y in range(height):
r,g,b = pixels[x,y]
print(x, y, f'{r},{g},{b}')
This code uses PIL to convert test.png to a grayscale image and then it gets all the pixels and their rgb values I want to take all the pixel coordinates that are in the same rgb value and store them together for each rgb value that comes so an example is like 80,40 255 0 0 and 70, 20 255 0 0 i want these to go in a list together because they have the same rgb value