<h1>Mathematica, score: 7</h1> k = {3, 5, 12, 25, 50, 83, 120, 150, 151, 200}; i = {"https://i.sstatic.net/8T6W2.jpg", "https://i.sstatic.net/pgWt1.jpg", "https://i.sstatic.net/M0K5w.jpg", "https://i.sstatic.net/eUFNo.jpg", "https://i.sstatic.net/2TFdi.jpg", "https://i.sstatic.net/wX48v.jpg", "https://i.sstatic.net/eXCGt.jpg", "https://i.sstatic.net/9na4J.jpg", "https://i.sstatic.net/UMP9V.jpg", "https://i.sstatic.net/nP3Hr.jpg"}; I think the function's names are descriptive enough: getSatHSVChannelAndBinarize[i_Image] := Binarize@ColorSeparate[i, "HSB"][[2]] removeSmallNoise[i_Image] := DeleteSmallComponents[i, 100] fillSmallHoles[i_Image] := Closing[i, 1] getMorphologicalComponentsAreas[i_Image] := ComponentMeasurements[i, "Area"][[All, 2]] roundAreaSizeToGrainCount[areaSize_, grainSize_] := Round[areaSize/grainSize] Processing all the pictures at once: counts = Plus @@@ (roundAreaSizeToGrainCount[#, 2900] & /@ (getMorphologicalComponentsAreas@ fillSmallHoles@ removeSmallNoise@ getSatHSVChannelAndBinarize@#) & /@ im) (* Output {3, 5, 12, 25, 49, 83, 118, 149, 152, 202} *) The score is: counts - {3, 5, 12, 25, 50, 83, 120, 150, 151, 200} // Abs // Total (* 7 *) Here you can see the sensitivity of the score to the grain size used: ![Mathematica graphics](https://i.sstatic.net/0DhXI.png)