Commit 1d062852 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

ENH: added option to use Lee filter in despeckling procedure.

parent faa48a98
......@@ -312,7 +312,7 @@ def MultitempFilteringOutcore(infiles, outfile, window_radius=3, overwrite=False
# cmd = ['otbcli_MultitempFilteringOutcore', '-inl'] + files + ['-wr', str(window_radius), '-oc',
# outcore_file]
def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_file, overwrite=False, verbose=True, ram=1024):
def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_file, filter='mean', overwrite=False, verbose=True, ram=1024):
infiles = [Path(f) for f in infiles]
outdir = Path(outdir)
......@@ -347,11 +347,19 @@ def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_f
i = 1
for f in infiles:
pipe = []
pipe.append(otb.Registry.CreateApplication('Smoothing'))
pipe[-1].SetParameterString('in', f)
pipe[-1].SetParameterString('type', 'mean')
pipe[-1].SetParameterString('type.mean.radius', str(window_radius))
pipe[-1].SetParameterString('ram', str(ram))
if filter == 'mean':
pipe.append(otb.Registry.CreateApplication('Smoothing'))
pipe[-1].SetParameterString('in', f)
pipe[-1].SetParameterString('type', 'mean')
pipe[-1].SetParameterString('type.mean.radius', str(window_radius))
pipe[-1].SetParameterString('ram', str(ram))
elif filter == 'lee':
pipe.append(otb.Registry.CreateApplication('Despeckle'))
pipe[-1].SetParameterString('in', f)
pipe[-1].SetParameterString('filter', 'lee')
pipe[-1].SetParameterString('filter.lee.rad', str(window_radius))
pipe[-1].SetParameterString('filter.lee.nblooks', '4')
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].Execute()
pipe.append(otb.Registry.CreateApplication('BandMath'))
pipe[-1].SetParameterStringList('il', [outcore_file])
......@@ -426,7 +434,7 @@ def extractROI(infiles, outdir, roi, roiname=None, ncores=12, overwrite=False, v
return outfiles
def multitempSpeckleFilt(infiles, outdir, window_radius=3, overwrite=False, verbose=True, ram=1024):
def multitempSpeckleFilt(infiles, outdir, window_radius=3, filter='mean', overwrite=False, verbose=True, ram=1024):
print('Multi-temporal speckle filtering...')
infiles = [Path(f) for f in infiles]
......@@ -454,7 +462,7 @@ def multitempSpeckleFilt(infiles, outdir, window_radius=3, overwrite=False, verb
print('\tFiltering images {} {} ...'.format(sensor, polar))
psoutfiles = MultitempFilteringFilter(files, outdir, window_radius,
outcore_file, enl_file , overwrite, verbose, ram=ram)
outcore_file, enl_file , filter, overwrite, verbose, ram=ram)
outfiles.extend([outcore_file] + psoutfiles)
......@@ -664,7 +672,7 @@ def raster_epsg(x):
return int(proj.GetAttrValue('AUTHORITY', 1))
def s1process(indir, outdir, epsg=None,
roi=None, buffer=100, dem=None, geoid=None, orthofit=False, lut='sigma',
roi=None, buffer=100, dem=None, geoid=None, orthofit=False, lut='sigma', filter='mean',
direction='descending', satellite='both', step='all', force_clip=False, features=None, skip_db_conversion=False,
features_by_date=False, calib_dir=None, cache_dir=Path('~/.moringa/cache').expanduser(),
ram=1024, ncores=1, overwrite=False, verbose=True):
......@@ -949,7 +957,7 @@ def s1process(indir, outdir, epsg=None,
if 'filter' in step:
print(proc_files)
filtered_dir.mkdir_p()
multitempSpeckleFilt(proc_files, filtered_dir, window_radius=3, overwrite=overwrite, verbose=verbose, ram=ram)
multitempSpeckleFilt(proc_files, filtered_dir, window_radius=3, filter=filter, overwrite=overwrite, verbose=verbose, ram=ram)
if features is not None:
if 'filter' not in step:
......@@ -981,6 +989,11 @@ def parse_cmd_line(argv=sys.argv[1:]):
choices=['sigma', 'gamma', 'beta'],
default='sigma')
parser.add_argument("--filter",
help='Specify mono-date filter to use in multitemporal despeckling.',
choices=['mean', 'lee'],
default='mean')
parser.add_argument("--direction",
help="Direction of acquisition, either ascending, descending",
choices=['descending', 'ascending', 'both'],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment