py4dgeo icon indicating copy to clipboard operation
py4dgeo copied to clipboard

ZeroDevisionError happened during automatic seeds detection in py4dgeo.RegionGrowingAlgorithm.

Open Wjppppp opened this issue 1 year ago • 0 comments

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)

Wjppppp avatar Jan 10 '24 12:01 Wjppppp