[Tkinter-discuss] how to get all pixels enclosed by a canvas object
yahuip at uchicago.edu
Tue Jun 21 15:20:01 CEST 2011
Thanks for your reply, Lion.
What I want to do is to select a region of interest (ROI) in a given
image. I can display the image in a canvas widget and use
canvas.create_#object#() method to generate an ROI on the screen.
However, I could not find a way to get all pixel coordinates inside the
ROI. I have found that canvas.coors() returns pixel coordinates but
they do not normally form a close contour. What I was wondering is
whether there is a simple way to get all pixels inside an object that is
created by canvas.create_#object#() method.
I see your suggestion is a possible way: get the bbox() return values
for the object and test each pixel (or a small box) to see whether or
not it is inside the object. But are there easier and more direct ways
to do this?
On Mon, 2011-06-20 at 23:39 -0700, Lion Kimbro wrote:
> I'm not sure what you mean, but perhaps you are looking for:
> canvas.find_enclosed(x1, y1, x2, y2) => [objID, objID, ...]
> completely enclosed
> canvas.find_overlapping(x1, y1, x2, y2) => [objID, objID, ...]
> sharing at least 1 point
> On Mon, Jun 20, 2011 at 7:59 PM, <yahuip at uchicago.edu> wrote:
> Hi there,
> I have been struggling to find a way to retrieve all pixel
> coordinates that are enclosed by an object drawn on a canvas
> widget. Anyone knows how I can do it?
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
More information about the Tkinter-discuss