Color code Voronoi cell areas depending on number of vertices

MeshPrimitives returns a list of Polygon objects; and it's not too tricky to just to count the number of points in each Polygon:

colorvm = Map[{ColorData[97, First[Dimensions[First[#]]] - 2], #} &,  MeshPrimitives[vm, {2, "Interior"}]]]
Graphics[{EdgeForm[Black], colorvm}]

Here's what it returns on the Voronoi diagram for a bunch of random points:

enter image description here

The number 97 is used to access the default plot colors for MM 10, but other color schemes are available as well.


You can change the color function, but the idea is there.

meanValues = ComponentMeasurements[image, {"Centroid"}];
listData = meanValues /. Rule -> List;
listData = Partition[Flatten[listData[[All, 2]]], 2];
vm = VoronoiMesh[listData];

meshData = MeshPrimitives[vm, {2, "Interior"}];
iterMax = Length@meshData;
nbSideCell = Length @@@ meshData;
colorVect = Red;

Graphics[Table[{Hue[1/nbSideCell[[i]]], EdgeForm[Black], 
meshData[[i]]}, {i, iterMax}]]

a busy cat