2
$\begingroup$

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

Image

$\endgroup$
2
  • $\begingroup$ looks quite tricky. Maybe start by trying to correlate it with a disk-like kernel that has two distinct sides e.g: 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$
    – flinty
    Oct 7 '20 at 15:51
  • $\begingroup$ Notice that all dots are arranged in a hexagonal grid. If all your images have the same arrangement I would take advantage of this fact and use far more precise detection of the centers of dots - because knowing position just of two centers gives you coordinates of all others. So maybe you select manually by position of mouse pointer the two centers a the rest solve mathematically. $\endgroup$ Oct 7 '20 at 16:52
1
$\begingroup$

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

enter image description here

163 objects are found.

$\endgroup$
1
  • $\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 '20 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.