Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
f1e57236
Commit
f1e57236
authored
Nov 23, 2020
by
Cédric Traizet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REFAC: use ImageMetadata instead of IMIs (ossim) in OpticalCalibration
parent
f8ab02c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
56 deletions
+58
-56
Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
...tions/AppOpticalCalibration/app/otbOpticalCalibration.cxx
+58
-56
No files found.
Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
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
->
GetSensorID
()
<<
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
->
GetSunElevation
()
<<
std
::
endl
<<
"
\t
Acquisition Sun Azimuth Angle: "
<<
lImageMetadataInterface
->
GetSunAzimuth
()
<<
std
::
endl
<<
"
\t
Acquisition Viewing Elevation Angle: "
<<
lImageMetadataInterface
->
GetSatElevation
()
<<
std
::
endl
<<
"
\t
Acquisition Viewing Azimuth Angle: "
<<
lImageMetadataInterface
->
GetSatAzimuth
()
<<
std
::
endl
;
vlvector
=
lImageMetadataInterface
->
GetPhysicalGain
(
);
<<
"
\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
->
GetPhysicalBias
(
);
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
->
GetSolarIrradiance
(
);
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
->
GetSunElevation
()
);
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
->
GetSunAzimuth
()
);
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
->
GetSatElevation
()
);
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
->
GetSatAzimuth
()
);
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
->
GetSunElevation
()
);
SetDefaultParameterFloat
(
"acqui.sun.azim"
,
lImageMetadataInterface
->
GetSunAzimuth
()
);
SetDefaultParameterFloat
(
"acqui.view.elev"
,
lImageMetadataInterface
->
GetSatElevation
()
);
SetDefaultParameterFloat
(
"acqui.view.azim"
,
lImageMetadataInterface
->
GetSatAzimuth
()
);
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
->
GetPhysicalGain
(
));
m_RadianceToImageFilter
->
SetAlpha
(
lImageMetadataInterface
->
GetPhysicalGain
(
));
m_ImageToRadianceFilter
->
SetAlpha
(
metadata
.
GetAsVector
(
MDNum
::
PhysicalGain
));
m_RadianceToImageFilter
->
SetAlpha
(
metadata
.
GetAsVector
(
MDNum
::
PhysicalGain
));
m_ImageToRadianceFilter
->
SetBeta
(
lImageMetadataInterface
->
GetPhysicalBias
(
));
m_RadianceToImageFilter
->
SetBeta
(
lImageMetadataInterface
->
GetPhysicalBias
(
));
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
->
GetSolarIrradiance
(
));
m_ReflectanceToRadianceFilter
->
SetSolarIllumination
(
lImageMetadataInterface
->
GetSolarIrradiance
(
));
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment