Python Forum
How to determine pen color from an image?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to determine pen color from an image?
#1
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?
Reply
#2
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)
Reply
#3
Thank you so much! Is there anyway I could do that in the turtle library tho?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 904 Oct-25-2023, 09:09 AM
Last Post: codelab
  determine if an number is in a list Dbeah 7 3,719 Nov-06-2018, 12:11 PM
Last Post: buran
  determine if an number is in a list Dbeah 1 2,209 Nov-04-2018, 04:50 PM
Last Post: stullis
  Is there a way to detect the text font, size and color from an image in python? Maia07 2 8,583 Aug-23-2018, 01:16 PM
Last Post: Maia07
  how to determine if an object is a number Skaperen 6 3,916 Jul-11-2018, 08:18 PM
Last Post: Skaperen
  How Do I Determine indentation in AST? jimo 3 4,172 Jul-01-2018, 04:25 PM
Last Post: buran
  Determine whether a method was overridden porton 6 6,050 Nov-14-2016, 09:51 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020