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?
how to get x coordinate of image
Collapse
X
-
-
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 ordinatesComment
-
Comment
-
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
-
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
Comment