how to get x coordinate of image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarfarazfarru
    New Member
    • May 2010
    • 12

    #1

    how to get x coordinate of image

    I want to get the X coordinate. Here is my image shown in the below attachment. It shows at what point i need the pixel coordinate value that is X,Y?
    Attached Files
    Last edited by Niheel; May 24 '10, 06:01 AM. Reason: grammar, punctuation
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    What type of image is this? A file? Did you create the image? Are you using Tkinter, Wxpython, PIL, or what? Do you have access to the data that created the image?. Is the image a series of dots, or is it a smooth curve? Your question is too vague. Please clarify.

    Comment

    • sarfarazfarru
      New Member
      • May 2010
      • 12

      #3
      Originally posted by bvdet
      What type of image is this? A file? Did you create the image? Are you using Tkinter, Wxpython, PIL, or what? Do you have access to the data that created the image?. Is the image a series of dots, or is it a smooth curve? Your question is too vague. Please clarify.
      the image is created by me it is character in kannada lanuage.
      i am using the PIL to display the image.
      i wanna know the x and y co ordinates

      Comment

      • sarfarazfarru
        New Member
        • May 2010
        • 12

        #4
        Originally posted by sarfarazfarru
        the image is created by me it is character in kannada lanuage.
        i am using the PIL to display the image.
        i wanna know the x and y co ordinates
        and can u tell me how dispay the image tkinter and draw grid to it

        Comment

        • sarfarazfarru
          New Member
          • May 2010
          • 12

          #5
          Originally posted by sarfarazfarru
          I want to get the X coordinate. Here is my image shown in the below attachment. It shows at what point i need the pixel coordinate value that is X,Y?
          i have created an image in a canvas,and i am finding diffculty in measureing the dimension of an image's pixel at a particular point .i had already sent an image prior to this message.

          Comment

          • bvdet
            Recognized Expert Specialist
            • Oct 2006
            • 2851

            #6
            To determine the lower right pixel of the image, you have to make some assumptions. Let's assume we are using PIL. Let's also assume the pixels representing the image will have RGB values less than 100. We want to determine the last image pixel column (X value) of the last image pixel row.

            Open the file
            Initialize a dictionary
            Iterate on the X and Y values of the image size
            If a pixel RGB values are less than 100, save in the dictionary (d[(X,Y)] = (R,G,B)
            Create a list from the dictionary keys
            Sort the list on the Y (row) values, then the X (column) values
            You answer is keys[-1]
            Code:
            from PIL import Image
            
            img = Image.open('image.jpg')
            output = {}
            for col in range(img.size[0]):
                for row in range(img.size[1]):
                    pixel = img.getpixel((col,row))
                    if pixel[0] < 100 and pixel[1] < 100 and pixel[2] < 100:
                        output[(col,row)] = pixel
            
            def comp(a,b):
                x = cmp(a[1], b[1])
                if not x:
                    return cmp(a[0],b[0])
                return x
            
            keys = output.keys()
            keys.sort(comp)
            Code:
            >>> keys[-1]
            (277, 218)
            >>>

            Comment

            Working...