Home > other >  How to get image X Y coordinates and a pixel value at the indicated point by cursor with Python?
How to get image X Y coordinates and a pixel value at the indicated point by cursor with Python?

Time:02-11

I have a gray scale image which size is (5472, 3648). How does python return the pixel value and x y cordinates of an point in the image? I want to get the values when I set the cursor and click the point in the image?

CodePudding user response:

def print_location(event):
    print(f' location of x={event.x}, location of y ={event.y}')

your_image_object.bind("<Button-1>", print_location)

#this should print x and y co ordinate of where you click in that image

  • Related