I am new to python (also to stackoverflow) and I need help with combining pixel color values into an image.
After searching through the web and playing around with the codes mentioned, I eventually used the following code to get the color values from a given image:
from PIL import Image
filename = "INSERT_PATH_OF_IMAGE"
image = Image.open(filename)
t = list(image.getdata())
r = list(image.getdata(0))
g = list(image.getdata(1))
b = list(image.getdata(2))
print(r)
print(g)
print(b)
print(image)
This outputs the numerical values of the given pixels of the given image like so:
[r_value1, r_value2, ..]
[g_value1, g_value2, ..]
[b_ , b_..]
How from here would the pixel-coordinates of the colors be identified and how could they be put together into an image?
How can the print-command be structured such that
[(r_value1, g_value1, b_value1),
(r_value2, g_value2, ..)]
would be the output shown?
Because (depending on image size) the amount of values shown can exceed the output terminal record (Using Pycharm), how could the printed result instead be saved in a text file? (Like: Editor on Windows OS)
The eventual goal is to create an algorithm to use with opencv (probably) with which to process images, I thought I should start with understanding how to process just standard images from pixeldata first and progress from there.
Thanks for reading!
P.S. I welcome any and every advice on what sources I should read up on, so feel free to share. =)