3
$\begingroup$

I have been trying to identify the centroids or positions of the small yellow dots (not the large regions) in the image below. I have adopted the following strategy (please see the code), however, i wonder if the results can be improved. In my attempt, I could not identify all spots and rather some extraneous spots are also selected. Thanks !

The original picture:

enter image description here

The picture with the centroids of the spots highlighted, is as follows:

enter image description here

The code can be found below:

segmented = ColorSeparate[img][[2]] // MorphologicalPerimeter[#, 0.2] & // MorphologicalComponents //
SelectComponents[#, {"Count", "AdjacentBorderCount","Holes"}, #1 < 50 && #2 == 0 && #3 >=  0 &] & 
// Colorize

centroids = ComponentMeasurements[segmented, "Centroid"];
HighlightImage[img, ListPlot[centroids // Values]]

Also do you recommend the use of Binarize[img] in the very beginning?

$\endgroup$
3
$\begingroup$

I will recommend a function of TopHatTransform for this request,you wil get it like this:

mask = MaxDetect[TopHatTransform[img, DiskMatrix[1]], .2]

enter image description here

Show it in your original picture:

HighlightImage[img, {Gray, mask}]

enter image description here

| improve this answer | |
$\endgroup$

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.