Python Forum
How to determine pen color from an image? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to determine pen color from an image? (/thread-16998.html)



How to determine pen color from an image? - robie972003 - Mar-24-2019

So lets say I have a .png image and I want the pen color to be the (0,0) pixel on the picture, am I able to do that in python?


RE: How to determine pen color from an image? - scidam - Mar-24-2019

You need to load an image into Python memory first. That could be done, e.g. using scikit-image or Pillow packages.
So, if you have a png-file named myfile.png, you can get color at (0, 0) position as follows:

from skimage import io

img = io.imread("myfile.png")
color_rgb = img[0, 0, :]
print("Color of the (0, 0)-pixel is ", color_rgb)



RE: How to determine pen color from an image? - robie972003 - Mar-24-2019

Thank you so much! Is there anyway I could do that in the turtle library tho?