PatBall1 / detectree2

Python package for automatic tree crown delineation based on the Detectron2 implementation of Mask R-CNN
https://patball1.github.io/detectree2/
MIT License
148 stars 35 forks source link

Addition of an additional crown cleaning function to remove very small "false" fragmented tree crowns #132

Open zeppehpt1 opened 6 months ago

zeppehpt1 commented 6 months ago

Hi, this change is to fix #120 by applying a additional cleaning step to the crowns after the clean_crowns() function has been applied in order to optimize the quality of the resulting tree crowns.

PS: First PR, I hope I got it right.

PatBall1 commented 6 months ago

Hi Richard, @zeppehpt1 thanks for contributing this. And well done on submitting your thesis! The thing is we already have a haphazard area filtering process here: https://github.com/PatBall1/detectree2/blob/f996564bfcbaed1ff0ef13a63ea3e62f47252731/detectree2/models/outputs.py#L351

Your function would need to be integrated within this function for it to be cohesively integrated within the current set up.

What really needs fixing is this step: https://github.com/PatBall1/detectree2/blob/f996564bfcbaed1ff0ef13a63ea3e62f47252731/detectree2/models/outputs.py#L42

I think it would be better to skip non-closed polygons in that function. But I didn't implement it before because it seemed to give some unexpected outputs. But I was in a rush and wasn't sure whether I'd overlooked something. We should check that again. Skipping those cases would be the quickest and cleanest way to proceed. Would you be willing to check that on your pipeline (I can send you and edited branch)?

zeppehpt1 commented 6 months ago

Thank you very much!

Oh yes, I must have overlooked that. But it seems that the step you mentioned might be the reason, because with my pipeline the additional cleaning step was always necessary even though I was using the latest version of the package.

Yes, I'm willing to look into it and hope I can help!