Domanda

i am trying to make an polygon ROI for an matplotlib imshow(image). Using the Event Handling of matplotlib i am able to manually set an polygon ROI ontop of the image (via Line2D segments).

The result is a set of edge coordinates (in pixel values) of my ROI. Does someone know how i can extract the pixel values inside the ROI? What i finally would like to have is a numpy mask (array the size of the image with 1 at elements outside the ROI, 0 at elements inside the ROI).

Is there any easy way to do so? Maybe there already is some kind of image processing function that is able to close and fill the ROI points?

ImageExample: http://img707.imageshack.us/img707/186/roi.png

È stato utile?

Soluzione

I just stumbled across the solution.

The "scikits-image" module offers exactly whats needed. I can pass the polygon coordinates and it will give me a tool to slice out the ROI of the image array.

Example: http://scikits-image.org/docs/dev/auto_examples/plot_shapes.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top