Skip to content
Snippets Groups Projects
Commit 09d53e14 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

add additional trap identification method

parent 07f5498e
No related branches found
No related tags found
No related merge requests found
...@@ -91,10 +91,28 @@ def segment_traps(image, tile_size, downscale=0.4): ...@@ -91,10 +91,28 @@ def segment_traps(image, tile_size, downscale=0.4):
x - tile_size // 2 : x + tile_size // 2, y - tile_size // 2 : y + tile_size // 2 x - tile_size // 2 : x + tile_size // 2, y - tile_size // 2 : y + tile_size // 2
] ]
# add template as mean of found traps
mean_template = (
np.dstack(
[
image[
x - tile_size // 2 : x + tile_size // 2,
y - tile_size // 2 : y + tile_size // 2,
]
for x, y in traps
]
)
.astype(int)
.mean(axis=-1)
)
traps = identify_trap_locations(image, template) traps = identify_trap_locations(image, template)
mean_traps = identify_trap_locations(image, mean_template)
traps = traps if len(traps) > len(mean_traps) else mean_traps
if len(traps) < 10 and downscale != 1: if len(traps) < 30 and downscale != 1:
print("Trying again.") print("Tiler:TrapIdentification: Trying again.")
return segment_traps(image, tile_size, downscale=1) return segment_traps(image, tile_size, downscale=1)
return traps return traps
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment