On 22/01/2008, Søren Nielsen <[EMAIL PROTECTED]> wrote: > I'm looking for a way to do masking of an Image.. I need to be able to make > a circle / box or a user made polygon on an image using the mouse and > retrieve the pixellocations of all pixels inside the masked area.. (which > will then be processed later)
I have very recently written some code that creates a binary mask (2-D array) of an irregular polygon given the co-ordinates of the corners. It successively uses equations of the line segments between pairs of neighbouring points around the polygon edge and sets the pixels on the inner side of those lines. I doubt it's the most efficient code, but seem so to work, and I'm happy to send you a copy it if it might be helpful. > Has anyone tried this? What is the easiest way > to start? I'm using wxpython for the GUI. It's relatively easy to capture successive mouse clicks using mpl, and use those co-ordinates for the polygon calculating code. An example of capturing mouse co-ordinates is in the cookbook: http://www.scipy.org/Cookbook/Matplotlib/Interactive_Plotting. Best regards, Angus. -- AJC McMorland, PhD candidate Physiology, University of Auckland ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users