I want to segment an arrayplot donut in to 6 pizza slices and export per segment the coordinates and intensity values of the pixels inside of it.
I found a good example, which used RegionMember to exclude data points from a listplot.
code used from thread
Exclude data from a list (kguler)
How to check if a 2D point is in a polygon? (aisamu)
data = Table[{RandomReal[{-10, 10}], RandomReal[{-10, 10}]}, {i, 1,
10}];
L0 = ListPlot[data, Frame -> True, Axes -> False, AspectRatio -> 1,
ImageSize -> 400, BaseStyle -> PointSize[.02]];
Deploy@DynamicModule[{list = {}}, Row[{EventHandler[
Dynamic[
Show[L0,
Graphics[{Opacity[.4], Yellow, EdgeForm[Thick], Polygon[list],
Purple, PointSize[.03], Point[list]},
PlotRange -> PlotRange[L0]]]], {"MouseDown" :>
AppendTo[list, MousePosition["Graphics"]]}],
Dynamic@
ListPlot[
If[Length@list <= 2, data,
Pick[data, ! RegionMember[Polygon@list, #] & /@ data]],
BaseStyle -> PointSize[.02], Axes -> False, L0[[2]],
Prolog -> {Opacity[.5], Yellow, Polygon[list]}]}, Spacer[5]]]
So i tried to use the same code for my array plot (code below), but it is not working. It does not select the arraypixels (coordiantes and value) inside the red area, as you can see in the right arrayplot on the image below. It only gives a realvalue error and and i dont know how to fix it.
I also wonder if its possible to segment multiple regions like i did in paint.
data1 = bla2[[9]];
L01 = ArrayPlot[data1, Frame -> True, Mesh -> True, AspectRatio -> Automatic, ImageSize -> 400];
Deploy@DynamicModule[{list = {}}, Row[{EventHandler[
Dynamic[
Show[L01,
Graphics[{Opacity[.3], Red, EdgeForm[Thin], Polygon[list], Red,
PointSize[.01], Point[list]},
PlotRange -> PlotRange[L01]]]], {"MouseDown" :>
AppendTo[list, MousePosition["Graphics"]]}],
Dynamic@ArrayPlot[
If[Length@list <= 2, data1,
Pick[data1, ! RegionMember[Polygon@list, #] & /@ data1]],
BaseStyle -> PointSize[.02], Axes -> False, L01[[2]],
ImageSize -> 300,
Prolog -> {Opacity[.5], Yellow, Polygon[list]}]}, Spacer[5]]]
I hope some one can help me out
Edit, Maybe you have a better method in mind. I would love to hear.