Python Forum

Full Version: How to determine pen color from an image?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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)
Thank you so much! Is there anyway I could do that in the turtle library tho?