has anybody a idea on how to detect dots centers on this kind of image. Here dots host a black and white contraste (or white and black) and are almost touching each other. This make it difficult to use ComponentMeasurements as I usualy do . Thanks for your help, Daniel
1 Answer
This comes close, and I suspect a masking approach would be better given that all objects appear to be of the same size. An edge-preserving filter is applied to smooth out the background while maintaining contrast of the objects. Colors are then binned into 3 categories (high/low/background). I ignore one of the high/low, which is an area for improvement. Lastly, delete objects of an arbitrary size and count what's left.
i = Import@"https://i.stack.imgur.com/9RP53.png"
ij = ImportString[ExportString[i, "jpg"], "jpg"];
if = PeronaMalikFilter[ij,10];
data = ClusteringComponents[ColorQuantize[if, 16], 3];
ip = DeleteSmallComponents[
Colorize[idata, ColorRules -> {1 -> Black, 2 -> Black, 3 -> Red}],
50]
ComponentMeasurements[ip, "Area"] //Length
163 objects are found.
-
$\begingroup$ There are
9*(9 + 10) + 9=180
dots.9+9=18
of them are on edge of the image and thus not entirely visible. Notice that the dots are arranged in hexagonal grid so I would expect the red regions to form the same hexagonal grid. $\endgroup$ Oct 7, 2020 at 17:05
img = ColorConvert[ RemoveAlphaChannel[Import["https://i.stack.imgur.com/9RP53.png"]], "Grayscale"]; dm = DiskMatrix[15]; step = ArrayResample[{{1, -1}, {1, -1}}, Dimensions[dm], Resampling -> "Linear"]; kern1 = dm*step; MatrixPlot[kern1, ImageSize -> Small] corrk1 = ImageCorrelate[img, kern1, NormalizedSquaredEuclideanDistance]; HighlightImage[img, Binarize[corrk1]]
$\endgroup$