diff --git a/Code/Radiometry/otbRadarFunctors.h b/Code/Radiometry/otbRadarFunctors.h deleted file mode 100644 index b57a2029f45174c6cae3079cab4665826b3d640b..0000000000000000000000000000000000000000 --- a/Code/Radiometry/otbRadarFunctors.h +++ /dev/null @@ -1,305 +0,0 @@ -/*========================================================================= - - Program: ORFEO Toolbox - Language: C++ - Date: $Date$ - Version: $Revision$ - - - Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. - See OTBCopyright.txt for details. - - - Some parts of this code are derived from ITK. See ITKCopyright.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. - -=========================================================================*/ -#ifndef __otbRadarFunctors_h -#define __otbRadarFunctors_h - - -#include "itkUnaryFunctorImageFilter.h" -#include "itkMetaDataDictionary.h" -#include "otbMath.h" - -namespace otb -{ -namespace Functor -{ -/** - * \class TerraSarRadarBrightnessImageFunctor - * \brief Compute the radar brightness from an modulus image. - * - * \ingroup Functor - * \ingroup Radiometry - */ -template <class TInput, class TOutput> -class TerraSarRadarBrightnessImageFunctor -{ -public: - TerraSarRadarBrightnessImageFunctor() - { - m_CalFactor = 1.; - }; - virtual ~TerraSarRadarBrightnessImageFunctor() {}; - - typedef std::vector<double> DoubleVectorType; - typedef std::vector<DoubleVectorType> DoubleVectorVectorType; - typedef itk::Size<2> SizeType; - - /** Accessors */ - void SetCalFactor( double val ) { m_CalFactor = val; }; - double GetCalFactor() { return m_CalFactor; }; - - - inline TOutput operator() (const TInput & inPix) - { - double squareInPix = vcl_pow( static_cast<double>(inPix), 2.); - // Beta naught computation - double beta = m_CalFactor*squareInPix; - - return static_cast<TOutput>(beta); - } - -private: - /** Calibration Factor */ - double m_CalFactor; -}; - - - -/** - * \class TerraSarRadarBrightnessComplexImageFunctor - * \brief Compute the radar brightness from an complexe image. - * - * \ingroup Functor - * \ingroup Radiometry - */ -template <class TInput, class TOutput> -class TerraSarRadarBrightnessComplexImageFunctor -{ -public: - TerraSarRadarBrightnessComplexImageFunctor() {}; - virtual ~TerraSarRadarBrightnessComplexImageFunctor() {}; - - typedef TerraSarRadarBrightnessImageFunctor<double, double> BetaNaughtFunctorType; - - /** Accessors */ - void SetCalFactor( double val ) { m_BetaNaughtFunctor.SetCalFactor(val); }; - double GetCalFactor() { return m_BetaNaughtFunctor.GetCalFactor(); }; - - /* We assume that the input pixel is a complex */ - inline TOutput operator() (const TInput & inPix) - { - - - // Beta naught computation, will be the Modulus of the result - double beta = m_BetaNaughtFunctor(static_cast<double>(std::abs(inPix))); - - // Phase - double phase = std::arg(inPix); - - // We retrieve the complex value from the modulus and the phase. - std::complex<double> res = std::complex<double>(beta*vcl_cos(phase), beta*vcl_sin(phase) ); - - return static_cast<TOutput>(res); - } - -private: - /** Calibration Factor */ - BetaNaughtFunctorType m_BetaNaughtFunctor; -}; - - -/** - * \class TerraSarCalibrationImageFunctor - * \brief Compute sigma naught coefficient from a modulus image. - * - * \ingroup Functor - * \ingroup Radiometry - */ -template<class TInput, class TOutput> -class TerraSarCalibrationImageFunctor -{ -public: - TerraSarCalibrationImageFunctor(); - virtual ~TerraSarCalibrationImageFunctor() {}; - - typedef std::vector<double> DoubleVectorType; - typedef std::vector<DoubleVectorType> DoubleVectorVectorType; - typedef std::vector<long int> LIntVectorType; - typedef itk::Size<2> SizeType; - typedef itk::Index<2> IndexType; - //typedef typename TInputIt::PixelType InputPixelType; - typedef TerraSarRadarBrightnessImageFunctor<TInput, TOutput> BrightnessFunctorType; - - /** Accessors */ - void SetCalFactor( double val ) { m_CalFactor = val; m_RadarBrightness.SetCalFactor(val); }; - double GetCalFactor() const { return m_CalFactor; }; - void SetNoiseRangeValidityMin( double val ) { m_NoiseRangeValidityMin = val; }; - double GetNoiseRangeValidityMin() const { return m_NoiseRangeValidityMin; }; - void SetNoiseRangeValidityMax( double val ) { m_NoiseRangeValidityMax = val; }; - double GetNoiseRangeValidityMax() const { return m_NoiseRangeValidityMax; }; - void SetNoiseRangeValidityRef( double val ) { m_NoiseRangeValidityRef = val; }; - double GetNoiseRangeValidityRef() const { return m_NoiseRangeValidityRef; }; - void SetLocalIncidentAngle( double val ) - { - m_LocalIncidentAngle = val; - m_SinLocalIncidentAngle = vcl_sin(m_LocalIncidentAngle*CONST_PI_180); - }; - double GetLocalIncidentAngle() const { return m_LocalIncidentAngle; }; - double GetSinLocalIncidentAngle() const { return m_SinLocalIncidentAngle; }; - void SetNoisePolynomialCoefficientsList( DoubleVectorVectorType vect ) { m_NoisePolynomialCoefficientsList = vect; }; - DoubleVectorVectorType GetNoisePolynomialCoefficientsList() const { return m_NoisePolynomialCoefficientsList; }; - void SetImageSize( SizeType size ) { m_ImageSize = size; }; - SizeType GetImageSize() const { return m_ImageSize; }; - void SetUseFastCalibrationMethod( bool b ) { m_UseFastCalibrationMethod = b; }; - bool GetUseFastCalibrationMethod() const { return m_UseFastCalibrationMethod; }; - void SetTimeUTC( LIntVectorType vect ) { m_TimeUTC = vect; }; - LIntVectorType GetTimeUTC() const { return m_TimeUTC; }; - 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() const { return m_RadarBrightness; }; - //BrightnessFunctorType GetRadarBrightness() { return m_RadarBrightness; }; - - double ComputeCurrentNoise( unsigned int colId ); - DoubleVectorType ComputeCurrentCoeffs( unsigned int lineId ); - inline TOutput operator() (const TInput & inPix, IndexType index); - - -private: - /** Calibration Factor */ - double m_CalFactor; - /** Noise minimal range validity */ - double m_NoiseRangeValidityMin; - /** Noise maxinimal range validity */ - double m_NoiseRangeValidityMax; - /** Noise reference range */ - double m_NoiseRangeValidityRef; - /** Sensor local incident angle in degree */ - double m_LocalIncidentAngle; - /** sin of the LocalIncidentAngle */ - double m_SinLocalIncidentAngle; - /** Vector of vector that contain noise polinomial coefficient */ - DoubleVectorVectorType m_NoisePolynomialCoefficientsList; - /** Image Size */ - SizeType m_ImageSize; - /** Fast Calibration Method. If set to trus, will consider only the first noise coefficient else, - * will use all of them and applied it according to its acquisition UTC time and the coordinates - * of the pixel in the image. */ - bool m_UseFastCalibrationMethod; - /** TimeUTC for each noise coefficient acquisition (in second). */ - LIntVectorType m_TimeUTC; - /** Pulse Repetition Frequency */ - double m_PRF; - /** Inverse Pulse Repetition Frequency */ - double m_InvPRF; - /** Radar Brightness functor */ - BrightnessFunctorType m_RadarBrightness; - -}; - -/** TODO : Use inheritance **/ - -/** - * \class TerraSarCalibrationComplexImageFunctor - * \brief Compute sigma naught coefficient from a modulus image. - * - * \ingroup Functor - * \ingroup Radiometry - */ -template <class TInput, class TOutput> - class TerraSarCalibrationComplexImageFunctor -{ - -public: - TerraSarCalibrationComplexImageFunctor(); - virtual ~TerraSarCalibrationComplexImageFunctor() {}; - typedef std::vector<double> DoubleVectorType; - typedef std::vector<DoubleVectorType> DoubleVectorVectorType; - typedef std::vector<long int> LIntVectorType; - typedef itk::Size<2> SizeType; - typedef itk::Index<2> IndexType; - //typedef typename TInputIt::PixelType InputPixelType; - typedef TerraSarRadarBrightnessImageFunctor<double, double> BrightnessFunctorType; - - /** Accessors */ - void SetCalFactor( double val ) { m_CalFactor = val; m_RadarBrightness.SetCalFactor(val); }; - double GetCalFactor() const { return m_CalFactor; }; - void SetNoiseRangeValidityMin( double val ) { m_NoiseRangeValidityMin = val; }; - double GetNoiseRangeValidityMin() const { return m_NoiseRangeValidityMin; }; - void SetNoiseRangeValidityMax( double val ) { m_NoiseRangeValidityMax = val; }; - double GetNoiseRangeValidityMax() const { return m_NoiseRangeValidityMax; }; - void SetNoiseRangeValidityRef( double val ) { m_NoiseRangeValidityRef = val; }; - double GetNoiseRangeValidityRef() const { return m_NoiseRangeValidityRef; }; - void SetLocalIncidentAngle( double val ) - { - m_LocalIncidentAngle = val; - m_SinLocalIncidentAngle = vcl_sin(m_LocalIncidentAngle*CONST_PI_180); - }; - double GetLocalIncidentAngle() const { return m_LocalIncidentAngle; }; - double GetSinLocalIncidentAngle() const { return m_SinLocalIncidentAngle; }; - void SetNoisePolynomialCoefficientsList( DoubleVectorVectorType vect ) { m_NoisePolynomialCoefficientsList = vect; }; - DoubleVectorVectorType GetNoisePolynomialCoefficientsList() const { return m_NoisePolynomialCoefficientsList; }; - void SetImageSize( SizeType size ) { m_ImageSize = size; }; - SizeType GetImageSize() const { return m_ImageSize; }; - void SetUseFastCalibrationMethod( bool b ) { m_UseFastCalibrationMethod = b; }; - bool GetUseFastCalibrationMethod() const { return m_UseFastCalibrationMethod; }; - void SetTimeUTC( LIntVectorType vect ) { m_TimeUTC = vect; }; - LIntVectorType GetTimeUTC() const { return m_TimeUTC; }; - 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() const { return m_RadarBrightness; }; - //BrightnessFunctorType GetRadarBrightness() { return m_RadarBrightness; }; - - double ComputeCurrentNoise( unsigned int colId ); - DoubleVectorType ComputeCurrentCoeffs( unsigned int lineId ); - inline TOutput operator() (const TInput & inPix, IndexType index); - - -private: - /** Calibration Factor */ - double m_CalFactor; - /** Noise minimal range validity */ - double m_NoiseRangeValidityMin; - /** Noise maxinimal range validity */ - double m_NoiseRangeValidityMax; - /** Noise reference range */ - double m_NoiseRangeValidityRef; - /** Sensor local incident angle in degree */ - double m_LocalIncidentAngle; - /** sin of the LocalIncidentAngle */ - double m_SinLocalIncidentAngle; - /** Vector of vector that contain noise polinomial coefficient */ - DoubleVectorVectorType m_NoisePolynomialCoefficientsList; - /** Image Size */ - SizeType m_ImageSize; - /** Fast Calibration Method. If set to trus, will consider only the first noise coefficient else, - * will use all of them and applied it according to its acquisition UTC time and the coordinates - * of the pixel in the image. */ - bool m_UseFastCalibrationMethod; - /** TimeUTC for each noise coefficient acquisition (in second). */ - LIntVectorType m_TimeUTC; - /** Pulse Repetition Frequency */ - double m_PRF; - /** Inverse Pulse Repetition Frequency */ - double m_InvPRF; - /** Radar Brightness functor */ - BrightnessFunctorType m_RadarBrightness; -}; - -}// end namespace functor -} // end namespace otb - -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbRadarFunctors.txx" -#endif - -#endif diff --git a/Code/Radiometry/otbRadarFunctors.txx b/Code/Radiometry/otbRadarFunctors.txx deleted file mode 100644 index 5dce6c077378ced9fdce10230f9c9c85f7a86d69..0000000000000000000000000000000000000000 --- a/Code/Radiometry/otbRadarFunctors.txx +++ /dev/null @@ -1,237 +0,0 @@ -/*========================================================================= - - 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. - -=========================================================================*/ -#ifndef __otbRadarFunctors_txx -#define __otbRadarFunctors_txx - -#include "otbRadarFunctors.h" - - -namespace otb -{ -/************************************************************************** - ***************** TerraSarCalibrationImageFunctor ******************* - **************************************************************************/ -namespace Functor -{ -/** Constructor */ -template <class TInput, class TOutput> -TerraSarCalibrationImageFunctor<TInput, TOutput> -::TerraSarCalibrationImageFunctor() -{ - m_CalFactor = 1.; - m_NoiseRangeValidityMin = 0.; - m_NoiseRangeValidityMax = 0.; - m_NoiseRangeValidityRef = 0.; - m_LocalIncidentAngle = 0.; - m_NoisePolynomialCoefficientsList.clear(); - m_ImageSize.Fill(0); - m_UseFastCalibrationMethod = true; - m_TimeUTC.clear(); - m_PRF = 1.; -} - - -template <class TInput, class TOutput> -double -TerraSarCalibrationImageFunctor<TInput, TOutput> -::ComputeCurrentNoise( unsigned int colId ) - { - double curRange = 0.; - double width_2 = static_cast<double>(m_ImageSize[0])/2.; - - // Use +1 because image start index is 0 - if( colId < static_cast<unsigned int>(width_2) ) - { - curRange = m_NoiseRangeValidityMin + ( m_NoiseRangeValidityRef-m_NoiseRangeValidityMin )/width_2 * static_cast<double>(colId+1); - } - else - { - curRange = m_NoiseRangeValidityRef + ( m_NoiseRangeValidityMax-m_NoiseRangeValidityRef )/width_2 * (static_cast<double>(colId+1) - width_2 ); - } - - return curRange; - } - - -template <class TInput, class TOutput> -typename TerraSarCalibrationImageFunctor<TInput, TOutput>::DoubleVectorType -TerraSarCalibrationImageFunctor<TInput, TOutput> -::ComputeCurrentCoeffs( unsigned int lineId ) - { - DoubleVectorType curCoeffs; - if(m_UseFastCalibrationMethod) - { - curCoeffs = m_NoisePolynomialCoefficientsList[0]; - } - else - { - // m_ImageSize[1]-(lineId+1) because the first acquisition line is the last image one. - // line+1 because image starts to 0. - //double interval = static_cast<double>(m_ImageSize[1]) / static_cast<double>(m_NoisePolynomialCoefficientsList.size()); - // compute utc time of the line - double currTimeUTC = m_TimeUTC[0] + static_cast<double>(m_ImageSize[1]-(lineId-1))*m_InvPRF; - unsigned int id = 0; - bool go = true; - // deduct the corresponding noise acquisition index - while( id<m_TimeUTC.size() && go) - { - if( currTimeUTC < m_TimeUTC[id] ) - go = false; - 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; - } - -template <class TInput, class TOutput> -TOutput -TerraSarCalibrationImageFunctor<TInput, TOutput> -::operator()(const TInput & inPix, IndexType index) -{ - double diffCurRange = ComputeCurrentNoise( static_cast<unsigned int>(index[0]) ) - m_NoiseRangeValidityRef; - DoubleVectorType curCoeff = ComputeCurrentCoeffs( static_cast<unsigned int>(index[1]) ); - - TOutput outRadBr = m_RadarBrightness( inPix ); - - double NEBN = 0.; - for(unsigned int i=0; i<curCoeff.size(); i++) - { - NEBN += curCoeff[i]*vcl_pow( diffCurRange, static_cast<double>(i)); - } - double sigma = ( outRadBr - m_CalFactor*NEBN ) * m_SinLocalIncidentAngle; - - return static_cast<TOutput>(sigma); -} - - -/** Constructor */ -template <class TInput, class TOutput> -TerraSarCalibrationComplexImageFunctor<TInput, TOutput> -::TerraSarCalibrationComplexImageFunctor() -{ - m_CalFactor = 1.; - m_NoiseRangeValidityMin = 0.; - m_NoiseRangeValidityMax = 0.; - m_NoiseRangeValidityRef = 0.; - m_LocalIncidentAngle = 0.; - m_NoisePolynomialCoefficientsList.clear(); - m_ImageSize.Fill(0); - m_UseFastCalibrationMethod = true; - m_TimeUTC.clear(); - m_PRF = 1.; -} - - -template <class TInput, class TOutput> -double -TerraSarCalibrationComplexImageFunctor<TInput, TOutput> -::ComputeCurrentNoise( unsigned int colId ) - { - double curRange = 0.; - double width_2 = static_cast<double>(m_ImageSize[0])/2.; - - // Use +1 because image start index is 0 - if( colId < static_cast<unsigned int>(width_2) ) - { - curRange = m_NoiseRangeValidityMin + ( m_NoiseRangeValidityRef-m_NoiseRangeValidityMin )/width_2 * static_cast<double>(colId+1); - } - else - { - curRange = m_NoiseRangeValidityRef + ( m_NoiseRangeValidityMax-m_NoiseRangeValidityRef )/width_2 * (static_cast<double>(colId+1) - width_2 ); - } - - return curRange; - } - - -template <class TInput, class TOutput> -typename TerraSarCalibrationComplexImageFunctor<TInput, TOutput>::DoubleVectorType -TerraSarCalibrationComplexImageFunctor<TInput, TOutput> -::ComputeCurrentCoeffs( unsigned int lineId ) - { - DoubleVectorType curCoeffs; - if(m_UseFastCalibrationMethod) - { - curCoeffs = m_NoisePolynomialCoefficientsList[0]; - } - else - { - // m_ImageSize[1]-(lineId+1) because the first acquisition line is the last image one. - // line+1 because image starts to 0. - // compute utc time of the line - double currTimeUTC = m_TimeUTC[0] + static_cast<double>(m_ImageSize[1]-(lineId-1))*m_InvPRF; - unsigned int id = 0; - bool go = true; - // deduct the corresponding noise acquisition index - while( id<m_TimeUTC.size() && go) - { - if( currTimeUTC < m_TimeUTC[id] ) - go = false; - 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; - } - -template <class TInput, class TOutput> -TOutput -TerraSarCalibrationComplexImageFunctor<TInput, TOutput> -::operator()(const TInput & inPix, IndexType index) -{ - double diffCurRange = this->ComputeCurrentNoise( static_cast<unsigned int>(index[0]) ) - this->GetNoiseRangeValidityRef(); - DoubleVectorType curCoeff = this->ComputeCurrentCoeffs( static_cast<unsigned int>(index[1]) ); - - double modulus = std::abs(inPix); - double outRadBr = static_cast<double>(m_RadarBrightness( modulus )); - - double NEBN = 0.; - for(unsigned int i=0; i<curCoeff.size(); i++) - { - NEBN += curCoeff[i]*vcl_pow( diffCurRange, static_cast<double>(i)); - } - double sigma = ( outRadBr - this->GetCalFactor()*NEBN ) * this->GetSinLocalIncidentAngle(); - - double phase = std::arg(inPix); - - TOutput out(sigma*vcl_cos(phase), sigma*vcl_sin(phase)); - - return out; -} - -}// namespace Functor - -} // namespace otb -#endif diff --git a/Code/Radiometry/otbTerraSarCalibrationImageFilter.h b/Code/Radiometry/otbTerraSarCalibrationImageFilter.h index 94d8f9c31661f957b511429b2a211675a89d0858..3fd4180a63b331cc6dcba674ed6534898cf59c99 100644 --- a/Code/Radiometry/otbTerraSarCalibrationImageFilter.h +++ b/Code/Radiometry/otbTerraSarCalibrationImageFilter.h @@ -24,7 +24,7 @@ #include "otbUnaryFunctorWithIndexImageFilter.h" -#include "otbRadarFunctors.h" +#include "otbTerraSarFunctors.h" #include "itkMetaDataDictionary.h" //#include "itkConstNeighborhoodIterator.h" #include "otbMath.h" diff --git a/Code/Radiometry/otbTerraSarFunctors.h b/Code/Radiometry/otbTerraSarFunctors.h new file mode 100644 index 0000000000000000000000000000000000000000..57c1dd56d2de29751d88ca29f00618a8ff61e4e9 --- /dev/null +++ b/Code/Radiometry/otbTerraSarFunctors.h @@ -0,0 +1,168 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + Some parts of this code are derived from ITK. See ITKCopyright.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. + +=========================================================================*/ +#ifndef __otbTerraSarFunctors_h +#define __otbTerraSarFunctors_h + + +#include "itkUnaryFunctorImageFilter.h" +#include "itkMetaDataDictionary.h" +#include "otbMath.h" + +namespace otb +{ +namespace Functor +{ + + +/** + * \class TerraSarRadarBrightnessImageFunctor + * \brief Compute the radar brightness from an modulus image. + * + * \ingroup Functor + * \ingroup Radiometry + */ +template <class TInput, class TOutput> +class TerraSarRadarBrightnessImageFunctor +{ +public: + TerraSarRadarBrightnessImageFunctor(); + virtual ~TerraSarRadarBrightnessImageFunctor() {}; + + typedef std::vector<double> DoubleVectorType; + typedef std::vector<DoubleVectorType> DoubleVectorVectorType; + typedef itk::Size<2> SizeType; + + /** Accessors */ + void SetCalFactor( double val ) { m_CalFactor = val; }; + double GetCalFactor() { return m_CalFactor; }; + + /** We assume that the input pixel is a scalar -> modulus image */ + inline TOutput operator() (const TInput & inPix); + /** We assume that the input pixel is a complex -> complex image */ + inline std::complex<TOutput> operator() (const std::complex<TInput> & inPix); + +private: + /** Calibration Factor */ + double m_CalFactor; +}; + + + + +/** + * \class TerraSarCalibrationImageFunctor + * \brief Compute sigma naught coefficient from a modulus image. + * + * \ingroup Functor + * \ingroup Radiometry + */ +template<class TInput, class TOutput> +class TerraSarCalibrationImageFunctor +{ +public: + TerraSarCalibrationImageFunctor(); + virtual ~TerraSarCalibrationImageFunctor() {}; + + typedef std::vector<double> DoubleVectorType; + typedef std::vector<DoubleVectorType> DoubleVectorVectorType; + typedef std::vector<long int> LIntVectorType; + typedef itk::Size<2> SizeType; + typedef itk::Index<2> IndexType; + typedef TerraSarRadarBrightnessImageFunctor<double, double> BrightnessFunctorType; + + /** Accessors */ + void SetCalFactor( double val ) { m_CalFactor = val; m_RadarBrightness.SetCalFactor(val); }; + double GetCalFactor() const { return m_CalFactor; }; + void SetNoiseRangeValidityMin( double val ) { m_NoiseRangeValidityMin = val; }; + double GetNoiseRangeValidityMin() const { return m_NoiseRangeValidityMin; }; + void SetNoiseRangeValidityMax( double val ) { m_NoiseRangeValidityMax = val; }; + double GetNoiseRangeValidityMax() const { return m_NoiseRangeValidityMax; }; + void SetNoiseRangeValidityRef( double val ) { m_NoiseRangeValidityRef = val; }; + double GetNoiseRangeValidityRef() const { return m_NoiseRangeValidityRef; }; + void SetLocalIncidentAngle( double val ) + { + m_LocalIncidentAngle = val; + m_SinLocalIncidentAngle = vcl_sin(m_LocalIncidentAngle*CONST_PI_180); + }; + double GetLocalIncidentAngle() const { return m_LocalIncidentAngle; }; + double GetSinLocalIncidentAngle() const { return m_SinLocalIncidentAngle; }; + void SetNoisePolynomialCoefficientsList( DoubleVectorVectorType vect ) { m_NoisePolynomialCoefficientsList = vect; }; + DoubleVectorVectorType GetNoisePolynomialCoefficientsList() const { return m_NoisePolynomialCoefficientsList; }; + void SetImageSize( SizeType size ) { m_ImageSize = size; }; + SizeType GetImageSize() const { return m_ImageSize; }; + void SetUseFastCalibrationMethod( bool b ) { m_UseFastCalibrationMethod = b; }; + bool GetUseFastCalibrationMethod() const { return m_UseFastCalibrationMethod; }; + void SetTimeUTC( LIntVectorType vect ) { m_TimeUTC = vect; }; + LIntVectorType GetTimeUTC() const { return m_TimeUTC; }; + 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; }; + double ComputeCurrentNoise( unsigned int colId ); + DoubleVectorType ComputeCurrentCoeffs( unsigned int lineId ); + + /** We assume that the input pixel is a scalar -> modulus image */ + inline TOutput operator() (const TInput & inPix, IndexType index); + /** We assume that the input pixel is a complex -> complex image */ + inline std::complex<TOutput> operator() (const std::complex<TInput> & inPix, IndexType index); + +private: + /** Calibration Factor */ + double m_CalFactor; + /** Noise minimal range validity */ + double m_NoiseRangeValidityMin; + /** Noise maxinimal range validity */ + double m_NoiseRangeValidityMax; + /** Noise reference range */ + double m_NoiseRangeValidityRef; + /** Sensor local incident angle in degree */ + double m_LocalIncidentAngle; + /** sin of the LocalIncidentAngle */ + double m_SinLocalIncidentAngle; + /** Vector of vector that contain noise polinomial coefficient */ + DoubleVectorVectorType m_NoisePolynomialCoefficientsList; + /** Image Size */ + SizeType m_ImageSize; + /** Fast Calibration Method. If set to trus, will consider only the first noise coefficient else, + * will use all of them and applied it according to its acquisition UTC time and the coordinates + * of the pixel in the image. */ + bool m_UseFastCalibrationMethod; + /** TimeUTC for each noise coefficient acquisition (in second). */ + LIntVectorType m_TimeUTC; + /** Pulse Repetition Frequency */ + double m_PRF; + /** Inverse Pulse Repetition Frequency */ + double m_InvPRF; + /** Radar Brightness functor */ + BrightnessFunctorType m_RadarBrightness; +}; + + + +}// end namespace functor +} // end namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbTerraSarFunctors.txx" +#endif + +#endif diff --git a/Code/Radiometry/otbTerraSarFunctors.txx b/Code/Radiometry/otbTerraSarFunctors.txx new file mode 100644 index 0000000000000000000000000000000000000000..5d23b7886646204de828efee79d870b11e540d53 --- /dev/null +++ b/Code/Radiometry/otbTerraSarFunctors.txx @@ -0,0 +1,202 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef __otbTerraSarFunctors_txx +#define __otbTerraSarFunctors_txx + +#include "otbTerraSarFunctors.h" + + +namespace otb +{ +namespace Functor +{ + +/******************************************************************/ +/*********** TerraSarRadarBrightnessImageFunctor *****************/ +/******************************************************************/ +template <class TInput, class TOutput> +TerraSarRadarBrightnessImageFunctor<TInput, TOutput> +::TerraSarRadarBrightnessImageFunctor() +{ + m_CalFactor = 1.; +} + + +template <class TInput, class TOutput> +TOutput +TerraSarRadarBrightnessImageFunctor<TInput, TOutput> +::operator() (const TInput & inPix) +{ + double squareInPix = vcl_pow( static_cast<double>(inPix), 2.); + // Beta naught computation + double beta = m_CalFactor*squareInPix; + + return static_cast<TOutput>(beta); +} + + +template <class TInput, class TOutput> +std::complex<TOutput> +TerraSarRadarBrightnessImageFunctor<TInput, TOutput> +::operator() (const std::complex<TInput> & inPix) +{ + // Beta naught computation, will be the Modulus of the result + + double beta = operator()(static_cast<double>(std::abs(inPix))); + // Phase + double phase = std::arg(inPix); + + // 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); +} + + +/******************************************************************/ +/*********** TerraSarCalibrationImageFunctor ****************/ +/******************************************************************/ +template <class TInput, class TOutput> +TerraSarCalibrationImageFunctor<TInput, TOutput> +::TerraSarCalibrationImageFunctor() +{ + m_CalFactor = 1.; + m_NoiseRangeValidityMin = 0.; + m_NoiseRangeValidityMax = 0.; + m_NoiseRangeValidityRef = 0.; + m_LocalIncidentAngle = 0.; + m_SinLocalIncidentAngle = 0.; + m_NoisePolynomialCoefficientsList.clear(); + m_ImageSize.Fill(0); + m_UseFastCalibrationMethod = true; + m_TimeUTC.clear(); + m_PRF = 1.; +} + + +template <class TInput, class TOutput> +double +TerraSarCalibrationImageFunctor<TInput, TOutput> +::ComputeCurrentNoise( unsigned int colId ) +{ + double curRange = 0.; + double width_2 = static_cast<double>(m_ImageSize[0])/2.; + + // Use +1 because image start index is 0 + if( colId < static_cast<unsigned int>(width_2) ) + { + curRange = m_NoiseRangeValidityMin + ( m_NoiseRangeValidityRef-m_NoiseRangeValidityMin )/width_2 * static_cast<double>(colId+1); + } + else + { + curRange = m_NoiseRangeValidityRef + ( m_NoiseRangeValidityMax-m_NoiseRangeValidityRef )/width_2 * (static_cast<double>(colId+1) - width_2 ); + } + + return curRange; +} + + +template <class TInput, class TOutput> +typename TerraSarCalibrationImageFunctor<TInput, TOutput>::DoubleVectorType +TerraSarCalibrationImageFunctor<TInput, TOutput> +::ComputeCurrentCoeffs( unsigned int lineId ) +{ + DoubleVectorType curCoeffs; + if(m_UseFastCalibrationMethod) + { + curCoeffs = m_NoisePolynomialCoefficientsList[0]; + } + else + { + // m_ImageSize[1]-(lineId+1) because the first acquisition line is the last image one. + // line+1 because image starts to 0. + //double interval = static_cast<double>(m_ImageSize[1]) / static_cast<double>(m_NoisePolynomialCoefficientsList.size()); + // compute utc time of the line + double currTimeUTC = m_TimeUTC[0] + static_cast<double>(m_ImageSize[1]-(lineId-1))*m_InvPRF; + unsigned int id = 0; + bool go = true; + // deduct the corresponding noise acquisition index + while( id<m_TimeUTC.size() && go) + { + if( currTimeUTC < m_TimeUTC[id] ) + go = false; + 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; +} + + + +template <class TInput, class TOutput> +TOutput +TerraSarCalibrationImageFunctor<TInput, TOutput> +::operator()(const TInput & inPix, IndexType index) +{ + 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 NEBN = 0.; + for(unsigned int i=0; i<curCoeff.size(); i++) + { + NEBN += curCoeff[i]*vcl_pow( diffCurRange, static_cast<double>(i)); + } + double sigma = ( outRadBr - this->GetCalFactor()*NEBN ) * this->GetSinLocalIncidentAngle(); + + return static_cast<TOutput>(sigma); +} + + +template <class TInput, class TOutput> +std::complex<TOutput> +TerraSarCalibrationImageFunctor<TInput, TOutput> +::operator()(const std::complex<TInput> & inPix, IndexType index) +{ + double diffCurRange = this->ComputeCurrentNoise( static_cast<unsigned int>(index[0]) ) - this->GetNoiseRangeValidityRef(); + DoubleVectorType curCoeff = this->ComputeCurrentCoeffs( static_cast<unsigned int>(index[1]) ); + + double modulus = std::abs(inPix); + double outRadBr = static_cast<double>(this->GetRadarBrightness()( modulus )); + + double NEBN = 0.; + for(unsigned int i=0; i<curCoeff.size(); i++) + { + NEBN += curCoeff[i]*vcl_pow( diffCurRange, static_cast<double>(i)); + } + double sigma = ( outRadBr - this->GetCalFactor()*NEBN ) * this->GetSinLocalIncidentAngle(); + + double phase = std::arg(inPix); + + std::complex<TOutput> out(sigma*vcl_cos(phase), sigma*vcl_sin(phase)); + + return out; +} + + +}// namespace Functor + +} // namespace otb +#endif diff --git a/Code/Radiometry/otbTerraSarRadarBrightnessImageFilter.h b/Code/Radiometry/otbTerraSarRadarBrightnessImageFilter.h index 45cef271df62d6733176521097ba34a248663c86..07873aa0a24626c20962d8fbed009d02233f6288 100644 --- a/Code/Radiometry/otbTerraSarRadarBrightnessImageFilter.h +++ b/Code/Radiometry/otbTerraSarRadarBrightnessImageFilter.h @@ -26,7 +26,7 @@ #include "itkUnaryFunctorImageFilter.h" #include "itkMetaDataDictionary.h" #include "otbMath.h" -#include "otbRadarFunctors.h" +#include "otbTerraSarFunctors.h" namespace otb { diff --git a/Testing/Code/Radiometry/CMakeLists.txt b/Testing/Code/Radiometry/CMakeLists.txt index 33d770f937a629d2a488b8e6ba4c09ab7fe62722..746582ae9809434e9dcad8b87f11f2b36ddb0012 100644 --- a/Testing/Code/Radiometry/CMakeLists.txt +++ b/Testing/Code/Radiometry/CMakeLists.txt @@ -1056,38 +1056,8 @@ ADD_TEST(raTvTerraSarRadarBrightnessImageFilterTest ${RADIOMETRY_TESTS9} ${TEMP}/raTvTerraSarRadarBrightnessImageFilterTest.tif ) -# ------- TerraSarRadarBrightnessComplexImageFilter ------------------------------ -ADD_TEST(raTuTerraSarRadarBrightnessComplexImageFilterNew ${RADIOMETRY_TESTS9} - otbTerraSarRadarBrightnessComplexImageFilterNew -) - -ADD_TEST(raTvTerraSarRadarBrightnessComplexImageFilterTest ${RADIOMETRY_TESTS9} - --compare-image ${EPSILON} - ${BASELINE}/raTvTerraSarRadarBrightnessComplexImageFilterTest.tif - ${TEMP}/raTvTerraSarRadarBrightnessComplexImageFilterTest.tif - otbTerraSarRadarBrightnessComplexImageFilterTest - # complex image - ${INPUTDATA}/ExtractIMAGE_HH_SRA_spot_074.tif - ${TEMP}/raTvTerraSarRadarBrightnessComplexImageFilterTest.tif -) -# ------- TerraSarCalibrationCplxImageFilter ------------------------------ - ADD_TEST(raTuTerraSarCalibrationCplxImageFilterNew ${RADIOMETRY_TESTS9} - otbTerraSarCalibrationCplxImageFilterNew -) - -ADD_TEST(raTvTerraSarCalibrationCplxImageFilterTest ${RADIOMETRY_TESTS9} -# TEST GIVE NULL OUTPUT, DON'T HAVE TIME TO CORRECT, SORRY -# --compare-image ${EPSILON} - # ${BASELINE}/raTvTerraSarCalibrationClxImageFilterTest.tif - # ${TEMP}/raTvTerraSarCalibrationCplxImageFilterTest.tif - otbTerraSarCalibrationCplxImageFilterTest - # complex image - ${INPUTDATA}/ExtractIMAGE_HH_SRA_spot_074.tif - ${TEMP}/raTvTerraSarCalibrationCplxImageFilterTest.tif -) - # A enrichir SET(Radiometry_SRCS1 otbRadiometryTests1.cxx @@ -1184,10 +1154,6 @@ otbTerraSarCalibrationImageFilterNew.cxx otbTerraSarCalibrationImageFilterTest.cxx otbTerraSarRadarBrightnessImageFilterNew.cxx otbTerraSarRadarBrightnessImageFilterTest.cxx -otbTerraSarRadarBrightnessComplexImageFilterNew.cxx -otbTerraSarRadarBrightnessComplexImageFilterTest.cxx -otbTerraSarCalibrationCplxImageFilterNew.cxx -otbTerraSarCalibrationCplxImageFilterTest.cxx ) diff --git a/Testing/Code/Radiometry/otbRadiometryTests9.cxx b/Testing/Code/Radiometry/otbRadiometryTests9.cxx index 77efc546f996e334302c2e5729a71fa21b8f3475..54ec4cfaa520aba626c6c4d385b796f2cdca880c 100644 --- a/Testing/Code/Radiometry/otbRadiometryTests9.cxx +++ b/Testing/Code/Radiometry/otbRadiometryTests9.cxx @@ -31,10 +31,6 @@ void RegisterTests() REGISTER_TEST(otbTerraSarCalibrationImageFilterTest); REGISTER_TEST(otbTerraSarRadarBrightnessImageFilterNew); REGISTER_TEST(otbTerraSarRadarBrightnessImageFilterTest); - REGISTER_TEST(otbTerraSarRadarBrightnessComplexImageFilterNew); - REGISTER_TEST(otbTerraSarRadarBrightnessComplexImageFilterTest); - REGISTER_TEST(otbTerraSarCalibrationCplxImageFilterNew); - REGISTER_TEST(otbTerraSarCalibrationCplxImageFilterTest); } diff --git a/Testing/Code/Radiometry/otbTerraSarCalibrationCplxImageFilterNew.cxx b/Testing/Code/Radiometry/otbTerraSarCalibrationCplxImageFilterNew.cxx deleted file mode 100644 index f694098c0f5c2037740c52becfa39f7b3461ed48..0000000000000000000000000000000000000000 --- a/Testing/Code/Radiometry/otbTerraSarCalibrationCplxImageFilterNew.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/*========================================================================= - - 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 "otbImage.h" -#include "otbUnaryFunctorWithIndexImageFilter.h" -#include "otbRadarFunctors.h" - -int otbTerraSarCalibrationCplxImageFilterNew(int argc, char * argv[]) -{ - typedef std::complex<double> CplxType; - typedef otb::Image<CplxType, 2> CplxImageType; - typedef otb::Functor::TerraSarCalibrationComplexImageFunctor< CplxType, CplxType > FunctorType; - typedef otb::UnaryFunctorWithIndexImageFilter< CplxImageType,CplxImageType, FunctorType> CplxFilterType; - - CplxFilterType::Pointer filterCplx = CplxFilterType::New(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Radiometry/otbTerraSarCalibrationCplxImageFilterTest.cxx b/Testing/Code/Radiometry/otbTerraSarCalibrationCplxImageFilterTest.cxx deleted file mode 100644 index 6a5445580ebceb741087618d644c4800e7efbef2..0000000000000000000000000000000000000000 --- a/Testing/Code/Radiometry/otbTerraSarCalibrationCplxImageFilterTest.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/*========================================================================= - - 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 "otbRadarFunctors.h" -#include "otbUnaryFunctorWithIndexImageFilter.h" -#include "otbImage.h" -#include "otbImageFileReader.h" -#include "otbImageFileWriter.h" - -int otbTerraSarCalibrationCplxImageFilterTest(int argc, char * argv[]) -{ - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - - typedef std::complex<double> CplxType; - typedef otb::Image<CplxType, 2> ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; - typedef otb::ImageFileWriter<ImageType> WriterType; - typedef otb::Functor::TerraSarCalibrationComplexImageFunctor< CplxType, CplxType > FunctorType; - typedef otb::UnaryFunctorWithIndexImageFilter< ImageType,ImageType, FunctorType> FilterType; - typedef FunctorType::DoubleVectorType DoubleVectorType; - typedef FunctorType::DoubleVectorVectorType DoubleVectorVectorType; - - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - FilterType::Pointer filter = FilterType::New(); - - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - - reader->UpdateOutputInformation(); - - DoubleVectorType coefs; - coefs.push_back(1.); - coefs.push_back(0.5); - coefs.push_back(1.); - coefs.push_back(0.1); - DoubleVectorVectorType coefVect(1, coefs); - - coefs.clear(); - coefs.push_back(10.); - coefs.push_back(5); - coefs.push_back(10); - coefs.push_back(1); - coefVect.push_back( coefs ); - - coefs.clear(); - coefs.push_back(100); - coefs.push_back(50); - coefs.push_back(100); - coefs.push_back(10); - coefVect.push_back( coefs ); - - filter->GetFunctor().SetNoisePolynomialCoefficientsList(coefVect); - - filter->GetFunctor().SetCalFactor( 10 ); - filter->GetFunctor().SetNoiseRangeValidityMin( 0 ); - filter->GetFunctor().SetNoiseRangeValidityMax( 1 ); - filter->GetFunctor().SetNoiseRangeValidityRef( 0.5 ); - filter->GetFunctor().SetLocalIncidentAngle( 15 ); - filter->GetFunctor().SetLocalIncidentAngle( 15 ); - - std::vector<long int> timeUtc; - timeUtc.push_back(1); - timeUtc.push_back(2); - timeUtc.push_back(3); - filter->GetFunctor().SetTimeUTC(timeUtc); - filter->GetFunctor().SetPRF(50); - filter->GetFunctor().SetUseFastCalibrationMethod( false ); - - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); - - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Radiometry/otbTerraSarRadarBrightnessComplexImageFilterNew.cxx b/Testing/Code/Radiometry/otbTerraSarRadarBrightnessComplexImageFilterNew.cxx deleted file mode 100644 index a8f45331715c6006308f533ca921b8300be4c21f..0000000000000000000000000000000000000000 --- a/Testing/Code/Radiometry/otbTerraSarRadarBrightnessComplexImageFilterNew.cxx +++ /dev/null @@ -1,36 +0,0 @@ -/*========================================================================= - - 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 "otbRadarFunctors.h" -#include "itkUnaryFunctorImageFilter.h" -#include "otbImage.h" - -int otbTerraSarRadarBrightnessComplexImageFilterNew(int argc, char * argv[]) -{ - typedef std::complex<double> ComplexPixelType; - typedef otb::Image< ComplexPixelType > ComplexImageType; - - typedef otb::Functor::TerraSarRadarBrightnessComplexImageFunctor< ComplexPixelType, ComplexPixelType > FunctorType; - - typedef itk::UnaryFunctorImageFilter<ComplexImageType, ComplexImageType, FunctorType > FilterType; - - FilterType::Pointer filter = FilterType::New(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Radiometry/otbTerraSarRadarBrightnessComplexImageFilterTest.cxx b/Testing/Code/Radiometry/otbTerraSarRadarBrightnessComplexImageFilterTest.cxx deleted file mode 100644 index 1b0815ddd854e836da781f3c14107c4d301ade2a..0000000000000000000000000000000000000000 --- a/Testing/Code/Radiometry/otbTerraSarRadarBrightnessComplexImageFilterTest.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/*========================================================================= - - 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 "otbRadarFunctors.h" -#include "itkUnaryFunctorImageFilter.h" -#include "otbImage.h" -#include "otbImageFileReader.h" -#include "otbImageFileWriter.h" - -int otbTerraSarRadarBrightnessComplexImageFilterTest(int argc, char * argv[]) -{ - - const char * inputFileName = argv[1]; - const char * outputFileName = argv[2]; - - typedef std::complex<double> ComplexPixelType; - typedef otb::Image< ComplexPixelType > ComplexImageType; - - typedef otb::Functor::TerraSarRadarBrightnessComplexImageFunctor< ComplexPixelType, ComplexPixelType > FunctorType; - typedef itk::UnaryFunctorImageFilter<ComplexImageType, ComplexImageType, FunctorType > FilterType; - - typedef otb::ImageFileReader<ComplexImageType> ReaderType; - typedef otb::ImageFileWriter<ComplexImageType> WriterType; - - - ReaderType::Pointer reader = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - FilterType::Pointer filter = FilterType::New(); - - - reader->SetFileName(inputFileName); - writer->SetFileName(outputFileName); - reader->UpdateOutputInformation(); - - - filter->GetFunctor().SetCalFactor( 10 ); - - - filter->SetInput(reader->GetOutput()); - writer->SetInput(filter->GetOutput()); -// writer->SetNumberOfStreamDivisions(1); - writer->Update(); - - - return EXIT_SUCCESS; -}