Commit d6505203 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

FIX: Replaced MultitempFilteringFilter (causing stream artifacts) with a...

FIX: Replaced MultitempFilteringFilter (causing stream artifacts) with a sequence of mean smoothing and bandmath.
parent 7a7821f2
......@@ -139,39 +139,38 @@ def S1CalibOrtho(fld, epsg=None, demfld=None, geoid=None, overwrite=False):
return out
def S1CalibOrthoWithROI(infile, outfile, roi, demfld, geoid, lut='sigma', overwrite=False, ram=1024):
if checkRoiInS1Acquisition(infile, roi):
pipe = []
pipe.append(otb.Registry.CreateApplication('SARCalibration'))
pipe[-1].SetParameterString('in', infile)
pipe[-1].SetParameterString('lut', lut)
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].Execute()
pipe.append(otb.Registry.CreateApplication('OrthoRectification'))
pipe[-1].SetParameterInputImage('io.in', pipe[-2].GetParameterOutputImage('out'))
pipe[-1].SetParameterString('elev.dem', demfld)
pipe[-1].SetParameterString('elev.geoid', geoid)
pipe[-1].SetParameterString('map', 'epsg')
pipe[-1].SetParameterString('map.epsg.code', getRasterEPSG(roi))
pipe[-1].SetParameterInt('opt.gridspacing', 40)
pipe[-1].SetParameterString('opt.ram', str(ram))
pipe[-1].Execute()
pipe.append(otb.Registry.CreateApplication('Superimpose'))
pipe[-1].SetParameterInputImage('inm', pipe[-2].GetParameterOutputImage('io.out'))
pipe[-1].SetParameterString('inr', roi)
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].SetParameterString('out', outfile)
if (os.path.exists(outfile) and not overwrite):
print('Calibration and Orthorectification process skipped, file already exists:\n\t{}'.format(outfile))
else:
pipe[-1].ExecuteAndWriteOutput()
if (os.path.exists(outfile) and not overwrite):
print('Calibration and Orthorectification process skipped, file already exists:\n\t{}'.format(outfile))
return outfile
else:
print('ROI not overlapping with S1 acquisition :\n\t{}'.format(infile))
return None
if checkRoiInS1Acquisition(infile, roi):
pipe = []
pipe.append(otb.Registry.CreateApplication('SARCalibration'))
pipe[-1].SetParameterString('in', infile)
pipe[-1].SetParameterString('lut', lut)
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].Execute()
pipe.append(otb.Registry.CreateApplication('OrthoRectification'))
pipe[-1].SetParameterInputImage('io.in', pipe[-2].GetParameterOutputImage('out'))
pipe[-1].SetParameterString('elev.dem', demfld)
pipe[-1].SetParameterString('elev.geoid', geoid)
pipe[-1].SetParameterString('map', 'epsg')
pipe[-1].SetParameterString('map.epsg.code', getRasterEPSG(roi))
pipe[-1].SetParameterInt('opt.gridspacing', 40)
pipe[-1].SetParameterString('opt.ram', str(ram))
pipe[-1].Execute()
pipe.append(otb.Registry.CreateApplication('Superimpose'))
pipe[-1].SetParameterInputImage('inm', pipe[-2].GetParameterOutputImage('io.out'))
pipe[-1].SetParameterString('inr', roi)
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].SetParameterString('out', outfile)
pipe[-1].ExecuteAndWriteOutput()
return outfile
else:
print('ROI not overlapping with S1 acquisition :\n\t{}'.format(infile))
return None
def checkRoiInS1Acquisition(s1file, roifile):
isIntersecting = False
......@@ -328,13 +327,14 @@ def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_f
print('MultitempFilteringFilter process skipped, files already exists:\n\t{}'.format(existing))
return outfiles
"""
app = otb.Registry.CreateApplication('MultitempFilteringFilter')
app.SetParameterStringList('inl', infiles) # list parameter not accpeted
app.SetParameterString('wr', str(window_radius))
app.SetParameterString('oc', outcore_file)
app.SetParameterString('enl', enl_file)
app.SetParameterString('filtpath', outdir)
app.SetParameterString('ram', str(ram))
app.SetParameterString('ram', str(10*ram))
app.ExecuteAndWriteOutput()
# infiles[0].parent.mkdir_p()
# cmd = ['otbcli_MultitempFilteringFilter', '-inl'] + infiles + ['-wr', str(window_radius), '-oc',
......@@ -343,6 +343,24 @@ def MultitempFilteringFilter(infiles, outdir, window_radius, outcore_file, enl_f
# if verbose:
# print(cmd)
# subprocess.check_call(cmd, shell=False)
"""
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))
pipe[-1].Execute()
pipe.append(otb.Registry.CreateApplication('BandMath'))
pipe[-1].SetParameterStringList('il', [f, outcore_file])
pipe[-1].SetParameterString('exp', 'im1b1*im2b1/im2b2')
pipe[-1].SetParameterString('ram', str(ram))
pipe[-1].SetParameterString('out', outfiles[i])
pipe[-1].ExecuteAndWriteOutput()
i += 1
return outfiles
......
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