floravf80
(Flora Vosoughi)
February 19, 2025, 11:05am
1
Hi everybody,
I am a beginner in Mathematica and would like to ask how I can count the points on a leaf. Is there a specific method or function for this?
I would appreciate any guidance.
Thank you!
The code I wrote and the result I got is:
img = Import["path/to/your/leaf_image.jpg"];
bwImg = Binarize[img];
spots = MorphologicalComponents[bwImg];
numSpots = Max[spots];ImageCollage[{img, Colorize[spots]}]
giulioa
(Giulio Alessandrini)
February 19, 2025, 12:46pm
2
Not perfect but you could use color based segmentation
mask = Binarize[ColorDetect[img, ColorsNear[Brown]], .1]
Then use the centers of the morphological components
HighlightImage[img,
ComponentMeasurements[MorphologicalComponents[mask], "Centroid"]]
floravf80
(Flora Vosoughi)
February 19, 2025, 6:52pm
3
Thank you very much for your guidance.
I have tested 3 images and obtained the results and errors. I would greatly appreciate it if you could kindly review them and provide your feedback.