andrew-plowright / ForestTools

Detect and segment individual tree from remotely sensed data
68 stars 22 forks source link

How to improve the results on the number of tree heights detected and crowns detected? #34

Open chugom opened 1 month ago

chugom commented 1 month ago

Hello,

First of all, thank you for your work, it is top notch.

I tested the ForestTools library on a small area to check the finesse of the results. I counted the number of trees visible from a LAS viewer (CloudCompare), I have around 17 trees. I must have at least and maximum 17 tree tops, except that in the results I have 47 tree tops, and for the crowns there is too much cutting for the number of trees I am sure that there are parameters to adapt to refine the results, is it possible to help me to get as close as possible to a visible result on CloudCompare. Thank you.

Capture d'écran 2024-10-21 151421 Test_ttops Test_crowns_poly Test_color_crowns_poly

andrew-plowright commented 1 month ago

The main parameter for increasing or decreasing the number of trees that is detected is winFun. This is a function that sets the size of the search window based on the canopy height over which it is centered. In other words:

Input = CHM cell values Output = window radius

So a function like function(x){x * 0.06 + 0.5} will yield a consistently wider search window than function(x){x * 0.06 + 0.1}. A wider window will yield fewer trees. Adjusting the function's intercept will enlarge the window for all canopy heights, whereas adjusting the slope can tilt results for higher/lower sections of the canopy.

You also don't need to use a linear function. For forest stands dominated by tall, narrow conifers, I found that logarithmic functions (ex.: function(x){x * 0.06 + 0.5}) work well.

However, coming up with an optimal function is not easy. I would recommend reading up the primary literature from Popescu and Wynne for a discussion on this. If you scroll down the ForestTools README page, you'll also find many other studies that use this library and discuss parameterization.

chugom commented 1 month ago

Thank you for your feedback, I will review the various works. One last question: is it possible to aggregate or use the data captured by the DeepForest algorithm for canopy detection and use the results to refine the search for tree tops with the ForestTools algorithm?

I am primarily working with deciduous trees.

andrew-plowright commented 1 month ago

That's an interesting question, and something I've been wanting to explore myself (I haven't had a chance to try DeepForest myself yet). What I would probably try is:

  1. Forget about the vwf function, and instead attempt to detect individual trees using DeepForest
  2. Within each bounding box produced by DeepForest (which presumably correspond to individual trees) extract the highest point in the canopy (i.e.: local maxima)
  3. Use those local maxima as inputs for the mcws function that will then segment the trees using a watershed algorithm

This could potentially work, although I would expect step 2 might be problematic. Given that the bounding boxes are square, the highest point within them might belong to a neighbouring tree instead of the tree on which they're centered. You might have to think of some clever way of preventing this (turn the boxes into circles? use spatial weighting when looking for the local maxima?)

I'd be curious to know how this goes, if you end up attempting it.

chugom commented 1 month ago

If I have some time I will also try it, and I will be sure to get back to you.