Home python How can I consider a color from pixel in python

How can I consider a color from pixel in python

Author

Date

Category

Suppose there is a site on which three rectangles are located. As I can find out the color and make to variables, even through the number (i.e., red – 1, green – 2, yellow – 3)?


Answer 1, Authority 100%

from pil import imagegrab
image = image ()
Class Pixel:
  Def __init __ (Self, Position, Color):
    Self.position = Position
    Self.color = Color.
Class Image:
  Def __init __ (Self):
    self.image_obj = imagegrab.grab (BBOX = (0, 0, 100, 100)) # do screenshot
    self.pixels = self.image.load () # take all pixels
  DEF Get_Pixel (Self, X, Y):
    RETURN PIXEL ((X, Y), Self.pixels [x, y])

For example:
print (1, 1) .color) will return color, conditionally, “255, 255, 255”

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions