py4dgeo
py4dgeo copied to clipboard
ZeroDevisionError happened during automatic seeds detection in 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)