# Measuring the area of different regions from a picture

Consider the following picture of a phase plane which help us distinguish between regular and chaotic motion. The entire phase plane is divided into two types of regions: (i) the regular domain corresponding to the different well-defined islands of closed curves and (ii) the chaotic domain corresponding to the randomly scattered black dots. So the question is the following: is there a computational way to measure the area of these two domains? Let's say 55% of the phase plane is chaotic and 45% is regular.

EDIT

I want to calculate the portion inside the outermost star-like thick black curve occupied by the red circled white regions.

EDIT 2

Some more examples

• Do you have the equations that produced this pattern? – paw Oct 12 '14 at 10:05
• @paw No, the equations of the patterns are unknown; in fact they do not exist. – Vaggelis_Z Oct 12 '14 at 12:39
• @Vaggelis_Z, existence doesn't imply easy to compute or even computable. What's the class of dynamics, more detailed than just conservative (if that's the case). Do you have a Hamiltonian? Were the graphics computed pointwise vs curve following? – alancalvitti Oct 12 '14 at 16:48

Mathematica has a lot of image-processing functions. The proper combination of them will give you the desired result.

\$HistoryLength = 0;
img = Binarize@ImagePad[#, -{{340, 80}, {230, 60}}] &@
Import@"http://i.stack.imgur.com/5FnSe.jpg"


Erosion and removing small white components

img2 = SelectComponents[#, "BoundingDiskRadius", # > 50 &] &@ Erosion[img, DiskMatrix[2.5]]


Big chaotic brother is watching you! :)

Deleting holes and removing remaining small components.

img3 = SelectComponents[#, "BoundingDiskRadius", # > 45 &] &@
Erosion[FillingTransform[img2], DiskMatrix[2.5]]


img4 = Dilation[img3, DiskMatrix[6]]


The mask of the full region

full = FillingTransform@ColorNegate@img4


The mask of the regular regions

regular = SelectComponents[img4, "Area", # < 3*^5 &]


The detected regions (hi-res)

ImageSubtract[img, ImageMultiply[regular, Darker@Cyan]]


The ratio of regular regions

Total[ImageData@regular, 2]/Total[ImageData@full, 2] // N


0.261486

• The proposed image-processing method works perfectly to this particular example (.jpg file). However, I tried it in other plots with less amount of chaos and the results are no longer good. I uploaded some more examples; see Edit 2. Is there a way to modify this method, so as to work well regardless the particular image file? Since the general idea is working I suppose it needs some fine tuning so as to be applicable to any image file. – Vaggelis_Z Oct 12 '14 at 19:33
• @Vaggelis_Z Of course, the image-processing have certain limitations. It is difficult to tune it to process these images. The main problem is that lines in the regular regions are not solid. Could you modify your algorithm (if it is your plots) to produce solid lines? Or calculate so many point to join them. – ybeltukov Oct 12 '14 at 20:00