Extracting pixel values from an image under a polygon (region of interest)
- To: mathgroup at smc.vnet.net
- Subject: [mg115312] Extracting pixel values from an image under a polygon (region of interest)
- From: Mac <mwjdavidson at googlemail.com>
- Date: Fri, 7 Jan 2011 04:10:16 -0500 (EST)
I've tried solving this general scientific image processing problem for some time, alas without success. Given an image and a polygon with coordinates describing a region of interest, I would like to extract all the image pixels falling completely within the boundaries of the polygon (not necessarily a square). As an illustrative example consider the following synthetic image + region of interest marked in red img = Graphics[{Raster[RandomReal[{0, 1}, {10, 10}]], Red, Opacity[0.5], Polygon[{{0.9, 0.9}, {4, 4.1}, {7, 4.1}, {8, 1}}]}, Frame -> True] I would like to extract all the values of img falling within the boundary of the red polygon. The real world problem I face is that I have a radar map of the earth's surface with the pixel values representing the radar intensity and would like to extract and analyse all pixels falling within a specific region (say for instance Greenland). Despite the advances in image processing in Mathematica 8 I still do not see a solution. There is no PixelTake function or similar.... Anway, any help would be much appreciated. Mac