OpenDroneMap / ODM

A command line toolkit to generate maps, point clouds, 3D models and DEMs from drone, balloon or kite images. 📷
https://opendronemap.org
GNU Affero General Public License v3.0
4.91k stars 1.11k forks source link

C++ median smoothing filter #1731

Closed pierotofy closed 11 months ago

pierotofy commented 11 months ago

This PR moves the median smoothing filter to C++ via FastRasterFilter (https://github.com/OpenDroneMap/FastRasterFilter), which is now both faster and more algorithmically correct, since we properly apply the median filter using a sliding window with padding (compared to the current implementation, which does not implement padding).

image

pierotofy commented 11 months ago

On brighton beach for a small raster this is ~25% faster, I fully expect this to be much faster for larger rasters and orders of magnitude faster for corridor type datasets, which have large chunks of empty space (we now detect empty tiles and skip the filtering for those areas).

pierotofy commented 11 months ago

Oh yeah.

time ./fastrasterfilter "/datasets/large/mesh_dsm.tif" --output "/datasets/large/median.tif" --window-size 512 --radius 5 --co TILED=YES --co BIGTIFF=IF_SAFER --co COMPRESS=DEFLATE
Input: /datasets/large/mesh_dsm.tif
Size: 45999x96885
Blocks: 17100
Smoothing...1000...2000...3000...4000...5000...6000...7000...8000...9000...10000...11000...12000...13000...14000...15000...16000...17000...17100... done
Wrote /datasets/large/median.tif

real    5m47.263s

On a scrappy core i5 laptop (4 cores).