I have multispectral images taken with the drone. I'm looking for an algorithm that can do tree counting and tagging through these images. I need to use python for this job and I need your suggestions.
Well, machine learning algorithms will not solve the counting task. But they can be used to identify and tagging objects in images. The counting needs to be implemented on top of the results.
In order to achieve the labeling, the machine learning algorithms usually needs to be trained with preclassified data (i.e. images where each object to be detected is labeled). Things get more difficult, if you do not have such data available.
There are a number of possible machine learning approaches around falling in the category of "supervised learning" and more specifically "classification", like decision trees, random forrests, SVM, neural nets just to mention a few. For python you me take a look at the library scikit-learn.
Could you share one typical image in multispectral photographic layers? It would be much easier to find ML methods how to detect single trees. Counting must be done on the top of it using a different method.
Try to split the goal into subtasks, which are solvable by existing methods. Try to write down an abstract algorithm of all steps necessary to reach the goal.
Labeling of trees can be done by measuring the area of continuous spots. When the ratio of diameter and area occupied drops below some value, there are more trees than one.
Take trees 16, 11, 12, 7. Trees 16 and seventeen are separated by a narrow bridge => they are two trees. Similarly trees 11 and 12. Trees 12 and 7 are merged but the total area is more than twice of the average tree area plus the ratio of diameter (longest distance) to total area (or vice versa) is below some value.
Is this thinking understandable? Ask more when you need to.
OK, you have already identified objects you consider as trees. Hence, you just need to cluster the pixels making up a tree. So this is not a supervised learning problem instead it is just an unsupervised learning approach. Here a density-based clustering, such as DBSCAN and its derivates, could be useful to isolate potential trees.
I agree that it is not a machine learning problem. If you want to locate the tree tops, blur your image with a gaussian filter and then locate the local maxima or minima of the filtering result. The local extremas most probably will give the tree tops . And then you can segment out the tree pixels with a segmentation method.
Thank you for all the answers. I've tried watershed algorithm out of these answers. I get exactly what I want. But the biggest problem is that the trees touch each other like a single tree. How can I fix this?
Actually as you saw segmentation can be the way indeed, however you need something a bit more complex to resolve individual densely located objects like trees.
Have a look at this detection of individual trees using Picterra deep learning model dedicated to geospatial images and pretrained on forestry applications: https://bit.ly/2zrmaqU