Commit 7b028dfc authored by Cyrille Valladeau's avatar Cyrille Valladeau

ENH : TSX calibration

parent 0290d845
......@@ -39,11 +39,11 @@ namespace otb
*/
template <class TInputImage, class TOutputImage >
class ITK_EXPORT TerraSarRadarBrightnessImageFilter :
class ITK_EXPORT TerraSarBrightnessImageFilter :
public itk::UnaryFunctorImageFilter<
TInputImage,
TOutputImage,
ITK_TYPENAME Functor::TerraSarRadarBrightnessImageFunctor< ITK_TYPENAME TInputImage::InternalPixelType, ITK_TYPENAME TOutputImage::InternalPixelType > >
ITK_TYPENAME Functor::TerraSarBrightnessImageFunctor< ITK_TYPENAME TInputImage::InternalPixelType, ITK_TYPENAME TOutputImage::InternalPixelType > >
{
public:
/** Extract input and output images dimensions.*/
......@@ -53,10 +53,10 @@ public:
/** "typedef" to simplify the variables definition and the declaration. */
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename Functor::TerraSarRadarBrightnessImageFunctor<ITK_TYPENAME TInputImage::InternalPixelType,
typedef typename Functor::TerraSarBrightnessImageFunctor<ITK_TYPENAME TInputImage::InternalPixelType,
ITK_TYPENAME OutputImageType::InternalPixelType> FunctorType;
/** "typedef" for standard classes. */
typedef TerraSarRadarBrightnessImageFilter Self;
typedef TerraSarBrightnessImageFilter Self;
typedef itk::UnaryFunctorImageFilter< InputImageType, OutputImageType, FunctorType >
Superclass;
typedef itk::SmartPointer<Self> Pointer;
......@@ -66,7 +66,7 @@ public:
itkNewMacro(Self);
/** return class name. */
itkTypeMacro(TerraSarRadarBrightnessImageFilter, itk::UnaryFunctorImageFilter);
itkTypeMacro(TerraSarBrightnessImageFilter, itk::UnaryFunctorImageFilter);
typedef itk::MetaDataDictionary MetaDataDictionaryType;
......@@ -84,9 +84,9 @@ public:
protected:
/** Constructor */
TerraSarRadarBrightnessImageFilter();
TerraSarBrightnessImageFilter();
/** Destructor */
virtual ~TerraSarRadarBrightnessImageFilter() {};
virtual ~TerraSarBrightnessImageFilter() {};
/** Initialize the functor vector */
void BeforeThreadedGenerateData();
......@@ -98,7 +98,7 @@ private:
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbTerraSarRadarBrightnessImageFilter.txx"
#include "otbTerraSarBrightnessImageFilter.txx"
#endif
#endif
......@@ -15,10 +15,10 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbTerraSarRadarBrightnessImageFilter_txx
#define __otbTerraSarRadarBrightnessImageFilter_txx
#ifndef __otbTerraSarBrightnessImageFilter_txx
#define __otbTerraSarBrightnessImageFilter_txx
#include "otbTerraSarRadarBrightnessImageFilter.h"
#include "otbTerraSarBrightnessImageFilter.h"
#include "otbImageMetadataInterfaceFactory.h"
#include "otbImageMetadataInterfaceBase.h"
......@@ -30,15 +30,15 @@ namespace otb
* Constructor
*/
template <class TInputImage, class TOutputImage>
TerraSarRadarBrightnessImageFilter<TInputImage,TOutputImage>
::TerraSarRadarBrightnessImageFilter()
TerraSarBrightnessImageFilter<TInputImage,TOutputImage>
::TerraSarBrightnessImageFilter()
{
// m_CalFactor = 1.;
}
template <class TInputImage, class TOutputImage>
void
TerraSarRadarBrightnessImageFilter<TInputImage,TOutputImage>
TerraSarBrightnessImageFilter<TInputImage,TOutputImage>
::BeforeThreadedGenerateData()
{
Superclass::BeforeThreadedGenerateData();
......
......@@ -34,18 +34,18 @@ namespace Functor
/**
* \class TerraSarRadarBrightnessImageFunctor
* \class TerraSarBrightnessImageFunctor
* \brief Compute the radar brightness from an modulus image.
*
* \ingroup Functor
* \ingroup Radiometry
*/
template <class TInput, class TOutput>
class TerraSarRadarBrightnessImageFunctor
class TerraSarBrightnessImageFunctor
{
public:
TerraSarRadarBrightnessImageFunctor();
virtual ~TerraSarRadarBrightnessImageFunctor() {};
TerraSarBrightnessImageFunctor();
virtual ~TerraSarBrightnessImageFunctor() {};
typedef std::vector<double> DoubleVectorType;
typedef std::vector<DoubleVectorType> DoubleVectorVectorType;
......@@ -87,10 +87,10 @@ public:
typedef std::vector<long int> LIntVectorType;
typedef itk::Size<2> SizeType;
typedef itk::Index<2> IndexType;
typedef TerraSarRadarBrightnessImageFunctor<double, double> BrightnessFunctorType;
typedef TerraSarBrightnessImageFunctor<double, double> BrightnessFunctorType;
/** Accessors */
void SetCalFactor( double val ) { m_CalFactor = val; m_RadarBrightness.SetCalFactor(val); };
void SetCalFactor( double val ) { m_CalFactor = val; m_Brightness.SetCalFactor(val); };
double GetCalFactor() const { return m_CalFactor; };
void SetNoiseRangeValidityMin( double val ) { m_NoiseRangeValidityMin = val; };
double GetNoiseRangeValidityMin() const { return m_NoiseRangeValidityMin; };
......@@ -116,7 +116,7 @@ public:
void SetPRF( double val ) { m_PRF = val; m_InvPRF = 1./m_PRF; };
double GetPRF() const { return m_PRF; };
double GetInvPRF() const { return m_InvPRF; };
BrightnessFunctorType GetRadarBrightness() { return m_RadarBrightness; };
BrightnessFunctorType GetBrightness() { return m_Brightness; };
double ComputeCurrentNoise( unsigned int colId );
DoubleVectorType ComputeCurrentCoeffs( unsigned int lineId );
......@@ -153,7 +153,7 @@ private:
/** Inverse Pulse Repetition Frequency */
double m_InvPRF;
/** Radar Brightness functor */
BrightnessFunctorType m_RadarBrightness;
BrightnessFunctorType m_Brightness;
};
......
......@@ -27,11 +27,11 @@ namespace Functor
{
/******************************************************************/
/*********** TerraSarRadarBrightnessImageFunctor *****************/
/*********** TerraSarBrightnessImageFunctor *****************/
/******************************************************************/
template <class TInput, class TOutput>
TerraSarRadarBrightnessImageFunctor<TInput, TOutput>
::TerraSarRadarBrightnessImageFunctor()
TerraSarBrightnessImageFunctor<TInput, TOutput>
::TerraSarBrightnessImageFunctor()
{
m_CalFactor = 1.;
}
......@@ -39,7 +39,7 @@ TerraSarRadarBrightnessImageFunctor<TInput, TOutput>
template <class TInput, class TOutput>
TOutput
TerraSarRadarBrightnessImageFunctor<TInput, TOutput>
TerraSarBrightnessImageFunctor<TInput, TOutput>
::operator() (const TInput & inPix)
{
double squareInPix = vcl_pow( static_cast<double>(inPix), 2.);
......@@ -52,7 +52,7 @@ TerraSarRadarBrightnessImageFunctor<TInput, TOutput>
template <class TInput, class TOutput>
std::complex<TOutput>
TerraSarRadarBrightnessImageFunctor<TInput, TOutput>
TerraSarBrightnessImageFunctor<TInput, TOutput>
::operator() (const std::complex<TInput> & inPix)
{
// Beta naught computation, will be the Modulus of the result
......@@ -63,7 +63,8 @@ TerraSarRadarBrightnessImageFunctor<TInput, TOutput>
// We retrieve the complex value from the modulus and the phase.
std::complex<TOutput> res = std::complex<TOutput>(beta*vcl_cos(phase), beta*vcl_sin(phase) );
return static_cast<TOutput>(res);
return res;
}
......@@ -80,10 +81,11 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
m_NoiseRangeValidityRef = 0.;
m_LocalIncidentAngle = 0.;
m_SinLocalIncidentAngle = 0.;
m_NoisePolynomialCoefficientsList.clear();
m_NoisePolynomialCoefficientsList = DoubleVectorVectorType( 1, DoubleVectorType(1, 0.) );
m_ImageSize.Fill(0);
m_UseFastCalibrationMethod = true;
m_TimeUTC.clear();
m_TimeUTC = LIntVectorType(2, 0);
m_TimeUTC[1] = 1;
m_PRF = 1.;
}
......@@ -105,7 +107,7 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
{
curRange = m_NoiseRangeValidityRef + ( m_NoiseRangeValidityMax-m_NoiseRangeValidityRef )/width_2 * (static_cast<double>(colId+1) - width_2 );
}
return curRange;
}
......@@ -130,6 +132,7 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
unsigned int id = 0;
bool go = true;
// deduct the corresponding noise acquisition index
while( id<m_TimeUTC.size() && go)
{
if( currTimeUTC < m_TimeUTC[id] )
......@@ -137,13 +140,14 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
id++;
}
id--;
double timeCoef = 1. / (m_TimeUTC[id]- m_TimeUTC[id-1]) * (currTimeUTC-m_TimeUTC[id-1]);
for(unsigned int j=0; j<m_NoisePolynomialCoefficientsList.size(); j++)
{
curCoeffs.push_back( m_NoisePolynomialCoefficientsList[id-1][j] + (m_NoisePolynomialCoefficientsList[id][j] - m_NoisePolynomialCoefficientsList[id-1][j]) * timeCoef );
}
}
return curCoeffs;
}
......@@ -157,7 +161,7 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
double diffCurRange = ComputeCurrentNoise( static_cast<unsigned int>(index[0]) ) - this->GetNoiseRangeValidityRef();
DoubleVectorType curCoeff = this->ComputeCurrentCoeffs( static_cast<unsigned int>(index[1]) );
double outRadBr = this->GetRadarBrightness()( static_cast<double>(inPix) );
double outRadBr = this->GetBrightness()( static_cast<double>(inPix) );
double NEBN = 0.;
for(unsigned int i=0; i<curCoeff.size(); i++)
......@@ -179,7 +183,7 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
DoubleVectorType curCoeff = this->ComputeCurrentCoeffs( static_cast<unsigned int>(index[1]) );
double modulus = std::abs(inPix);
double outRadBr = static_cast<double>(this->GetRadarBrightness()( modulus ));
double outRadBr = static_cast<double>(this->GetBrightness()( modulus ));
double NEBN = 0.;
for(unsigned int i=0; i<curCoeff.size(); i++)
......
......@@ -1028,6 +1028,16 @@ ADD_TEST(raTvAeronet_ArcachonLevel10_ExtractData ${RADIOMETRY_TESTS8}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbRADIOMETRY_TESTS9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ------- TerraSarCalibrationImageFunctor ------------------------------
ADD_TEST(raTvTerraSarCalibrationImageFunctor ${RADIOMETRY_TESTS9}
# --compare-image ${EPSILON}
# ${BASELINE}/raTvTerraSarCalibrationImageFunctor.tif
# ${TEMP}/raTvTerraSarCalibrationImageFunctor.tif
otbTerraSarCalibrationImageFunctor
# ${INPUTDATA}/ExtractIMAGE_HH_SRA_strip_012.tif
# ${TEMP}/raTvTerraSarCalibrationImageFunctor.tif
)
# ------- TerraSarCalibrationImageFilter ------------------------------
ADD_TEST(raTuTerraSarCalibrationImageFilterNew ${RADIOMETRY_TESTS9}
otbTerraSarCalibrationImageFilterNew
......@@ -1042,18 +1052,28 @@ ADD_TEST(raTvTerraSarCalibrationImageFilterTest ${RADIOMETRY_TESTS9}
${TEMP}/raTvTerraSarCalibrationImageFilterTest.tif
)
# ------- TerraSarRadarBrightnessImageFilter ------------------------------
ADD_TEST(raTuTerraSarRadarBrightnessImageFilterNew ${RADIOMETRY_TESTS9}
otbTerraSarRadarBrightnessImageFilterNew
# ------- TerraSarBrightnessImageFunctor ------------------------------
ADD_TEST(raTvTerraSarBrightnessImageFunctor ${RADIOMETRY_TESTS9}
# --compare-image ${EPSILON}
# ${BASELINE}/raTvTerraSarBrightnessImageFunctor.tif
# ${TEMP}/raTvTerraSarBrightnessImageFunctor.tif
otbTerraSarBrightnessImageFunctor
# ${INPUTDATA}/ExtractIMAGE_HH_SRA_strip_012.tif
# ${TEMP}/raTvTerraSarBrightnessImageFunctor.tif
)
# ------- TerraSarBrightnessImageFilter ------------------------------
ADD_TEST(raTuTerraSarBrightnessImageFilterNew ${RADIOMETRY_TESTS9}
otbTerraSarBrightnessImageFilterNew
)
ADD_TEST(raTvTerraSarRadarBrightnessImageFilterTest ${RADIOMETRY_TESTS9}
ADD_TEST(raTvTerraSarBrightnessImageFilterTest ${RADIOMETRY_TESTS9}
--compare-image ${EPSILON}
${BASELINE}/raTvTerraSarRadarBrightnessImageFilterTest.tif
${TEMP}/raTvTerraSarRadarBrightnessImageFilterTest.tif
otbTerraSarRadarBrightnessImageFilterTest
${BASELINE}/raTvTerraSarBrightnessImageFilterTest.tif
${TEMP}/raTvTerraSarBrightnessImageFilterTest.tif
otbTerraSarBrightnessImageFilterTest
${INPUTDATA}/ExtractIMAGE_HH_SRA_strip_012.tif
${TEMP}/raTvTerraSarRadarBrightnessImageFilterTest.tif
${TEMP}/raTvTerraSarBrightnessImageFilterTest.tif
)
......@@ -1150,10 +1170,12 @@ otbAeronetExtractDataBadData.cxx
SET(Radiometry_SRCS9
otbRadiometryTests9.cxx
otbTerraSarCalibrationImageFunctor.cxx
otbTerraSarCalibrationImageFilterNew.cxx
otbTerraSarCalibrationImageFilterTest.cxx
otbTerraSarRadarBrightnessImageFilterNew.cxx
otbTerraSarRadarBrightnessImageFilterTest.cxx
otbTerraSarBrightnessImageFunctor.cxx
otbTerraSarBrightnessImageFilterNew.cxx
otbTerraSarBrightnessImageFilterTest.cxx
)
......
......@@ -27,10 +27,12 @@
void RegisterTests()
{
REGISTER_TEST(otbTerraSarCalibrationImageFilterNew);
REGISTER_TEST(otbTerraSarCalibrationImageFilterTest);
REGISTER_TEST(otbTerraSarRadarBrightnessImageFilterNew);
REGISTER_TEST(otbTerraSarRadarBrightnessImageFilterTest);
REGISTER_TEST(otbTerraSarBrightnessImageFunctor);
REGISTER_TEST(otbTerraSarCalibrationImageFunctor);
REGISTER_TEST(otbTerraSarCalibrationImageFilterNew);
REGISTER_TEST(otbTerraSarCalibrationImageFilterTest);
REGISTER_TEST(otbTerraSarBrightnessImageFilterNew);
REGISTER_TEST(otbTerraSarBrightnessImageFilterTest);
}
......
......@@ -17,13 +17,13 @@
=========================================================================*/
#include "itkExceptionObject.h"
#include "otbTerraSarRadarBrightnessImageFilter.h"
#include "otbTerraSarBrightnessImageFilter.h"
#include "otbImage.h"
int otbTerraSarRadarBrightnessImageFilterNew(int argc, char * argv[])
int otbTerraSarBrightnessImageFilterNew(int argc, char * argv[])
{
typedef otb::Image<double, 2> ImageType;
typedef otb::TerraSarRadarBrightnessImageFilter<ImageType, ImageType> FilterType;
typedef otb::Image<double, 2> ImageType;
typedef otb::TerraSarBrightnessImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
......
......@@ -17,21 +17,21 @@
=========================================================================*/
#include "itkExceptionObject.h"
#include "otbTerraSarRadarBrightnessImageFilter.h"
#include "otbTerraSarBrightnessImageFilter.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
int otbTerraSarRadarBrightnessImageFilterTest(int argc, char * argv[])
int otbTerraSarBrightnessImageFilterTest(int argc, char * argv[])
{
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
typedef otb::Image<double, 2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::TerraSarRadarBrightnessImageFilter<ImageType, ImageType> FilterType;
typedef otb::Image<double, 2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::TerraSarBrightnessImageFilter<ImageType, ImageType> FilterType;
ReaderType::Pointer reader = ReaderType::New();
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkExceptionObject.h"
#include "otbTerraSarFunctors.h"
int otbTerraSarBrightnessImageFunctor(int argc, char * argv[])
{
typedef double ScalarType;
typedef std::complex<ScalarType> ComplexType;
typedef otb::Functor::TerraSarBrightnessImageFunctor<ScalarType, ScalarType> FunctorType;
FunctorType funct;
ScalarType inPix = 150.2;
std::cout << inPix << " -> " << funct.operator()(inPix) << std::endl;
ComplexType inCplxPix(12, 180);
std::cout << inCplxPix << " -> " << funct.operator()(inCplxPix) << std::endl;
return EXIT_SUCCESS;
}
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkExceptionObject.h"
#include "otbTerraSarFunctors.h"
#include "itkIndex.h"
int otbTerraSarCalibrationImageFunctor(int argc, char * argv[])
{
typedef double ScalarType;
typedef std::complex<ScalarType> ComplexType;
typedef itk::Index<> IndexType;
typedef otb::Functor::TerraSarCalibrationImageFunctor<ScalarType, ScalarType> FunctorType;
FunctorType funct;
IndexType id;
id[0] = 125; id[0] = 150;
ScalarType inPix = 150.2;
std::cout << inPix << " -> " << funct.operator()(inPix, id) << std::endl;
ComplexType inCplxPix(12, 180);
std::cout << inCplxPix << " -> " << funct.operator()(inCplxPix, id) << std::endl;
return EXIT_SUCCESS;
}
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