kopia lustrzana https://github.com/OpenDroneMap/ODM
Fix median filtering nodata handling
rodzic
2c2ac29d49
commit
88326108e9
|
@ -186,7 +186,7 @@ def create_dem(input_point_cloud, dem_type, output_type='max', radiuses=['0.56']
|
|||
for t in tiles:
|
||||
if not os.path.exists(t['filename']):
|
||||
raise Exception("Error creating %s, %s failed to be created" % (output_file, t['filename']))
|
||||
|
||||
|
||||
# Create virtual raster
|
||||
tiles_vrt_path = os.path.abspath(os.path.join(outdir, "tiles.vrt"))
|
||||
tiles_file_list = os.path.abspath(os.path.join(outdir, "tiles_list.txt"))
|
||||
|
@ -315,6 +315,8 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1):
|
|||
dtype = img.dtypes[0]
|
||||
arr = img.read()[0]
|
||||
|
||||
nodata_locs = numpy.where(arr == nodata)
|
||||
|
||||
# Median filter (careful, changing the value 5 might require tweaking)
|
||||
# the lines below. There's another numpy function that takes care of
|
||||
# these edge cases, but it's slower.
|
||||
|
@ -330,8 +332,7 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1):
|
|||
arr[-1][-2:] = arr[-2][-1] = arr[-2][-2]
|
||||
|
||||
# Median filter leaves a bunch of zeros in nodata areas
|
||||
locs = numpy.where(arr == 0.0)
|
||||
arr[locs] = nodata
|
||||
arr[nodata_locs] = nodata
|
||||
|
||||
# write output
|
||||
with rasterio.open(output_path, 'w', **img.profile) as imgout:
|
||||
|
|
Ładowanie…
Reference in New Issue