Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
f1e57236
Commit
f1e57236
authored
4 years ago
by
Cédric Traizet
Browse files
Options
Downloads
Patches
Plain Diff
REFAC: use ImageMetadata instead of IMIs (ossim) in OpticalCalibration
parent
f8ab02c4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
+58
-56
58 additions, 56 deletions
...tions/AppOpticalCalibration/app/otbOpticalCalibration.cxx
with
58 additions
and
56 deletions
Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
+
58
−
56
View file @
f1e57236
...
...
@@ -394,36 +394,32 @@ private:
// Check if valid metadata information are available to compute ImageToRadiance and RadianceToReflectance
FloatVectorImageType
::
Pointer
inImage
=
GetParameterFloatVectorImage
(
"in"
);
itk
::
MetaDataDictionary
dict
=
inImage
->
GetMetaDataDictionary
();
OpticalImageMetadataInterface
::
Pointer
lImageMetadataInterface
=
OpticalImageMetadataInterfaceFactory
::
CreateIMI
(
dict
);
const
auto
&
metadata
=
inImage
->
GetImageMetadata
(
);
//TODO : Remove, this is an Ossim compatibility layer
lImageMetadataInterface
->
SetImageMetadata
(
inImage
->
GetImageMetadata
());
std
::
string
IMIName
(
lImageMetadataInterface
->
GetNameOfClass
()),
IMIOptDfltName
(
"OpticalDefaultImageMetadataInterface"
);
if
((
IMIName
!=
IMIOptDfltName
))
if
((
otb
::
HasOpticalSensorMetadata
(
metadata
)))
{
ossOutput
<<
"Sensor detected: "
<<
lImageMetadataInterface
->
Get
SensorID
()
<<
std
::
endl
;
ossOutput
<<
"Sensor detected: "
<<
metadata
[
MDStr
::
SensorID
]
<<
std
::
endl
;
itk
::
VariableLengthVector
<
double
>
vlvector
;
std
::
stringstream
ss
;
ossOutput
<<
"Parameters extract from input image: "
<<
std
::
endl
<<
"
\t
Acquisition Day: "
<<
lImageMetadataInterface
->
GetDay
()
<<
std
::
endl
<<
"
\t
Acquisition Month: "
<<
lImageMetadataInterface
->
GetMonth
()
<<
std
::
endl
<<
"
\t
Acquisition Year: "
<<
lImageMetadataInterface
->
GetYear
()
<<
std
::
endl
<<
"
\t
Acquisition Sun Elevation Angle: "
<<
lImageMetadataInterface
->
Get
SunElevation
()
<<
std
::
endl
<<
"
\t
Acquisition Sun Azimuth Angle: "
<<
lImageMetadataInterface
->
Get
SunAzimuth
()
<<
std
::
endl
<<
"
\t
Acquisition Viewing Elevation Angle: "
<<
lImageMetadataInterface
->
Get
SatElevation
()
<<
std
::
endl
<<
"
\t
Acquisition Viewing Azimuth Angle: "
<<
lImageMetadataInterface
->
Get
SatAzimuth
()
<<
std
::
endl
;
vlvector
=
lImageMetadataInterface
->
Get
PhysicalGain
(
);
<<
"
\t
Acquisition Day: "
<<
metadata
[
MDTime
::
AcquisitionDate
].
GetDay
()
<<
std
::
endl
<<
"
\t
Acquisition Month: "
<<
metadata
[
MDTime
::
AcquisitionDate
].
GetMonth
()
<<
std
::
endl
<<
"
\t
Acquisition Year: "
<<
metadata
[
MDTime
::
AcquisitionDate
].
GetYear
()
<<
std
::
endl
<<
"
\t
Acquisition Sun Elevation Angle: "
<<
metadata
[
MDNum
::
SunElevation
]
<<
std
::
endl
<<
"
\t
Acquisition Sun Azimuth Angle: "
<<
metadata
[
MDNum
::
SunAzimuth
]
<<
std
::
endl
<<
"
\t
Acquisition Viewing Elevation Angle: "
<<
metadata
[
MDNum
::
SatElevation
]
<<
std
::
endl
<<
"
\t
Acquisition Viewing Azimuth Angle: "
<<
metadata
[
MDNum
::
SatAzimuth
]
<<
std
::
endl
;
vlvector
=
metadata
.
GetAsVector
(
MDNum
::
PhysicalGain
);
ossOutput
<<
"
\t
Acquisition gain (per band): "
;
for
(
unsigned
int
k
=
0
;
k
<
vlvector
.
Size
();
k
++
)
ossOutput
<<
vlvector
[
k
]
<<
" "
;
ossOutput
<<
std
::
endl
;
vlvector
=
lImageMetadataInterface
->
Get
PhysicalBias
(
);
vlvector
=
metadata
.
GetAsVector
(
MDNum
::
PhysicalBias
);
ossOutput
<<
"
\t
Acquisition bias (per band): "
;
for
(
unsigned
int
k
=
0
;
k
<
vlvector
.
Size
();
k
++
)
ossOutput
<<
vlvector
[
k
]
<<
" "
;
...
...
@@ -431,7 +427,7 @@ private:
DisableParameter
(
"acqui.gainbias"
);
MandatoryOff
(
"acqui.gainbias"
);
vlvector
=
lImageMetadataInterface
->
Get
SolarIrradiance
(
);
vlvector
=
metadata
.
GetAsVector
(
MDNum
::
SolarIrradiance
);
ossOutput
<<
"
\t
Solar Irradiance (per band): "
;
for
(
unsigned
int
k
=
0
;
k
<
vlvector
.
Size
();
k
++
)
ossOutput
<<
vlvector
[
k
]
<<
" "
;
...
...
@@ -443,21 +439,21 @@ private:
ossOutput
<<
"Acquisition Minute already set by user: no overload"
<<
std
::
endl
;
else
{
SetParameterInt
(
"acqui.minute"
,
lImageMetadataInterface
->
GetMinute
());
SetParameterInt
(
"acqui.minute"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetMinute
());
}
if
(
HasUserValue
(
"acqui.hour"
))
ossOutput
<<
"Acquisition Hour already set by user: no overload"
<<
std
::
endl
;
else
{
SetParameterInt
(
"acqui.hour"
,
lImageMetadataInterface
->
GetHour
());
SetParameterInt
(
"acqui.hour"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetHour
());
}
if
(
HasUserValue
(
"acqui.day"
))
ossOutput
<<
"Acquisition Day already set by user: no overload"
<<
std
::
endl
;
else
{
SetParameterInt
(
"acqui.day"
,
lImageMetadataInterface
->
GetDay
());
SetParameterInt
(
"acqui.day"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetDay
());
if
(
IsParameterEnabled
(
"acqui.fluxnormcoeff"
)
||
IsParameterEnabled
(
"acqui.solardistance"
))
DisableParameter
(
"acqui.day"
);
}
...
...
@@ -466,7 +462,7 @@ private:
ossOutput
<<
"Acquisition Month already set by user: no overload"
<<
std
::
endl
;
else
{
SetParameterInt
(
"acqui.month"
,
lImageMetadataInterface
->
GetMonth
());
SetParameterInt
(
"acqui.month"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetMonth
());
if
(
IsParameterEnabled
(
"acqui.fluxnormcoeff"
)
||
IsParameterEnabled
(
"acqui.solardistance"
))
DisableParameter
(
"acqui.month"
);
}
...
...
@@ -475,40 +471,40 @@ private:
ossOutput
<<
"Acquisition Year already set by user: no overload"
<<
std
::
endl
;
else
{
SetParameterInt
(
"acqui.year"
,
lImageMetadataInterface
->
GetYear
());
SetParameterInt
(
"acqui.year"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetYear
());
}
if
(
HasUserValue
(
"acqui.sun.elev"
))
ossOutput
<<
"Acquisition Sun Elevation Angle already set by user: no overload"
<<
std
::
endl
;
else
SetParameterFloat
(
"acqui.sun.elev"
,
lImageMetadataInterface
->
Get
SunElevation
()
);
SetParameterFloat
(
"acqui.sun.elev"
,
metadata
[
MDNum
::
SunElevation
]
);
if
(
HasUserValue
(
"acqui.sun.azim"
))
ossOutput
<<
"Acquisition Sun Azimuth Angle already set by user: no overload"
<<
std
::
endl
;
else
SetParameterFloat
(
"acqui.sun.azim"
,
lImageMetadataInterface
->
Get
SunAzimuth
()
);
SetParameterFloat
(
"acqui.sun.azim"
,
metadata
[
MDNum
::
SunAzimuth
]
);
if
(
HasUserValue
(
"acqui.view.elev"
))
ossOutput
<<
"Acquisition Viewing Elevation Angle already set by user: no overload"
<<
std
::
endl
;
else
SetParameterFloat
(
"acqui.view.elev"
,
lImageMetadataInterface
->
Get
SatElevation
()
);
SetParameterFloat
(
"acqui.view.elev"
,
metadata
[
MDNum
::
SatElevation
]
);
if
(
HasUserValue
(
"acqui.view.azim"
))
ossOutput
<<
"Acquisition Viewing Azimuth Angle already set by user: no overload"
<<
std
::
endl
;
else
SetParameterFloat
(
"acqui.view.azim"
,
lImageMetadataInterface
->
Get
SatAzimuth
()
);
SetParameterFloat
(
"acqui.view.azim"
,
metadata
[
MDNum
::
SatAzimuth
]
);
// Set default value so that they are stored somewhere even if
// they are overloaded by user values
SetDefaultParameterInt
(
"acqui.minute"
,
lImageMetadataInterface
->
GetMinute
());
SetDefaultParameterInt
(
"acqui.hour"
,
lImageMetadataInterface
->
GetHour
());
SetDefaultParameterInt
(
"acqui.day"
,
lImageMetadataInterface
->
GetDay
());
SetDefaultParameterInt
(
"acqui.month"
,
lImageMetadataInterface
->
GetMonth
());
SetDefaultParameterInt
(
"acqui.year"
,
lImageMetadataInterface
->
GetYear
());
SetDefaultParameterFloat
(
"acqui.sun.elev"
,
lImageMetadataInterface
->
Get
SunElevation
()
);
SetDefaultParameterFloat
(
"acqui.sun.azim"
,
lImageMetadataInterface
->
Get
SunAzimuth
()
);
SetDefaultParameterFloat
(
"acqui.view.elev"
,
lImageMetadataInterface
->
Get
SatElevation
()
);
SetDefaultParameterFloat
(
"acqui.view.azim"
,
lImageMetadataInterface
->
Get
SatAzimuth
()
);
SetDefaultParameterInt
(
"acqui.minute"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetMinute
());
SetDefaultParameterInt
(
"acqui.hour"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetHour
());
SetDefaultParameterInt
(
"acqui.day"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetDay
());
SetDefaultParameterInt
(
"acqui.month"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetMonth
());
SetDefaultParameterInt
(
"acqui.year"
,
metadata
[
MDTime
::
AcquisitionDate
].
GetYear
());
SetDefaultParameterFloat
(
"acqui.sun.elev"
,
metadata
[
MDNum
::
SunElevation
]
);
SetDefaultParameterFloat
(
"acqui.sun.azim"
,
metadata
[
MDNum
::
SunAzimuth
]
);
SetDefaultParameterFloat
(
"acqui.view.elev"
,
metadata
[
MDNum
::
SatElevation
]
);
SetDefaultParameterFloat
(
"acqui.view.azim"
,
metadata
[
MDNum
::
SatAzimuth
]
);
}
else
{
...
...
@@ -625,14 +621,8 @@ private:
FloatVectorImageType
::
Pointer
inImage
=
GetParameterFloatVectorImage
(
"in"
);
// Prepare a metadata interface on the input image.
itk
::
MetaDataDictionary
dict
=
inImage
->
GetMetaDataDictionary
();
OpticalImageMetadataInterface
::
Pointer
lImageMetadataInterface
=
OpticalImageMetadataInterfaceFactory
::
CreateIMI
(
dict
);
std
::
string
IMIName
(
lImageMetadataInterface
->
GetNameOfClass
());
std
::
string
IMIOptDfltName
(
"OpticalDefaultImageMetadataInterface"
);
//TODO : Remove, this is an Ossim compatibility layer
lImageMetadataInterface
->
SetImageMetadata
(
inImage
->
GetImageMetadata
());
const
auto
&
metadata
=
inImage
->
GetImageMetadata
();
auto
hasOpticalSensorMetadata
=
HasOpticalSensorMetadata
(
metadata
);
// Set (Date and Day) OR FluxNormalizationCoef to corresponding filters OR solardistance
if
(
IsParameterEnabled
(
"acqui.fluxnormcoeff"
))
...
...
@@ -723,13 +713,13 @@ private:
else
{
// Try to retrieve information from image metadata
if
(
IMIName
!=
IMIOptDfltName
)
if
(
hasOpticalSensorMetadata
)
{
m_ImageToRadianceFilter
->
SetAlpha
(
lImageMetadataInterface
->
Get
PhysicalGain
(
));
m_RadianceToImageFilter
->
SetAlpha
(
lImageMetadataInterface
->
Get
PhysicalGain
(
));
m_ImageToRadianceFilter
->
SetAlpha
(
metadata
.
GetAsVector
(
MDNum
::
PhysicalGain
));
m_RadianceToImageFilter
->
SetAlpha
(
metadata
.
GetAsVector
(
MDNum
::
PhysicalGain
));
m_ImageToRadianceFilter
->
SetBeta
(
lImageMetadataInterface
->
Get
PhysicalBias
(
));
m_RadianceToImageFilter
->
SetBeta
(
lImageMetadataInterface
->
Get
PhysicalBias
(
));
m_ImageToRadianceFilter
->
SetBeta
(
metadata
.
GetAsVector
(
MDNum
::
PhysicalBias
));
m_RadianceToImageFilter
->
SetBeta
(
metadata
.
GetAsVector
(
MDNum
::
PhysicalBias
));
}
else
itkExceptionMacro
(
<<
"Please, provide a type of sensor supported by OTB for automatic metadata extraction! "
);
...
...
@@ -781,10 +771,10 @@ private:
else
{
// Try to retrieve information from image metadata
if
(
IMIName
!=
IMIOptDfltName
)
if
(
hasOpticalSensorMetadata
)
{
m_RadianceToReflectanceFilter
->
SetSolarIllumination
(
lImageMetadataInterface
->
Get
SolarIrradiance
(
));
m_ReflectanceToRadianceFilter
->
SetSolarIllumination
(
lImageMetadataInterface
->
Get
SolarIrradiance
(
));
m_RadianceToReflectanceFilter
->
SetSolarIllumination
(
metadata
.
GetAsVector
(
MDNum
::
SolarIrradiance
));
m_ReflectanceToRadianceFilter
->
SetSolarIllumination
(
metadata
.
GetAsVector
(
MDNum
::
SolarIrradiance
));
}
else
itkExceptionMacro
(
<<
"Please, provide a type of sensor supported by OTB for automatic metadata extraction! "
);
...
...
@@ -873,10 +863,22 @@ private:
else
otbAppLogFATAL
(
"Please, set a sensor relative spectral response file."
);
}
else
if
(
IMIName
!=
IMIOptDfltName
)
else
if
(
hasOpticalSensorMetadata
)
{
// Avoid to call GetSpectralSensitivity() multiple times
OpticalImageMetadataInterface
::
WavelengthSpectralBandVectorType
spectralSensitivity
=
lImageMetadataInterface
->
GetSpectralSensitivity
();
auto
spectralSensitivity
=
AcquiCorrectionParametersType
::
InternalWavelengthSpectralBandVectorType
::
New
();
for
(
const
auto
&
band
:
metadata
.
Bands
)
{
const
auto
&
spectralSensitivityLUT
=
band
[
MDL1D
::
SpectralSensitivity
];
const
auto
&
axis
=
spectralSensitivityLUT
.
Axis
[
0
];
auto
filterFunction
=
FilterFunctionValues
::
New
();
// LUT1D stores a double vector whereas FilterFunctionValues stores a float vector
std
::
vector
<
float
>
vec
(
spectralSensitivityLUT
.
Array
.
begin
(),
spectralSensitivityLUT
.
Array
.
end
());
filterFunction
->
SetFilterFunctionValues
(
vec
);
filterFunction
->
SetMinSpectralValue
(
axis
.
Origin
);
filterFunction
->
SetMaxSpectralValue
(
axis
.
Origin
+
axis
.
Spacing
*
axis
.
Size
);
filterFunction
->
SetUserStep
(
axis
.
Spacing
);
spectralSensitivity
->
PushBack
(
filterFunction
);
}
if
(
spectralSensitivity
->
Size
()
>
0
)
m_paramAcqui
->
SetWavelengthSpectralBand
(
spectralSensitivity
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment