Optimize remove_trees

This commit is contained in:
2024-09-27 23:37:24 +02:00
parent 68241ae415
commit 12cdacba4e
14 changed files with 2 additions and 5 deletions

View File

@@ -31,11 +31,8 @@ def remove_trees(heightmap: Union[str, Image], treesmap: Union[str, Image], mask
if mask.getpixel((x, z)) != 0 and treesmap.getpixel((x, z)) > 0:
tree_area = morphology.flood(treesmap, (z, x), tolerance=1)
blend = img.blend(img.fromarray(tree_area).convert(
'L'), removed_treesmap.convert('L'), 0.5)
array = np.array(blend.convert('L'))
bool_array = array > 1
removed_treesmap = img.fromarray(bool_array)
removed_treesmap = img.fromarray(
np.where(tree_area, treesmap, 0).astype(np.uint8))
y = heightmap.getpixel((x, z))
y_top = removed_treesmap.getpixel((x, z))