# definitions and usages of options such as “Count” ,”Area”, “ConvexCount”, and “ConvexArea”

I would like to use ComponentMeasurements to do image analysis on porus materials. However definitions andusages of options such as “Count” ,”Area”, “ConvexCount”, and “ConvexArea” are not well documented. I tried to use these options in a simple case. I made a testimage by using EXCELL and Photoshop. (TEST1)

    <<ComputationalGeometry
data1=Import[“test image3.jpg”];
data1a=Binarize[data1];
data3=ImageData[data1a];
Dimensions[data3]
{700,700}
data5=Table[{i,j,data3[[i,j]]},{i,1,700},{j,1,700}];
data6=Flatten[data5,1];
data7=Select[data6,#[]0&];(*counting number of black element*)
data8=Map[{#[],#[]}&,data7];
Dimensions[data8]
{50197,2}


(Therefore area fraction of black elements with repect to entire image elements is 50197/490000=0.102442857.This is comparable to 0.102040816)

(TEST2)

data9=ConvexHull[data8];
data10=PlanarGraphPlot[data8,data9,LabelPoints®False] (*This consits of 25 blocks and 5 of them are black. Area fraction of black blocks with repect to the entire ConvexHull is 5/25=0.2. *)

data11=ConvexHullArea[data8](*area of the ConvexHull*)
249498


(Therefore area fraction of black elements with repect to entire CovexHull is 50197/249498=0.201191993. This is comparable to 0.2)

(TEST3*) I think that we can do same things by using ComponentMeasurements with options such as “Count” ,”Area”,“ConvexCount”, and “ConvexArea.”

data12a=ComponentMeasurements[data8,”Count”];(*number of element*)
data13a=ComponentMeasurements[data8,”Area”];(*area of element*)
data14a=Map[{#[],#[]}&,data12a];(*number of element*)
data15a=Map[{#[],#[]}&,data13a];(*area of element*)
data16a=Apply[Plus,Map[#[]&,data15a]](*total number of element*)
112944
data17a=Apply[Plus,Map[#[]&,data16a]](*total area of element*)
112944
data12b=ComponentMeasurements[data8,”ConvexCount”];(*number of element in convex hull polygon*)
data13b=ComponentMeasurements[data8,”ConvexArea”];(*area of element in convex hull polygon*)
data14b=Map[{#[],#[]}&,data12b];(*number of element in convex hull polygon*)
data15b=Map[{#[],#[]}&,data13b];(**area of element in convex hull polygon**)
data16b=Apply[Plus,Map[#[]&,data15b]](*total number of element in convex hull polygon*)
1.64599 ´ 107
data17b=Apply[Plus,Map[#[]&,data16b]](**total area of element in convex hull polygon**)
1.64599 ´ 107


However, definitions and usages of these options are not well documented. I could not get simillar results shown in TEST 1&2. Please give me your advices. Thanks in advance.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Nov 17 '14 at 2:00
• I think this question can be improved by providing minimal examples and clear questions. – bobthechemist Nov 17 '14 at 17:01

ComponentMeasurements[] counts WHITE components:

img = Import@"http://i.stack.imgur.com/OLjyi.jpg";
data8 = ColorNegate@Binarize@img;

data12a = ComponentMeasurements[data8, "Count"]
data13a = ComponentMeasurements[data8, "Area"]
data12b = ComponentMeasurements[data8, "ConvexCount"]
data13b = ComponentMeasurements[data8, "ConvexArea"]
Range@5 /. data12a // Total

(*
{1 -> 10000, 2 -> 10000, 3 -> 10000, 4 -> 10099, 5 -> 10098}
{1 -> 10049.5, 2 -> 10049.5, 3 -> 10049.5, 4 -> 10148.6, 5 -> 10147.3}
{1 -> 10000, 2 -> 10000, 3 -> 10000, 4 -> 10099, 5 -> 10098}
{1 -> 10000., 2 -> 10000., 3 -> 10000., 4 -> 10099.5, 5 -> 10099.}

50197
*)
`