1 | initial version |
Interesting problem. Did you check some articles in this field for ideas?
Anyway, counting individual grains (image 1) will probably give better results, as in kernels (image 2) you can't see all the grains (half of them are masked.
Based on my experience, it's better to work on the image acquisition conditions (especially lighting), it will make further work much easier.
For example you could put the grains on an opaque glass and provide a back light; expose for the background light, so the grains remain black over a white background in the image.
Then threshold the image and count the local maxima of the distance transform.