medfilt --> medfilt2d

pull/999/head
Piero Toffanin 2019-06-11 15:48:15 -04:00
rodzic be2815ac1c
commit af37b8c659
1 zmienionych plików z 3 dodań i 7 usunięć

Wyświetl plik

@ -303,9 +303,9 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1):
for i in range(smoothing_iterations):
log.ODM_INFO("Smoothing iteration %s" % str(i + 1))
try:
arr = signal.medfilt(arr, 5)
arr = signal.medfilt2d(arr, 5)
except MemoryError:
log.ODM_WARNING("medfilt ran out of memory, switching to slower median_filter")
log.ODM_WARNING("medfilt2d ran out of memory, switching to slower median_filter")
used_fallback = True
arr = ndimage.median_filter(arr, size=5, output=dtype)
@ -322,11 +322,7 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1):
# write output
with rasterio.open(output_path, 'w', **img.profile) as imgout:
# No need to cast if we used the fallback filter (save memory)
if used_fallback:
imgout.write(arr, 1)
else:
imgout.write(arr.astype(dtype), 1)
imgout.write(arr, 1)
log.ODM_INFO('Completed smoothing to create %s in %s' % (os.path.relpath(output_path), datetime.now() - start))