3dgeo-heidelberg / py4dgeo

py4dgeo - A Python library for change analysis in 4D point clouds
https://py4dgeo.readthedocs.io
MIT License
65 stars 8 forks source link

ZeroDevisionError happened during automatic seeds detection in py4dgeo.RegionGrowingAlgorithm. #314

Open Wjppppp opened 5 months ago

Wjppppp commented 5 months ago

bug_py4dgeo_RegionGrowingAlgorithm

Dear py4dgeo team,

Here's a ZeroDevisionError happened during seeds auto-detection step if there's only one neighbor surrounding seed candidate.

Related code: https://github.com/3dgeo-heidelberg/py4dgeo/blob/01d2ded31f56ef4dd62976694e13c409d35a5d45/src/py4dgeo/segmentation.py#L988

Possible solution:

            # avoid float division by zero
            if len(neighbors) > 1:
                return sum(similarities, 0.0) / (len(neighbors) - 1)
            else:
                return sum(similarities, 0.0)