diff --git a/Code/IO/otbOGRIOHelper.txx b/Code/IO/otbOGRIOHelper.txx index 894e4f4a2e9405ee98191e7ef4d45fa4f55fbd45..0df90d4a05ceab1a690af25a33a6db0750f94c4c 100644 --- a/Code/IO/otbOGRIOHelper.txx +++ b/Code/IO/otbOGRIOHelper.txx @@ -613,7 +613,7 @@ unsigned int OGRIOHelper<TVectorData> for (typename ChildrenListType::iterator it = children.begin(); it != children.end(); ++it) { DataNodePointerType dataNode = (*it)->Get(); - otbMsgDevMacro(<< "Type of node " << dataNode->GetNodeType() << " id" << dataNode->GetNodeId()); + //otbMsgDevMacro(<< "Type of node " << dataNode->GetNodeType() << " id " << dataNode->GetNodeId()); ++m_Kept; // Get the kwl @@ -621,6 +621,7 @@ unsigned int OGRIOHelper<TVectorData> itk::ExposeMetaData<VectorDataKeywordlist>(dataNode->GetMetaDataDictionary(), MetaDataKey::VectorDataKeywordlistKey, kwl); + // Create the field once if (ogrCurrentLayer != NULL && ogrCurrentLayer->GetFeatureCount() == 0) { @@ -628,11 +629,15 @@ unsigned int OGRIOHelper<TVectorData> // vectordatakeywordlist for (unsigned int fieldIdx = 0; fieldIdx < kwl.GetNumberOfFields(); fieldIdx++) { - if (ogrCurrentLayer->CreateField(kwl.GetNthField(fieldIdx).first) != OGRERR_NONE ) - { - itkExceptionMacro(<< "Failed to create Field "<<kwl.GetNthField(fieldIdx).first->GetNameRef()); - } - } + if ( std::string(kwl.GetNthField(fieldIdx).first->GetNameRef()) != "FID" ) + { + otbMsgDevMacro(<< " CreateField " << kwl.GetNthField(fieldIdx).first); + if (ogrCurrentLayer->CreateField(kwl.GetNthField(fieldIdx).first) != OGRERR_NONE ) + { + itkExceptionMacro(<< "Failed to create Field "<<kwl.GetNthField(fieldIdx).first->GetNameRef()); + } + } + } } switch (dataNode->GetNodeType()) @@ -680,11 +685,16 @@ unsigned int OGRIOHelper<TVectorData> { // Get the key of the Nth OGRFieldRefn const char * key = kwl.GetNthField(i).first->GetNameRef(); + + if (std::string(key) != "FID") + { // Edit the value of the field and add it to the current feature ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str()); + otbMsgDevMacro( << "kwl.GetFieldAsString(key) " << ogrFeature->GetFieldIndex(key) << " " << kwl.GetFieldAsString(key) ) + } } - ogrFeature->SetField("Name", dataNode->GetNodeId()); +// ogrFeature->SetField("Name", dataNode->GetNodeId()); ogrFeature->SetGeometry(&ogrPoint); if (ogrCurrentLayer->CreateFeature(ogrFeature) != OGRERR_NONE) @@ -738,7 +748,7 @@ unsigned int OGRIOHelper<TVectorData> ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str()); } - ogrFeature->SetField("Name", dataNode->GetNodeId()); +// ogrFeature->SetField("Name", dataNode->GetNodeId()); ogrFeature->SetGeometry(&ogrLine); if (ogrCurrentLayer->CreateFeature(ogrFeature) != OGRERR_NONE) @@ -851,7 +861,7 @@ unsigned int OGRIOHelper<TVectorData> OGRFeature * ogrFeature; ogrFeature = OGRFeature::CreateFeature(ogrCurrentLayer->GetLayerDefn()); - ogrFeature->SetField("Name", dataNode->GetNodeId()); +// ogrFeature->SetField("Name", dataNode->GetNodeId()); ogrFeature->GetDefnRef()->SetGeomType(wkbMultiPoint); ogrFeature->SetGeometry(ogrMultiPoint); @@ -877,7 +887,7 @@ unsigned int OGRIOHelper<TVectorData> OGRFeature *ogrFeature; ogrFeature = OGRFeature::CreateFeature(ogrCurrentLayer->GetLayerDefn()); - ogrFeature->SetField("Name", dataNode->GetNodeId()); +// ogrFeature->SetField("Name", dataNode->GetNodeId()); ogrFeature->GetDefnRef()->SetGeomType(wkbMultiLineString); ogrFeature->SetGeometry(ogrMultiLineString); @@ -900,7 +910,7 @@ unsigned int OGRIOHelper<TVectorData> OGRFeature * ogrFeature; ogrFeature = OGRFeature::CreateFeature(ogrCurrentLayer->GetLayerDefn()); - ogrFeature->SetField("Name", dataNode->GetNodeId()); +// ogrFeature->SetField("Name", dataNode->GetNodeId()); ogrFeature->GetDefnRef()->SetGeomType(wkbMultiPolygon); ogrFeature->SetGeometry(ogrMultiPolygon); @@ -924,7 +934,7 @@ unsigned int OGRIOHelper<TVectorData> OGRFeature *ogrFeature; ogrFeature = OGRFeature::CreateFeature(ogrCurrentLayer->GetLayerDefn()); - ogrFeature->SetField("Name", dataNode->GetNodeId()); +// ogrFeature->SetField("Name", dataNode->GetNodeId()); ogrFeature->GetDefnRef()->SetGeomType(wkbGeometryCollection); ogrFeature->SetGeometry(ogrCollectionGeometry); diff --git a/Code/IO/otbOGRVectorDataIO.txx b/Code/IO/otbOGRVectorDataIO.txx index 53ad3faddcd383ffec1f5d6c06c47641d3eee1dc..5a9e50d8971fa1aa8871cebe01be76fd864b234b 100644 --- a/Code/IO/otbOGRVectorDataIO.txx +++ b/Code/IO/otbOGRVectorDataIO.txx @@ -282,8 +282,8 @@ void OGRVectorDataIO<TData>::Write(const VectorDataConstPointerType data, char * } chrono.Stop(); - std::cout << "OGRVectorDataIO: file saved in " << chrono.GetMeanTime() << " seconds. (" << layerKept << - " elements)" << std::endl; + otbMsgDevMacro( << "OGRVectorDataIO: file saved in " << chrono.GetMeanTime() << " seconds. (" << layerKept << + " elements)" ); otbMsgDevMacro(<< " OGRVectorDataIO::Write() "); } diff --git a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h index 4d3c17fc968365f4a2c51c7be8ba0a55838dbb29..2027d111d9a22ff1e150ee61c5fd0eeaf89a413a 100644 --- a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h +++ b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h @@ -122,6 +122,13 @@ private: LabeledSampleLocalizationGenerator(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented + std::string GetNextID() + { + std::ostringstream oss; + oss << m_CurrentID++; + return oss.str(); + } + RandomGeneratorType::Pointer m_RandomGenerator; std::string m_ClassKey; @@ -130,6 +137,7 @@ private: double m_InhibitionRadius; unsigned long int m_NbMaxIteration; unsigned int m_NumberOfPositiveSamplesPerPoint; + unsigned int m_CurrentID; }; } // end namespace otb diff --git a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx index 34c30ed40642df81686b3f79ae3f25774a153748..29b6cbc6f2f5fd94834cc2262c58855b95333cda 100644 --- a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx +++ b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx @@ -32,7 +32,8 @@ LabeledSampleLocalizationGenerator<TVectorData> m_RandomLocalizationDensity(.005), m_InhibitionRadius(5.0), m_NbMaxIteration(10000), - m_NumberOfPositiveSamplesPerPoint(50) + m_NumberOfPositiveSamplesPerPoint(50), + m_CurrentID(0) { this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); @@ -210,7 +211,19 @@ LabeledSampleLocalizationGenerator<TVectorData> { if (itVector.Get()->IsPointFeature()) { - this->GetOutput(0)->GetDataTree()->Add(itVector.Get(), document); + // Duplicate input feature + typename DataNodeType::Pointer currentGeometry = DataNodeType::New(); + currentGeometry->SetNodeId(this->GetNextID()); + currentGeometry->SetNodeType(otb::FEATURE_POINT); + currentGeometry->SetPoint(itVector.Get()->GetPoint()); + + std::vector<std::string> fields = itVector.Get()->GetFieldList(); + for (std::vector<std::string>::const_iterator it = fields.begin(); it != fields.end(); ++it) + { + currentGeometry->SetFieldAsString( *it, itVector.Get()->GetFieldAsString(*it) ); + } + + this->GetOutput(0)->GetDataTree()->Add(currentGeometry, document); } ++itVector; } @@ -234,21 +247,21 @@ LabeledSampleLocalizationGenerator<TVectorData> for (typename PointVectorType::const_iterator it = vPoint.begin(); it != vPoint.end(); ++it) { - typename DataNodeType::Pointer CurrentGeometry = DataNodeType::New(); - CurrentGeometry->SetNodeId("FEATURE_POINT"); - CurrentGeometry->SetNodeType(otb::FEATURE_POINT); - CurrentGeometry->SetPoint(*it); - CurrentGeometry->SetFieldAsInt(this->GetClassKey(), this->GetNoClassIdentifier()); - this->GetOutput(0)->GetDataTree()->Add(CurrentGeometry, document); + typename DataNodeType::Pointer currentGeometry = DataNodeType::New(); + currentGeometry->SetNodeId(this->GetNextID()); + currentGeometry->SetNodeType(otb::FEATURE_POINT); + currentGeometry->SetPoint(*it); + currentGeometry->SetFieldAsInt(this->GetClassKey(), this->GetNoClassIdentifier()); + this->GetOutput(0)->GetDataTree()->Add(currentGeometry, document); } for (typename PointVectorType::const_iterator it = pPoint.begin(); it != pPoint.end(); ++it) { - typename DataNodeType::Pointer CurrentGeometry = DataNodeType::New(); - CurrentGeometry->SetNodeId("FEATURE_POINT"); - CurrentGeometry->SetNodeType(otb::FEATURE_POINT); - CurrentGeometry->SetPoint(*it); - CurrentGeometry->SetFieldAsInt(this->GetClassKey(), 1); - this->GetOutput(0)->GetDataTree()->Add(CurrentGeometry, document); + typename DataNodeType::Pointer currentGeometry = DataNodeType::New(); + currentGeometry->SetNodeId(this->GetNextID()); + currentGeometry->SetNodeType(otb::FEATURE_POINT); + currentGeometry->SetPoint(*it); + currentGeometry->SetFieldAsInt(this->GetClassKey(), 1); + this->GetOutput(0)->GetDataTree()->Add(currentGeometry, document); } } ++itVector; diff --git a/Code/Projections/otbRationalTransform.h b/Code/Projections/otbRationalTransform.h new file mode 100644 index 0000000000000000000000000000000000000000..ad587978b25c36b9df865c95c9ccd937c89fa7d1 --- /dev/null +++ b/Code/Projections/otbRationalTransform.h @@ -0,0 +1,180 @@ +/*========================================================================= + + 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 __otbRationalTransform_h +#define __otbRationalTransform_h + +#include "itkTransform.h" +#include "itkExceptionObject.h" +#include "itkMacro.h" + +namespace otb +{ +/** \class RationalTransform + * \brief This class implements a rational transfom + * + * A rational transform is a quotient of two polynomial functions. + * + * The degree of the numerator and denominator polynomial functions + * can be set using the appropriate setters. + * + * The number of parameters is then the number of dimensions times + * the numerator degree plus one times the denominator degree plus + * one. + * + * Parameters in the parameters vector are in the following order: + * dim0num0 dim0num1 ... dim0numN dim0denom0 dim0denom1 + * ... dim0denomM ... dim1num0 ... dimDdenomM. + * + * \ingroup Transform + **/ + +template <class TScalarType = double, + unsigned int Dimension = 2> +class ITK_EXPORT RationalTransform : public itk::Transform<TScalarType, Dimension, Dimension> +{ +public: + /** Standard class typedefs. */ + typedef itk::Transform<TScalarType, Dimension, + Dimension> Superclass; + typedef RationalTransform Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename Superclass::ScalarType ScalarType; + typedef itk::Point<ScalarType, Dimension> InputPointType; + typedef itk::Point<ScalarType, Dimension> OutputPointType; + + typedef typename Superclass::InverseTransformBasePointer InverseTransformBasePointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(RationalTransform, itk::Transform); + + itkStaticConstMacro(SpaceDimension, unsigned int, Dimension); + + /** Set the numerator degree */ + itkSetMacro(NumeratorDegree, unsigned int); + + /** Get the numerator degree */ + itkGetMacro(NumeratorDegree, unsigned int); + + /** Set the numerator degree */ + itkSetMacro(DenominatorDegree, unsigned int); + + /** Get the denominator degree */ + itkGetMacro(DenominatorDegree, unsigned int); + + + /** The transform point method */ + virtual OutputPointType TransformPoint(const InputPointType& point) const + { + // Check for consistency + if(this->GetNumberOfParameters() != this->m_Parameters.size()) + { + { + itkExceptionMacro(<<"Wrong number of parameters: found "<<this->m_Parameters.Size()<<", expected "<<this->GetNumberOfParameters()); + } + } + + // Build output + OutputPointType outputPoint; + + unsigned int dimensionStride = (m_DenominatorDegree+1)+(m_NumeratorDegree+1); + + // Compute RPC transform + for(unsigned int dim = 0; dim < SpaceDimension; ++dim) + { + // Initialize numerator and denominator + TScalarType num = itk::NumericTraits<TScalarType>::Zero; + TScalarType denom = itk::NumericTraits<TScalarType>::Zero; + TScalarType currentPower = 1.; + + // Compute numerator + for(unsigned int numDegree = 0; numDegree <= m_NumeratorDegree; ++numDegree) + { + num+=this->m_Parameters[dim*dimensionStride+numDegree]*currentPower; + currentPower*=point[dim]; + } + + // Compute denominator + currentPower = 1.; + for(unsigned int denomDegree = 0; denomDegree <= m_DenominatorDegree; ++denomDegree) + { + denom+=this->m_Parameters[dim*dimensionStride+m_NumeratorDegree+denomDegree+1]*currentPower; + currentPower*=point[dim]; + } + + // Finally, fill the output + outputPoint[dim]=num/denom; + } + + // Return the output point + return outputPoint; + } + + // Get the number of parameters + virtual unsigned int GetNumberOfParameters() const + { + return (m_NumeratorDegree +1 + m_DenominatorDegree+1)*SpaceDimension; + } + + // Set parameter method + virtual void SetParameters(const typename Superclass::ParametersType & params) + { + // Check for the appropriate size + if(params.Size() != this->GetNumberOfParameters()) + { + itkExceptionMacro(<<"Wrong number of parameters: found "<<params.Size()<<", expected "<<this->GetNumberOfParameters()); + } + + // Set parameters + this->m_Parameters = params; + } + +protected: + RationalTransform() : Superclass(SpaceDimension, 16), m_NumeratorDegree(3), m_DenominatorDegree(3) + { + this->m_Parameters.SetSize(this->GetNumberOfParameters()); + this->m_Parameters.Fill(0); + this->m_Parameters[1] = 1.; + this->m_Parameters[4] = 1.; + } + + virtual ~RationalTransform() {} + + void PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os, indent); + } + +private: + RationalTransform(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + // Degree of numerator + unsigned int m_NumeratorDegree; + + // Degree of denominator + unsigned int m_DenominatorDegree; +}; + +} // namespace otb + +#endif diff --git a/Code/SARPolarimetry/otbHermitianEigenAnalysis.h b/Code/SARPolarimetry/otbHermitianEigenAnalysis.h index fdc417d5bbe0f55f962eafa59f96e95393486f2b..16001824ae9bba73af0305911c6044885f74d341 100644 --- a/Code/SARPolarimetry/otbHermitianEigenAnalysis.h +++ b/Code/SARPolarimetry/otbHermitianEigenAnalysis.h @@ -1,13 +1,14 @@ /*========================================================================= - Program: Insight Segmentation & Registration Toolkit - Module: $RCSfile: otbHermitianEigenAnalysis.h, v $ + Program: ORFEO Toolbox Language: C++ - Date: $Date: 2005/07/09 22:43:35 $ - Version: $Revision: 1.5 $ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. - Copyright (c) Insight Software Consortium. All rights reserved. - See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR @@ -56,6 +57,8 @@ namespace otb * num. math. 11, 293-306(1968) by bowdler, martin, reinsch, and * wilkinson. * handbook for auto. comp., vol.ii-linear algebra, 227-240(1971). + * + * \ingroup SARPolarimetry */ template < typename TMatrix, typename TVector, typename TEigenMatrix=TMatrix > @@ -85,7 +88,7 @@ public: m_OrderEigenValues(OrderByValue) {}; - ~HermitianEigenAnalysis() {}; + virtual ~HermitianEigenAnalysis() {}; typedef TMatrix MatrixType; typedef TEigenMatrix EigenMatrixType; diff --git a/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilter.h b/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilter.h index 61ca413afb4b8c682e70a6d353b20665cc01938e..937b08dc15adf38fdd40e000abd3a89e4e895be4 100644 --- a/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilter.h +++ b/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilter.h @@ -45,6 +45,12 @@ namespace Functor { * \f$ S_{ll} = S_{ll}^{*} = 1/2 * ( -S_{xx} - j*2*S_{xy} + S_{yy}) \f$ * \f$ S_{lr} = S_{rl} = 1/2 * ( -S_{xx} - S_{yy}) \f$ * + * \infgroup Functor + * \ingroup SARPolarimetry + * + * \sa MLCToCoherencyDegreeImageFilter + * \sa MLCToCoherencyImageFilter + * */ template< class TInput, class TOutput> class MLCToCircularCoherencyDegreeFunctor @@ -60,24 +66,24 @@ public: result.SetSize(m_NumberOfComponentsPerPixel); result.Fill(0.0); - RealType C1 = static_cast<RealType>(Covariance[0].real()); // C1 <hh.hh*> - RealType C2 = static_cast<RealType>(Covariance[3].real()); // C2 <hv.hv*> - RealType C3 = static_cast<RealType>(Covariance[5].real()); // C3 <vv.vv*> - RealType C4 = static_cast<RealType>(Covariance[1].real()); // C4 Re<hh.hv*> - RealType C5 = static_cast<RealType>(Covariance[1].imag()); // C5 Im<hh.hv*> - RealType C6 = static_cast<RealType>(Covariance[2].real()); // C6 Re<hh.vv*> - RealType C7 = static_cast<RealType>(Covariance[2].imag()); // C7 Im<hh.vv*> - RealType C8 = static_cast<RealType>(Covariance[4].real()); // C8 Re<hv.vv*> - RealType C9 = static_cast<RealType>(Covariance[4].imag()); // C9 Im<hv.vv*> + const RealType C1 = static_cast<RealType>(Covariance[0].real()); // C1 <hh.hh*> + const RealType C2 = static_cast<RealType>(Covariance[3].real()); // C2 <hv.hv*> + const RealType C3 = static_cast<RealType>(Covariance[5].real()); // C3 <vv.vv*> + const RealType C4 = static_cast<RealType>(Covariance[1].real()); // C4 Re<hh.hv*> + const RealType C5 = static_cast<RealType>(Covariance[1].imag()); // C5 Im<hh.hv*> + const RealType C6 = static_cast<RealType>(Covariance[2].real()); // C6 Re<hh.vv*> + const RealType C7 = static_cast<RealType>(Covariance[2].imag()); // C7 Im<hh.vv*> + const RealType C8 = static_cast<RealType>(Covariance[4].real()); // C8 Re<hv.vv*> + const RealType C9 = static_cast<RealType>(Covariance[4].imag()); // C9 Im<hv.vv*> - RealType llrrReal = 0.25 * ( C1 + C3 -4*C2 -2*C6); - RealType llrrImag = -(C4 + C8); + const RealType llrrReal = 0.25 * ( C1 + C3 -4*C2 -2*C6); + const RealType llrrImag = -(C4 + C8); - RealType lllrReal = 0.25 * ( C1 - C3 - 2*C5 + 2*C9); - RealType lllrImag = -0.5*(C7+C4+C8); + const RealType lllrReal = 0.25 * ( C1 - C3 - 2*C5 + 2*C9); + const RealType lllrImag = -0.5*(C7+C4+C8); - RealType rrlrReal = 0.25 * ( C1 -C3 + 2*C5 - 2*C9); - RealType rrlrImag = 0.5 * (C4+C8-C7); + const RealType rrlrReal = 0.25 * ( C1 -C3 + 2*C5 - 2*C9); + const RealType rrlrImag = 0.5 * (C4+C8-C7); RealType ll2 = 0.25 * ( C1 + C3 + 4*C2 - 2*C6 - 4*C5 - 4*C9); RealType rr2 = 0.25 * ( C1 + C3 + 4*C2 - 2*C6 + 4*C5 + 4*C9); @@ -114,7 +120,7 @@ public: MLCToCircularCoherencyDegreeFunctor() : m_NumberOfComponentsPerPixel(3) {} /** Destructor */ - ~MLCToCircularCoherencyDegreeFunctor() {} + virtual ~MLCToCircularCoherencyDegreeFunctor() {} private: unsigned int m_NumberOfComponentsPerPixel; diff --git a/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilter.h b/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilter.h index fa19f292e4850f724a9dbb5740af0b0eec91475d..a9edf7d9fb1ad3fcb6dfde60791d67e89bb039e2 100644 --- a/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilter.h +++ b/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilter.h @@ -29,11 +29,16 @@ namespace Functor { /** \class otbMLCToCoherencyDegreeFunctor * \brief Evaluate the Coherency Degree coefficient from from the MLC image * - * * Output value are: + * Output value are: * channel #0 : \f$ abs(S_{hh}*S_{vv}}^{*}) / sqrt(S_{hh}*S_{hh}}^{*}) / sqrt(S_{vv}*S_{vv}}^{*})\f$ * channel #1 : \f$ abs(S_{hv}*S_{vv}}^{*}) / sqrt(S_{hv}*S_{hv}}^{*}) / sqrt(S_{vv}*S_{vv}}^{*}) \f$ * channel #2 : \f$ abs(S_{hh}*S_{hv}}^{*}) / sqrt(S_{hh}*S_{hh}}^{*}) / sqrt(S_{hv}*S_{hv}}^{*}) \f$ * + * \infgroup Functor + * \ingroup SARPolarimetry + * + * \sa MLCToCircularCoherencyDegreeImageFilter + * \sa MLCToCoherencyImageFilter */ template< class TInput, class TOutput> class MLCToCoherencyDegreeFunctor @@ -49,12 +54,12 @@ public: result.SetSize(m_NumberOfComponentsPerPixel); result.Fill(0.0); - RealType C11 = static_cast<RealType>(Covariance[0].real()); - ComplexType C12 = static_cast<ComplexType>(Covariance[1]); - ComplexType C13 = static_cast<ComplexType>(Covariance[2]); - RealType C22 = static_cast<RealType>(Covariance[3].real()); - ComplexType C23 = static_cast<ComplexType>(Covariance[4]); - RealType C33 = static_cast<RealType>(Covariance[5].real()); + const RealType C11 = static_cast<RealType>(Covariance[0].real()); + const ComplexType C12 = static_cast<ComplexType>(Covariance[1]); + const ComplexType C13 = static_cast<ComplexType>(Covariance[2]); + const RealType C22 = static_cast<RealType>(Covariance[3].real()); + const ComplexType C23 = static_cast<ComplexType>(Covariance[4]); + const RealType C33 = static_cast<RealType>(Covariance[5].real()); if ((C11 >0.00001) && (C33 > 0.0001)) { @@ -83,7 +88,7 @@ public: MLCToCoherencyDegreeFunctor() : m_NumberOfComponentsPerPixel(3) {} /** Destructor */ - ~MLCToCoherencyDegreeFunctor() {} + virtual ~MLCToCoherencyDegreeFunctor() {} private: unsigned int m_NumberOfComponentsPerPixel; diff --git a/Code/SARPolarimetry/otbMLCToCoherencyImageFilter.h b/Code/SARPolarimetry/otbMLCToCoherencyImageFilter.h index a8b2511b423fac6c377fcbd9fe36996f371610cd..0dbc3a47281c38444279727b141a5a548a86197a 100644 --- a/Code/SARPolarimetry/otbMLCToCoherencyImageFilter.h +++ b/Code/SARPolarimetry/otbMLCToCoherencyImageFilter.h @@ -29,7 +29,7 @@ namespace Functor { /** \class otbMLCToCoherencyFunctor * \brief Evaluate the Coherency matrix from from the MLC image * - * * Output value are: + * Output value are: * channel #0 : \f$ 0.5 * (S_{hh}+S_{vv}.(S_{hh}+S_{vv})^{*} \f$ * channel #1 : \f$ 0.5 * (S_{hh}+S_{vv}.(S_{hh}-S_{vv})^{*} \f$ * channel #2 : \f$ (S_{hh}+S_{vv}.(S_{hv})^{*} \f$ @@ -37,6 +37,11 @@ namespace Functor { * channel #4 : \f$ (S_{hh}-S_{vv}.(S_{hv})^{*} \f$ * channel #5 : \f$ 2.0*S_{hv}.S_{hv}^{*} \f$ * + * \infgroup Functor + * \ingroup SARPolarimetry + * + * \sa MLCToCircularCoherencyDegreeImageFilter + * \sa MLCToCoherencyDegreeImageFilter */ template< class TInput, class TOutput> class MLCToCoherencyFunctor @@ -50,16 +55,16 @@ public: TOutput result; result.SetSize(m_NumberOfComponentsPerPixel); - ComplexType C11 = static_cast<ComplexType>(Covariance[0]); - ComplexType C12 = static_cast<ComplexType>(Covariance[1]); - ComplexType C13 = static_cast<ComplexType>(Covariance[2]); - ComplexType C22 = static_cast<ComplexType>(Covariance[3]); - ComplexType C23 = static_cast<ComplexType>(Covariance[4]); - ComplexType C33 = static_cast<ComplexType>(Covariance[5]); + const ComplexType C11 = static_cast<ComplexType>(Covariance[0]); + const ComplexType C12 = static_cast<ComplexType>(Covariance[1]); + const ComplexType C13 = static_cast<ComplexType>(Covariance[2]); + const ComplexType C22 = static_cast<ComplexType>(Covariance[3]); + const ComplexType C23 = static_cast<ComplexType>(Covariance[4]); + const ComplexType C33 = static_cast<ComplexType>(Covariance[5]); - ComplexType C21 = vcl_conj(C12); - ComplexType C31 = vcl_conj(C13); - ComplexType C32 = vcl_conj(C23); + const ComplexType C21 = vcl_conj(C12); + const ComplexType C31 = vcl_conj(C13); + const ComplexType C32 = vcl_conj(C23); result[0] = static_cast<OutputValueType>( 0.5*(C11 + C13 + C31 + C33) ); result[1] = static_cast<OutputValueType>( 0.5*(C11 - C13 + C31 - C33) ); @@ -80,7 +85,7 @@ public: MLCToCoherencyFunctor() : m_NumberOfComponentsPerPixel(6) {} /** Destructor */ - ~MLCToCoherencyFunctor() {} + virtual ~MLCToCoherencyFunctor() {} private: unsigned int m_NumberOfComponentsPerPixel; diff --git a/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h b/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h index f64c0663638029cf431d5fd287c78e07ec2fdb17..89ae7bdcb18a0270d6588d9c5cd1bc1d3aa24779 100644 --- a/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h @@ -30,6 +30,11 @@ namespace Functor { * \brief Evaluate the Circular Polarisation image * (3 channels : LL, RR and LR) from the Mueller image * + * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa MuellerToMLCImageFilter + * \sa MuellerToPolarisationDegreeAndPowerImageFilter * */ template< class TInput, class TOutput> @@ -44,10 +49,10 @@ public: TOutput result; result.SetSize(m_NumberOfComponentsPerPixel); - RealType M11 = static_cast<RealType>(Mueller[0]); - RealType M14 = static_cast<RealType>(Mueller[3]); - RealType M41 = static_cast<RealType>(Mueller[12]); - RealType M44 = static_cast<RealType>(Mueller[15]); + const RealType M11 = static_cast<RealType>(Mueller[0]); + const RealType M14 = static_cast<RealType>(Mueller[3]); + const RealType M41 = static_cast<RealType>(Mueller[12]); + const RealType M44 = static_cast<RealType>(Mueller[15]); result[0] = static_cast<OutputValueType>( M11 + M14 + M41 + M44 ); // LL result[1] = static_cast<OutputValueType>( M11 - M14 - M41 + M44 ); // RR @@ -65,7 +70,7 @@ public: MuellerToCircularPolarisationFunctor() : m_NumberOfComponentsPerPixel(3) {} /** Destructor */ - ~MuellerToCircularPolarisationFunctor() {} + virtual ~MuellerToCircularPolarisationFunctor() {} private: unsigned int m_NumberOfComponentsPerPixel; diff --git a/Code/SARPolarimetry/otbMuellerToMLCImageFilter.h b/Code/SARPolarimetry/otbMuellerToMLCImageFilter.h index 90c0563e8f092be158949149fedbe99d8e0ac74c..97a45886f0388f87a9101ff63dbcce25dc2bcfc4 100644 --- a/Code/SARPolarimetry/otbMuellerToMLCImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToMLCImageFilter.h @@ -29,6 +29,12 @@ namespace Functor { /** \class otbMuellerToMLCFunctor * \brief Evaluate the MLC image from the Mueller image * + * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa MuellerToCircularPolarisationImageFilter + * \sa MuellerToPolarisationDegreeAndPowerImageFilter + * */ template< class TInput, class TOutput> class MuellerToMLCFunctor @@ -44,29 +50,29 @@ public: TOutput result; result.SetSize(m_NumberOfComponentsPerPixel); - RealType M11 = static_cast<RealType>(Mueller[0]); - RealType M12 = static_cast<RealType>(Mueller[1]); - RealType M13 = static_cast<RealType>(Mueller[2]); - RealType M14 = static_cast<RealType>(Mueller[3]); - RealType M21 = static_cast<RealType>(Mueller[4]); - RealType M22 = static_cast<RealType>(Mueller[5]); - RealType M23 = static_cast<RealType>(Mueller[6]); - RealType M24 = static_cast<RealType>(Mueller[7]); - RealType M31 = static_cast<RealType>(Mueller[8]); - RealType M32 = static_cast<RealType>(Mueller[9]); - RealType M33 = static_cast<RealType>(Mueller[10]); - RealType M34 = static_cast<RealType>(Mueller[11]); - RealType M41 = static_cast<RealType>(Mueller[12]); - RealType M42 = static_cast<RealType>(Mueller[13]); - RealType M43 = static_cast<RealType>(Mueller[14]); - RealType M44 = static_cast<RealType>(Mueller[15]); - - ComplexType hhhh(M11+M22+2.*M12, 0.0); - ComplexType hvhv(M11-M22, 0.0); - ComplexType vvvv(M11+M22-2.*M12, 0.0); - ComplexType hhhv(M13+M23, -1.*(M14+M24)); - ComplexType hhvv(M33-M44, -2.*M34); - ComplexType hvvv(M13-M23, -1.*(M14-M24)); + const RealType M11 = static_cast<RealType>(Mueller[0]); + const RealType M12 = static_cast<RealType>(Mueller[1]); + const RealType M13 = static_cast<RealType>(Mueller[2]); + const RealType M14 = static_cast<RealType>(Mueller[3]); + const RealType M21 = static_cast<RealType>(Mueller[4]); + const RealType M22 = static_cast<RealType>(Mueller[5]); + const RealType M23 = static_cast<RealType>(Mueller[6]); + const RealType M24 = static_cast<RealType>(Mueller[7]); + const RealType M31 = static_cast<RealType>(Mueller[8]); + const RealType M32 = static_cast<RealType>(Mueller[9]); + const RealType M33 = static_cast<RealType>(Mueller[10]); + const RealType M34 = static_cast<RealType>(Mueller[11]); + const RealType M41 = static_cast<RealType>(Mueller[12]); + const RealType M42 = static_cast<RealType>(Mueller[13]); + const RealType M43 = static_cast<RealType>(Mueller[14]); + const RealType M44 = static_cast<RealType>(Mueller[15]); + + const ComplexType hhhh(M11+M22+2.*M12, 0.0); + const ComplexType hvhv(M11-M22, 0.0); + const ComplexType vvvv(M11+M22-2.*M12, 0.0); + const ComplexType hhhv(M13+M23, -1.*(M14+M24)); + const ComplexType hhvv(M33-M44, -2.*M34); + const ComplexType hvvv(M13-M23, -1.*(M14-M24)); result[0] = static_cast<OutputValueType>( hhhh ); result[1] = static_cast<OutputValueType>( 2.* hhhv ); @@ -87,7 +93,7 @@ public: MuellerToMLCFunctor() : m_NumberOfComponentsPerPixel(6) {} /** Destructor */ - ~MuellerToMLCFunctor() {} + virtual ~MuellerToMLCFunctor() {} private: unsigned int m_NumberOfComponentsPerPixel; diff --git a/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h b/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h index 6182990e217ccaf736614bb2f7162e439ee1ce26..d4d955bb690af4143c5010a25255ecd30b294adf 100644 --- a/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h @@ -34,6 +34,12 @@ namespace Functor { * \brief Evaluate the min and max polarisation degree and min and max power * from the Mueller image * + * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa MuellerToCircularPolarisationImageFilter + * \sa MuellerToMLCImageFilter + * */ template< class TInput, class TOutput> class MuellerToPolarisationDegreeAndPowerFunctor @@ -151,7 +157,7 @@ public: MuellerToPolarisationDegreeAndPowerFunctor() : m_NumberOfComponentsPerPixel(4) {} /** Destructor */ - ~MuellerToPolarisationDegreeAndPowerFunctor() {} + virtual ~MuellerToPolarisationDegreeAndPowerFunctor() {} private: unsigned int m_NumberOfComponentsPerPixel; diff --git a/Code/SARPolarimetry/otbPolarimetricData.h b/Code/SARPolarimetry/otbPolarimetricData.h index 6a230fbc143dd1696c9d3f54b5e05f0383767846..938ba50fb5dacc99b06e2ae26b672e3eb22efdf7 100644 --- a/Code/SARPolarimetry/otbPolarimetricData.h +++ b/Code/SARPolarimetry/otbPolarimetricData.h @@ -41,8 +41,9 @@ typedef enum /** \class PolarimetricData * \brief This class allows to determine the type of architecture we get. * +* HH_HV_VH_VV (0), HH_HV_VV (1), HH_VH_VV (2), HH_HV(3), VH_VV (4), HH_VV (5). * -* \sa +* \ingroup SARPolarimetry */ class ITK_EXPORT PolarimetricData : public itk::DataObject @@ -73,7 +74,7 @@ protected: /** Constructor */ PolarimetricData(); /** Destructor */ - ~PolarimetricData() {} + virtual ~PolarimetricData() {} /**PrintSelf method */ void PrintSelf(std::ostream& os, itk::Indent indent) const; diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h index b6c6255632e579a27d3b21589a8a1bc231428e87..53551f4eefe9689dc13305c32b4f0b7de5653117 100644 --- a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h +++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h @@ -54,6 +54,10 @@ namespace otb * the type of the output image. It is also parameterized by the * operation to be applied, using a Functor style. * + * + * \ingroup SARPolarimetry + * \sa PolarimetricSynthesisFunctor + * */ template <class TInputImageHH, class TInputImageHV, class TInputImageVH, class TInputImageVV, class TOutputImage, diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h b/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h index 8f6cd87b03895f631ad93fc89deabd4a4aea7ce2..0f23625cfba3b59b7c7d5c9b78d8ea1ce04558ae 100644 --- a/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h +++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h @@ -32,6 +32,7 @@ namespace Functor \vec(E_{r})\cdot\left[ S \right] \vec(E_{i}) \f$ * * \ingroup Functor + * \ingroup SARPolarimetry */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> class PolarimetricSynthesisFunctor @@ -69,7 +70,7 @@ public: tmp = vcl_conj(m_Er[0]) * (m_Ei[0] * static_cast<ComplexType>(Shh) + m_Ei[1] * static_cast<ComplexType>(Shv)) + vcl_conj(m_Er[1]) * (m_Ei[0] * static_cast<ComplexType>(Svh) + m_Ei[1] * static_cast<ComplexType>(Svv)); - scalar = (double) (vcl_pow(vcl_abs(tmp), 2)); + scalar = static_cast<double>(vcl_abs(tmp)) * static_cast<double>(vcl_abs(tmp)); return (static_cast<TOutput>(scalar)); } diff --git a/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h b/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h index 38cbede26a18e9a230a0a5ee9fdd7cc75bfb093f..c7412fd8b283cbb02ad3eed023f731ecccfe6914 100644 --- a/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h @@ -29,6 +29,7 @@ namespace Functor { /** \class otbCoherencyToMuellerFunctor * \brief Evaluate the Mueller matrix from the reciprocal coherency matrix image * + * \ingroup SARPolarimetry */ template< class TInput, class TOutput> class ReciprocalCoherencyToMuellerFunctor @@ -76,7 +77,7 @@ public: ReciprocalCoherencyToMuellerFunctor() {} /** Destructor */ - ~ReciprocalCoherencyToMuellerFunctor() {} + virtual ~ReciprocalCoherencyToMuellerFunctor() {} private: itkStaticConstMacro(NumberOfComponentsPerPixel, unsigned int, 10); diff --git a/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h b/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h index 760a203ca91ec4eb5aa8d193b313ed8b599e969a..0cdb0ff672e3a56730c3a14790db7bd0c7e18990 100644 --- a/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h @@ -32,11 +32,13 @@ namespace Functor { /** \class otbHAlphaFunctor * \brief Evaluate the H-Alpha parameters from the reciprocal coherency matrix image * - * * Output value are: + * Output value are: * channel #0 : entropy * channel #1 : \f$ \alpha \f$ parameter * channel #2 : anisotropy * + * \ingroup SARPolarimetry + * */ template< class TInput, class TOutput> class ReciprocalHAlphaFunctor @@ -71,7 +73,7 @@ public: inline TOutput operator()( const TInput & Coherency ) const { TOutput result; - result.SetSize(NumberOfComponentsPerPixel); + result.SetSize(m_NumberOfComponentsPerPixel); CoherencyMatrixType T; EigenvalueType eigenValues; @@ -95,7 +97,7 @@ public: RealType entropy; RealType alpha; RealType anisotropy; - const RealType epsilon = 1.0E-4; + //const RealType epsilon = 1.0E-4; totalEigenValues = static_cast<RealType>( eigenValues[0] + eigenValues[1] + eigenValues[2]); @@ -110,7 +112,7 @@ public: p[k] = static_cast<RealType>(eigenValues[k]) / totalEigenValues; } - if ( (p[0] < epsilon) || (p[1] < epsilon) || (p[2] < epsilon) ) + if ( (p[0] < m_Epsilon) || (p[1] < m_Epsilon) || (p[2] < m_Epsilon) ) { entropy =0.0; } @@ -131,14 +133,14 @@ public: if (p[k] > 1.) p[k] = 1.; } - val0=sqrt(eigenVectors[0][0]*eigenVectors[0][0] + eigenVectors[0][1]*eigenVectors[0][1]); - a0=acos(abs(val0)) * CONST_180_PI; + val0=sqrt(static_cast<double>(eigenVectors[0][0]*eigenVectors[0][0]) + static_cast<double>(eigenVectors[0][1]*eigenVectors[0][1])); + a0=acos(vcl_abs(val0)) * CONST_180_PI; - val1=sqrt(eigenVectors[0][2]*eigenVectors[0][2] + eigenVectors[0][3]*eigenVectors[0][3]); - a1=acos(abs(val1)) * CONST_180_PI; + val1=sqrt(static_cast<double>(eigenVectors[0][2]*eigenVectors[0][2]) + static_cast<double>(eigenVectors[0][3]*eigenVectors[0][3])); + a1=acos(vcl_abs(val1)) * CONST_180_PI; - val2=sqrt(eigenVectors[0][4]*eigenVectors[0][4] + eigenVectors[0][5]*eigenVectors[0][5]); - a2=acos(abs(val2)) * CONST_180_PI; + val2=sqrt(static_cast<double>(eigenVectors[0][4]*eigenVectors[0][4]) + static_cast<double>(eigenVectors[0][5]*eigenVectors[0][5])); + a2=acos(vcl_abs(val2)) * CONST_180_PI; alpha=p[0]*a0 + p[1]*a1 + p[2]*a2; @@ -156,17 +158,18 @@ public: unsigned int GetOutputSize() { - return NumberOfComponentsPerPixel; + return m_NumberOfComponentsPerPixel; } /** Constructor */ - ReciprocalHAlphaFunctor() {} + ReciprocalHAlphaFunctor() : m_Epsilon(1e-4) {} /** Destructor */ - ~ReciprocalHAlphaFunctor() {} + virtual ~ReciprocalHAlphaFunctor() {} private: - itkStaticConstMacro(NumberOfComponentsPerPixel, unsigned int, 3); + itkStaticConstMacro(m_NumberOfComponentsPerPixel, unsigned int, 3); + const double m_Epsilon; }; } diff --git a/Code/SARPolarimetry/otbSinclairImageFilter.h b/Code/SARPolarimetry/otbSinclairImageFilter.h index 707f0184bf4960450e7fd3f7f3f1308cf2cc0227..6e10c46a379b86c210046cb28fd79f802634c24e 100644 --- a/Code/SARPolarimetry/otbSinclairImageFilter.h +++ b/Code/SARPolarimetry/otbSinclairImageFilter.h @@ -33,6 +33,16 @@ namespace otb * the type of the output image. It is also parameterized by the * operation to be applied, using a Functor style. * + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCircularCovarianceMatrixFunctor + * \sa SinclairToCoherencyFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInputImageHH, class TInputImageHV, diff --git a/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h index 194f74e1459595e206b3101cec76f7227074da6a..5640fc6bff9aef6436124bb41f4d6a3118cbdf70 100644 --- a/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h @@ -41,6 +41,15 @@ namespace Functor * channel #9 : \f$ S_{rr}.S_{rr}^{*} \f$ * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCoherencyFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> @@ -57,18 +66,18 @@ public: TOutput result; result.SetSize(m_NumberOfComponentsPerPixel); - ComplexType jShv = static_cast<ComplexType>(Shv) * vcl_complex<RealType>(0.0, 1.0); - ComplexType jSvh = static_cast<ComplexType>(Svh) * vcl_complex<RealType>(0.0, 1.0); - - ComplexType Sll = static_cast<ComplexType>( 0.5 * (-Shh-jShv-jSvh+Svv) ); - ComplexType Slr = static_cast<ComplexType>( 0.5 * (-Shh+jShv-jSvh+Svv) ); - ComplexType Srl = static_cast<ComplexType>( 0.5 * (-Shh-jShv+jSvh-Svv) ); - ComplexType Srr = static_cast<ComplexType>( 0.5 * (-Shh+jShv+jSvh+Svv) ); - - ComplexType conjSll = vcl_conj(Sll); - ComplexType conjSlr = vcl_conj(Slr); - ComplexType conjSrl = vcl_conj(Srl); - ComplexType conjSrr = vcl_conj(Srr); + const ComplexType jShv = static_cast<ComplexType>(Shv) * vcl_complex<RealType>(0.0, 1.0); + const ComplexType jSvh = static_cast<ComplexType>(Svh) * vcl_complex<RealType>(0.0, 1.0); + + const ComplexType Sll = static_cast<ComplexType>( 0.5 * (-Shh-jShv-jSvh+Svv) ); + const ComplexType Slr = static_cast<ComplexType>( 0.5 * (-Shh+jShv-jSvh+Svv) ); + const ComplexType Srl = static_cast<ComplexType>( 0.5 * (-Shh-jShv+jSvh-Svv) ); + const ComplexType Srr = static_cast<ComplexType>( 0.5 * (-Shh+jShv+jSvh+Svv) ); + + const ComplexType conjSll = vcl_conj(Sll); + const ComplexType conjSlr = vcl_conj(Slr); + const ComplexType conjSrl = vcl_conj(Srl); + const ComplexType conjSrr = vcl_conj(Srr); result[0] = static_cast<OutputValueType>( Sll * conjSll ); result[1] = static_cast<OutputValueType>( Sll * conjSlr ); diff --git a/Code/SARPolarimetry/otbSinclairToCoherencyFunctor.h b/Code/SARPolarimetry/otbSinclairToCoherencyFunctor.h index ea35f8717eb17c328b2b9a2cb515a43dde457cfe..cfbd6ca5b45404f1c47e6eba7c392215e638f815 100644 --- a/Code/SARPolarimetry/otbSinclairToCoherencyFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToCoherencyFunctor.h @@ -41,6 +41,15 @@ namespace Functor * channel #9 : \f$ j(S_{hv}-S_{vh}).(j(S_{hv}-S_{vh}))^{*} \f$ * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCircularCovarianceMatrixFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> @@ -58,10 +67,10 @@ public: result.SetSize(NumberOfComponentsPerPixel); - ComplexType HHPlusVV = static_cast<ComplexType>(Shh + Svv); - ComplexType VVMinusVV = static_cast<ComplexType>(Shh - Svv); - ComplexType HVPlusHV = static_cast<ComplexType>( Shv + Svh); - ComplexType jHVMinusHV = static_cast<ComplexType>( Shv - Svh) * vcl_complex<RealType>(0.0, 1.0); + const ComplexType HHPlusVV = static_cast<ComplexType>(Shh + Svv); + const ComplexType VVMinusVV = static_cast<ComplexType>(Shh - Svv); + const ComplexType HVPlusHV = static_cast<ComplexType>( Shv + Svh); + const ComplexType jHVMinusHV = static_cast<ComplexType>( Shv - Svh) * vcl_complex<RealType>(0.0, 1.0); result[0] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(HHPlusVV) ); result[1] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(VVMinusVV) ); diff --git a/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.h b/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.h index ed1229bb6fadfdf3a22e2a0e4e13943196a0fe0a..46034a4ffc1ea87a4b6e8efb120c82c6c7fd4547 100644 --- a/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.h @@ -41,6 +41,15 @@ namespace Functor * channel #9 : \f$ S_{vv}.S_{vv}^{*} \f$ * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCircularCovarianceMatrixFunctor + * \sa SinclairToCoherencyFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> @@ -55,7 +64,7 @@ public: { TOutput result; - result.SetSize(NumberOfComponentsPerPixel); + result.SetSize(m_NumberOfComponentsPerPixel); result[0] = static_cast<OutputValueType>( static_cast<ComplexType>(Shh)*vcl_conj(static_cast<ComplexType>(Shh)) ); result[1] = static_cast<OutputValueType>( static_cast<ComplexType>(Shh)*vcl_conj(static_cast<ComplexType>(Shv)) ); @@ -73,7 +82,7 @@ public: unsigned int GetNumberOfComponentsPerPixel() { - return NumberOfComponentsPerPixel; + return m_NumberOfComponentsPerPixel; } /** Constructor */ @@ -86,7 +95,7 @@ protected: private: - itkStaticConstMacro(NumberOfComponentsPerPixel, unsigned int, 10); + itkStaticConstMacro(m_NumberOfComponentsPerPixel, unsigned int, 10); }; diff --git a/Code/SARPolarimetry/otbSinclairToMuellerFunctor.h b/Code/SARPolarimetry/otbSinclairToMuellerFunctor.h index 9bba7f5ac13607c85abeacfe23ad34f5d8ff16c5..86d6998c7d12b2a7fd40b83c75f791cae1cff240 100644 --- a/Code/SARPolarimetry/otbSinclairToMuellerFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToMuellerFunctor.h @@ -29,7 +29,40 @@ namespace Functor * Elements of the Mueller matrix are extract from Antennas for radar and communications * Harold Mott p 503 * + * Output value are: + * channel #0 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} + T_{xy}.T_{xy}^{*} + T_{yx}.T_{yx}^{*} + T_{yy}.T_{yy}^{*} ) \f$ + * channel #1 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} - T_{xy}.T_{xy}^{*} + T_{yx}.T_{yx}^{*} - T_{yy}.T_{yy}^{*} ) \f$ + * channel #2 : \f$ \mathcal{Re}( T_{xx}.T_{xy}^{*} + T_{yx}.T_{yy}^{*} ) \f$ + * channel #3 : \f$ \mathcal{Im}( T_{xx}.T_{xy}^{*} + T_{yx}.T_{yy}^{*} ) \f$ + * channel #4 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} + T_{xy}.T_{xy}^{*} - T_{yx}.T_{yx}^{*} - T_{yy}.T_{yy}^{*} ) \f$ + * channel #5 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} - T_{xy}.T_{xy}^{*} - T_{yx}.T_{yx}^{*} + T_{yy}.T_{yy}^{*} ) \f$ + * channel #6 : \f$ \mathcal{Re}( T_{xx}.T_{xy}^{*} - T_{yx}.T_{yy}^{*} ) \f$ + * channel #7 : \f$ \mathcal{Im}( T_{xx}.T_{xy}^{*} - T_{yx}.T_{yy}^{*} ) \f$ + * channel #8 : \f$ \mathcal{Re}( T_{xx}.T_{yx}^{*} + T_{xy}.T_{yy}^{*} ) \f$ + * channel #9 : \f$ \mathcal{Im}( T_{xx}.T_{yx}^{*} - T_{xy}.T_{yy}^{*} ) \f$ + * channel #10 : \f$ \mathcal{Re}( T_{xx}.T_{yy}^{*} + T_{xy}.T_{yx}^{*} ) \f$ + * channel #11 : \f$ \mathcal{Im}( T_{xx}.T_{yy}^{*} - T_{xy}.T_{yx}^{*} ) \f$ + * channel #12 : \f$ \mathcal{Re}( T_{xx}.T_{yx}^{*} + T_{xy}.T_{yy}^{*} ) \f$ + * channel #13 : \f$ \mathcal{Im}( T_{xx}.T_{yx}^{*} - T_{xy}.T_{yy}^{*} ) \f$ + * channel #14 : \f$ \mathcal{Re}( T_{xx}.T_{yy}^{*} + T_{xy}.T_{yx}^{*} ) \f$ + * channel #15 : \f$ \mathcal{Im}( T_{xx}.T_{yy}^{*} - T_{xy}.T_{yx}^{*} ) \f$ + * + * With : + * \f$ T_{xx} = -S_{hh} \f$ + * \f$ T_{xy} = -S_{hv} \f$ + * \f$ T_{yx} = -S_{vh} \f$ + * \f$ T_{yy} = -S_{vv} \f$ + * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCircularCovarianceMatrixFunctor + * \sa SinclairToCoherencyFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> @@ -48,15 +81,15 @@ public: result.SetSize(m_NumberOfComponentsPerPixel); - ComplexType Txx = static_cast<ComplexType>(-Shh); - ComplexType Txy = static_cast<ComplexType>(-Shv); - ComplexType Tyx = static_cast<ComplexType>(Svh); - ComplexType Tyy = static_cast<ComplexType>(Svv); + const ComplexType Txx = static_cast<ComplexType>(-Shh); + const ComplexType Txy = static_cast<ComplexType>(-Shv); + const ComplexType Tyx = static_cast<ComplexType>(Svh); + const ComplexType Tyy = static_cast<ComplexType>(Svv); - ComplexType conjTxx = vcl_conj(static_cast<ComplexType>(-Shh)); - ComplexType conjTxy = vcl_conj(static_cast<ComplexType>(-Shv)); - ComplexType conjTyx = vcl_conj(static_cast<ComplexType>(Svh)); - ComplexType conjTyy = vcl_conj(static_cast<ComplexType>(Svv)); + const ComplexType conjTxx = vcl_conj(static_cast<ComplexType>(-Shh)); + const ComplexType conjTxy = vcl_conj(static_cast<ComplexType>(-Shv)); + const ComplexType conjTyx = vcl_conj(static_cast<ComplexType>(Svh)); + const ComplexType conjTyy = vcl_conj(static_cast<ComplexType>(Svv)); result[0] = static_cast<OutputValueType>( 0.5 * (Txx*conjTxx + Txy*conjTxy + Tyx*conjTyx + Tyy*conjTyy).real() ); result[1] = static_cast<OutputValueType>( 0.5 * (Txx*conjTxx - Txy*conjTxy + Tyx*conjTyx - Tyy*conjTyy).real() ); @@ -70,8 +103,10 @@ public: result[9] = static_cast<OutputValueType>( (Txx*conjTyx - Txy*conjTyy).real() ); result[10] = static_cast<OutputValueType>( (Txx*conjTyy + Txy*conjTyx).real() ); result[11] = static_cast<OutputValueType>( (Txx*conjTyy - Txy*conjTyx).imag() ); + result[12] = static_cast<OutputValueType>( (conjTxx*Tyx + conjTxy*Tyy).imag() ); result[13] = static_cast<OutputValueType>( (conjTxx*Tyx - conjTxy*Tyy).imag() ); + result[14] = static_cast<OutputValueType>( (conjTxx*Tyy + conjTxy*Tyx).imag() ); result[15] = static_cast<OutputValueType>( (Txx*conjTyy - Txy*conjTyx).real() ); diff --git a/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h index 6221350539eb6ae88a40fa70df390be7427c9139..8e55716a9685a66287bfd293818e8ccc0e306527 100644 --- a/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h @@ -37,6 +37,15 @@ namespace Functor * channel #5 : \f$ S_{rr}.S_{rr}^{*} \f$ * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCoherencyFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> @@ -53,15 +62,15 @@ public: TOutput result; result.SetSize(m_NumberOfComponentsPerPixel); - ComplexType j2Shv = static_cast<ComplexType>(Shv) * vcl_complex<RealType>(0.0, 2.0); + const ComplexType j2Shv = static_cast<ComplexType>(Shv) * vcl_complex<RealType>(0.0, 2.0); - ComplexType Sll = static_cast<ComplexType>( 0.5 * (-Shh-j2Shv+Svv) ); - ComplexType Slr = static_cast<ComplexType>( 0.5 * (-Shh+Svv) ); - ComplexType Srr = vcl_conj(Sll); + const ComplexType Sll = static_cast<ComplexType>( 0.5 * (-Shh-j2Shv+Svv) ); + const ComplexType Slr = static_cast<ComplexType>( 0.5 * (-Shh+Svv) ); + const ComplexType Srr = vcl_conj(Sll); - ComplexType conjSll = vcl_conj(Sll); - ComplexType conjSlr = vcl_conj(Slr); - ComplexType conjSrr = vcl_conj(Srr); + const ComplexType conjSll = vcl_conj(Sll); + const ComplexType conjSlr = vcl_conj(Slr); + const ComplexType conjSrr = vcl_conj(Srr); result[0] = static_cast<OutputValueType>( Sll * conjSll ); result[1] = static_cast<OutputValueType>( Sll * conjSlr ); diff --git a/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyFunctor.h b/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyFunctor.h index c668031a1536481038d78bd582eed38fa9369fdb..2f66651a436c62f0c322c7b00c277c430b4bbcd5 100644 --- a/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyFunctor.h @@ -37,6 +37,17 @@ namespace Functor * channel #5 : \f$ (2*S_{hv}).(2*S_{hv})^{*} \f$ * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCircularCovarianceMatrixFunctor + * \sa SinclairToCoherencyFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCovarianceFunctor + + * \sa SinclairToReciprocalCovarianceFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> @@ -53,9 +64,9 @@ public: result.SetSize(NumberOfComponentsPerPixel); - ComplexType HHPlusVV = static_cast<ComplexType>(Shh + Svv); - ComplexType VVMinusVV = static_cast<ComplexType>(Shh - Svv); - ComplexType twoHV = static_cast<ComplexType>( 2.0 * Shv); + const ComplexType HHPlusVV = static_cast<ComplexType>(Shh + Svv); + const ComplexType VVMinusVV = static_cast<ComplexType>(Shh - Svv); + const ComplexType twoHV = static_cast<ComplexType>( 2.0 * Shv); result[0] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(HHPlusVV) ); result[1] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(VVMinusVV) ); diff --git a/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.h b/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.h index 5b8d8ebd7aee3d1fc049b0da18ee07aa1f6c2db4..3e9a1e9db6fee058fcc8354d65eaa3fab4cd9884 100644 --- a/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.h @@ -37,6 +37,15 @@ namespace Functor * channel #5 : \f$ S_{vv}.S_{vv}^{*} \f$ * * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa SinclairImageFilter + * \sa SinclairToCircularCovarianceMatrixFunctor + * \sa SinclairToCoherencyFunctor + * \sa SinclairToCovarianceFunctor + * \sa SinclairToMuellerFunctor + * \sa SinclairToReciprocalCircularCovarianceMatrixFunctor + * \sa SinclairToReciprocalCoherencyFunctor */ template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput> diff --git a/Code/Visualization/otbArrowKeyMoveActionHandler.h b/Code/Visualization/otbArrowKeyMoveActionHandler.h index 00b180803a8067a357da9c422b74604d8ab2903c..ef9cdbb321ff754416fd689c954cae0d0e33b089 100644 --- a/Code/Visualization/otbArrowKeyMoveActionHandler.h +++ b/Code/Visualization/otbArrowKeyMoveActionHandler.h @@ -81,150 +81,167 @@ public: sourceWidget = m_View->GetZoomWidget(); handle = true; } + if(handle && event == FL_FOCUS) + { + return true; + } if ((handle) && ((event == FL_KEYBOARD) || (event == FL_SHORTCUT))) { - switch (Fl::event_key()) + // handle compose mode + if(m_Composed && Fl::event_state() != (int)m_ComposeKey) + { + return false; + } + + unsigned int eventKey = Fl::event_key(); + + if(eventKey == m_UpKey) + { + typename ViewType::SizeType size; + size = m_View->GetFullWidget()->GetExtent().GetSize(); + + // Get the current position + typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; + screenPoint[0] = size[0] / 2; + screenPoint[1] = size[1] / 2; + + // Transform to image point + imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); + + // Transform to index + typename ViewType::IndexType index; + index[0] = static_cast<int>(imagePoint[0]); + index[1] = static_cast<int>(imagePoint[1]); + + // Move + index[1] -= size[1]/4; + + // Change scaled extract region center + m_Model->SetExtractRegionCenter(index); + // Update model + m_Model->Update(); + return true; + } + else if(eventKey == m_DownKey) { - case FL_Up: - { - typename ViewType::SizeType size; - size = m_View->GetFullWidget()->GetExtent().GetSize(); - - // Get the current position - typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; - screenPoint[0] = size[0] / 2; - screenPoint[1] = size[1] / 2; - - // Transform to image point - imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); - - // Transform to index - typename ViewType::IndexType index; - index[0] = static_cast<int>(imagePoint[0]); - index[1] = static_cast<int>(imagePoint[1]); - - // Move - index[1] -= size[1]/4; - - // Change scaled extract region center - m_Model->SetExtractRegionCenter(index); - // Update model - m_Model->Update(); - return true; - break; - } - case FL_Down: - { - typename ViewType::SizeType size; - size = m_View->GetFullWidget()->GetExtent().GetSize(); - - // Get the current position - typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; - screenPoint[0] = size[0] / 2; - screenPoint[1] = size[1] / 2; - - // Transform to image point - imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); - - // Transform to index - typename ViewType::IndexType index; - index[0] = static_cast<int>(imagePoint[0]); - index[1] = static_cast<int>(imagePoint[1]); - - // Move - index[1] += size[1]/4; - - // Change scaled extract region center - m_Model->SetExtractRegionCenter(index); - // Update model - m_Model->Update(); - return true; - break; - } - case FL_Left: - { - typename ViewType::SizeType size; - size = m_View->GetFullWidget()->GetExtent().GetSize(); - - // Get the current position - typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; - screenPoint[0] = size[0] / 2; - screenPoint[1] = size[1] / 2; - - // Transform to image point - imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); - - // Transform to index - typename ViewType::IndexType index; - index[0] = static_cast<int>(imagePoint[0]); - index[1] = static_cast<int>(imagePoint[1]); - - // Move - index[0] -= size[0]/4; - - // Change scaled extract region center - m_Model->SetExtractRegionCenter(index); - // Update model - m_Model->Update(); - return true; - break; - } - case FL_Right: - { - typename ViewType::SizeType size; - size = m_View->GetFullWidget()->GetExtent().GetSize(); - - // Get the current position - typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; - screenPoint[0] = size[0] / 2; - screenPoint[1] = size[1] / 2; - - // Transform to image point - imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); - - // Transform to index - typename ViewType::IndexType index; - index[0] = static_cast<int>(imagePoint[0]); - index[1] = static_cast<int>(imagePoint[1]); - - // Move - index[0] += size[0]/4; - - // Change scaled extract region center - m_Model->SetExtractRegionCenter(index); - // Update model - m_Model->Update(); - return true; - break; - } - default: - { - return false; - break; - } + typename ViewType::SizeType size; + size = m_View->GetFullWidget()->GetExtent().GetSize(); + + // Get the current position + typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; + screenPoint[0] = size[0] / 2; + screenPoint[1] = size[1] / 2; + + // Transform to image point + imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); + + // Transform to index + typename ViewType::IndexType index; + index[0] = static_cast<int>(imagePoint[0]); + index[1] = static_cast<int>(imagePoint[1]); + + // Move + index[1] += size[1]/4; + + // Change scaled extract region center + m_Model->SetExtractRegionCenter(index); + // Update model + m_Model->Update(); + return true; + } + else if(eventKey == m_LeftKey) + { + typename ViewType::SizeType size; + size = m_View->GetFullWidget()->GetExtent().GetSize(); + + // Get the current position + typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; + screenPoint[0] = size[0] / 2; + screenPoint[1] = size[1] / 2; + + // Transform to image point + imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); + + // Transform to index + typename ViewType::IndexType index; + index[0] = static_cast<int>(imagePoint[0]); + index[1] = static_cast<int>(imagePoint[1]); + + // Move + index[0] -= size[0]/4; + + // Change scaled extract region center + m_Model->SetExtractRegionCenter(index); + // Update model + m_Model->Update(); + return true; + } + else if(eventKey == m_RightKey) + { + typename ViewType::SizeType size; + size = m_View->GetFullWidget()->GetExtent().GetSize(); + + // Get the current position + typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; + screenPoint[0] = size[0] / 2; + screenPoint[1] = size[1] / 2; + + // Transform to image point + imagePoint = m_View->GetFullWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); + + // Transform to index + typename ViewType::IndexType index; + index[0] = static_cast<int>(imagePoint[0]); + index[1] = static_cast<int>(imagePoint[1]); + + // Move + index[0] += size[0]/4; + + // Change scaled extract region center + m_Model->SetExtractRegionCenter(index); + // Update model + m_Model->Update(); + return true; } } } return false; } - /** Set/Get the pointer to the model */ +/** Set/Get the pointer to the model */ itkSetObjectMacro(Model, ModelType); itkGetObjectMacro(Model, ModelType); - /** Set/Get the pointer to the view */ +/** Set/Get the pointer to the view */ itkSetObjectMacro(View, ViewType); itkGetObjectMacro(View, ViewType); +/** Set key mapping */ + itkSetMacro(UpKey, unsigned int); + itkGetMacro(UpKey, unsigned int); + itkSetMacro(DownKey, unsigned int); + itkGetMacro(DownKey, unsigned int); + itkSetMacro(LeftKey, unsigned int); + itkGetMacro(LeftKey, unsigned int); + itkSetMacro(RightKey, unsigned int); + itkGetMacro(RightKey, unsigned int); + itkSetMacro(Composed, bool); + itkGetMacro(Composed, bool); + itkSetMacro(ComposeKey, unsigned int); + itkGetMacro(ComposeKey, unsigned int); + protected: - /** Constructor */ - ArrowKeyMoveActionHandler() : m_View(), m_Model() +/** Constructor */ + ArrowKeyMoveActionHandler() : m_View(), m_Model(), + m_UpKey(FL_Up), m_DownKey(FL_Down), + m_LeftKey(FL_Left), m_RightKey(FL_Right), + m_Composed(false), m_ComposeKey(FL_SHIFT) {} - /** Destructor */ +/** Destructor */ virtual ~ArrowKeyMoveActionHandler(){} - /** Printself method */ +/** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); @@ -234,12 +251,24 @@ private: ArrowKeyMoveActionHandler(const Self&); // purposely not implemented void operator =(const Self&); // purposely not implemented - // Pointer to the view +// Pointer to the view ViewPointerType m_View; - // Pointer to the model +// Pointer to the model ModelPointerType m_Model; +// Key mapping for up, down, left and right + unsigned int m_UpKey; + unsigned int m_DownKey; + unsigned int m_LeftKey; + unsigned int m_RightKey; + + // Use composed shortcuts + bool m_Composed; + +// Key state (for Ctrl - shortcuts) + unsigned int m_ComposeKey; + }; // end class } // end namespace otb #endif diff --git a/Code/Visualization/otbChangeExtractRegionActionHandler.h b/Code/Visualization/otbChangeExtractRegionActionHandler.h index e3c6b42d8da2c12f73d3af8551eec0558d52937d..4ffca79a548c2262b176c79f7997c55827c6e0c2 100644 --- a/Code/Visualization/otbChangeExtractRegionActionHandler.h +++ b/Code/Visualization/otbChangeExtractRegionActionHandler.h @@ -76,6 +76,9 @@ public: typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint; screenPoint = m_View->GetScrollWidget()->GetMousePosition(); + // Give focus to the widget + m_View->GetScrollWidget()->take_focus(); + // Transform to image point imagePoint = m_View->GetScrollWidget()->GetScreenToImageTransform()->TransformPoint(screenPoint); diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index e3999f4f8b8024e148ad9c4e215fab916888e1e0..764f56b11b30737e777cdec3bffba9deb9c5953f 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -1006,7 +1006,21 @@ ADD_TEST(prTvImageToGenericRSOutputParameters ${PROJECTIONS_TESTS4} ) ENDIF(OTB_DATA_USE_LARGEINPUT) +#----- otb::RationalTransform ------------------------ +ADD_TEST(prTuRationalTransformNew ${PROJECTIONS_TESTS4} +otbRationalTransformNew) +ADD_TEST(prTvRationalTransform ${PROJECTIONS_TESTS4} + --compare-ascii ${NOTOL} + ${BASELINE_FILES}/otbRationalTransformOutput.txt + ${TEMP}/otbRationalTransformOutput.txt +otbRationalTransform +${TEMP}/otbRationalTransformOutput.txt +0 0 +1 1 +10 10 +-10 -10 +) #======================================================================================= @@ -1067,6 +1081,7 @@ otbGenericRSResampleImageFilter.cxx otbElevDatabaseHeightAboveMSLFunction.cxx otbImageToEnvelopeVectorDataFilter.cxx otbImageToGenericRSOutputParameters.cxx +otbRationalTransform.cxx ) OTB_ADD_EXECUTABLE(otbProjectionsTests1 "${Projections_SRCS1}" "OTBProjections;OTBIO;OTBTesting") diff --git a/Testing/Code/Projections/otbProjectionsTests4.cxx b/Testing/Code/Projections/otbProjectionsTests4.cxx index 54d72c19f153b428f000d11687d3b477244dc2e8..de3ea5481bd1c572266fc24df1f7c15242b23531 100644 --- a/Testing/Code/Projections/otbProjectionsTests4.cxx +++ b/Testing/Code/Projections/otbProjectionsTests4.cxx @@ -35,4 +35,6 @@ void RegisterTests() REGISTER_TEST(otbImageToEnvelopeVectorDataFilter); REGISTER_TEST(otbImageToGenericRSOutputParametersNew); REGISTER_TEST(otbImageToGenericRSOutputParameters); + REGISTER_TEST(otbRationalTransformNew); + REGISTER_TEST(otbRationalTransform); } diff --git a/Testing/Code/Projections/otbRationalTransform.cxx b/Testing/Code/Projections/otbRationalTransform.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4b0e1ba826b4552c5e6276995e53039f72b50eb5 --- /dev/null +++ b/Testing/Code/Projections/otbRationalTransform.cxx @@ -0,0 +1,101 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbRationalTransform.h" +#include <fstream> + +int otbRationalTransformNew(int argc, char* argv[]) +{ + typedef otb::RationalTransform<> RationalTransformType; + + // Instantiation + RationalTransformType::Pointer rt = RationalTransformType::New(); + + return EXIT_SUCCESS; +} + +int otbRationalTransform(int argc, char* argv[]) +{ + typedef otb::RationalTransform<> RationalTransformType; + + // Instantiation + RationalTransformType::Pointer rt = RationalTransformType::New(); + rt->SetNumeratorDegree(4); + rt->SetDenominatorDegree(4); + + RationalTransformType::ParametersType params(rt->GetNumberOfParameters()); + params.Fill(1.); + + // Rational is + // fx(x, y) = (1+2*x+3*x^2+4*x^3+5*x^4)/(6+7*x+8*x^2+9*x^3+10*x^4) + // fy(x, y) = (11+12*y+13*y^2+14*y^3+15*y^4)/(16+17*y+18*y^2+19*y^3+20*y^4) + params[0]=1; + params[1]=2; + params[2]=3; + params[3]=4; + params[4]=5; + params[5]=6; + params[6]=7; + params[7]=8; + params[8]=9; + params[9]=10; + params[10]=11; + params[11]=12; + params[12]=13; + params[13]=14; + params[14]=15; + params[15]=16; + params[16]=17; + params[17]=18; + params[18]=19; + params[19]=20; + + rt->SetParameters(params); + + RationalTransformType::InputPointType inputPoint; + RationalTransformType::OutputPointType outputPoint; + + std::ofstream ofs; + ofs.open(argv[1]); + + // Set floatfield to format writing properly + ofs.setf(std::ios::fixed, std::ios::floatfield); + ofs.precision(10); + + unsigned int idx = 2; + + ofs<<"Rational function is: "<<std::endl; + ofs<<"fx(x, y) = (1+2*x+3*x^2+4*x^3+5*x^4)/(6+7*x+8*x^2+9*x^3+10*x^4)"<<std::endl; + ofs<<"fy(x, y) = (11+12*y+13*y^2+14*y^3+15*y^4)/(16+17*y+18*y^2+19*y^3+20*y^4)"<<std::endl; + while(idx+1<(unsigned int)argc) + { + inputPoint[0] = atof(argv[idx]); + inputPoint[1] = atof(argv[idx+1]); + outputPoint = rt->TransformPoint(inputPoint); + ofs<<inputPoint<<" -> "<<outputPoint<<std::endl; + idx+=2; + } + + ofs.close(); + + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/SARPolarimetry/CMakeLists.txt b/Testing/Code/SARPolarimetry/CMakeLists.txt index 80ac1101c4af3d95c36fed866662a3dfeb2a08a6..152de721dacaf9709033c8e880ebbaf840982ed7 100644 --- a/Testing/Code/SARPolarimetry/CMakeLists.txt +++ b/Testing/Code/SARPolarimetry/CMakeLists.txt @@ -266,7 +266,7 @@ ADD_TEST(saTuReciprocalHAlphaImageFilterNew ${SARPOLARIMETRY_TESTS1} ADD_TEST(saTvReciprocalHAlphaImageFilter ${SARPOLARIMETRY_TESTS1} --compare-image ${EPSILON_12} ${BASELINE}/saTvReciprocalHAlphaImageFilter.tif ${TEMP}/saTvReciprocalHAlphaImageFilter.tif - otbHAlphaImageFilter + otbReciprocalHAlphaImageFilter ${INPUTDATA}/RSAT_imagery_HH.tif ${INPUTDATA}/RSAT_imagery_HV.tif ${INPUTDATA}/RSAT_imagery_HV.tif @@ -337,6 +337,10 @@ ADD_TEST(saTvMuellerToMLCImageFilter ${SARPOLARIMETRY_TESTS1} ${INPUTDATA}/RSAT_imagery_VV.tif ${TEMP}/saTvMuellerToMLCImageFilter.tif ) +# Hermitian eigen analysis class +ADD_TEST(saTvHermitianEigenAnalysisTest ${SARPOLARIMETRY_TESTS1} + otbHermitianEigenAnalysisTest +) # A enrichir SET(SARPOLARIMETRY_SRCS1 @@ -350,6 +354,7 @@ otbMultiChannelsPolarimetricSynthesisFilterNew.cxx otbMultiChannelsPolarimetricSynthesisFilter.cxx otbVectorMultiChannelsPolarimetricSynthesisFilter.cxx otbSinclairToCovarianceFunctor.cxx +otbSinclairToReciprocalCovarianceFunctor.cxx otbSinclairImageFilter.cxx otbMLCToCoherencyImageFilterNew.cxx otbMLCToCoherencyImageFilter.cxx @@ -367,6 +372,7 @@ otbMuellerToPolarisationDegreeAndPowerImageFilterNew.cxx otbMuellerToPolarisationDegreeAndPowerImageFilter.cxx otbMuellerToMLCImageFilterNew.cxx otbMuellerToMLCImageFilter.cxx +otbHermitianEigenAnalysisTest.cxx ) OTB_ADD_EXECUTABLE(otbSARPolarimetryTests1 "${SARPOLARIMETRY_SRCS1}" "OTBSARPolarimetry;OTBIO;OTBTesting") diff --git a/Testing/Code/SARPolarimetry/otbHermitianEigenAnalysisTest.cxx b/Testing/Code/SARPolarimetry/otbHermitianEigenAnalysisTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3a111558ca201e4391e6083a31b70928eb9d63c1 --- /dev/null +++ b/Testing/Code/SARPolarimetry/otbHermitianEigenAnalysisTest.cxx @@ -0,0 +1,40 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include <iostream> + +#include "otbImage.h" +#include "otbVectorImage.h" +#include "otbHermitianEigenAnalysis.h" + +int otbHermitianEigenAnalysisTest(int argc, char * argv[]) +{ + typedef vnl_matrix<double> MatrixType; + typedef std::vector<double> VectorType; + + + typedef otb::HermitianEigenAnalysis<MatrixType, VectorType> FilterType; + + FilterType filter; + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilterNew.cxx index c79e3ddd94d5ed353f394f9c2a5cafe05a0f9c5f..78669a68b07b24da7542b685fa6c1b170126a67a 100644 --- a/Testing/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMLCToCircularCoherencyDegreeImageFilterNew.cxx @@ -37,7 +37,5 @@ int otbMLCToCircularCoherencyDegreeImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilterNew.cxx index 496e6b23599b7716da99a2eb1b030750eec1fc9f..70cd40313abda21f349016ea9c29938c5eb053c9 100644 --- a/Testing/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMLCToCoherencyDegreeImageFilterNew.cxx @@ -37,7 +37,5 @@ int otbMLCToCoherencyDegreeImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbMLCToCoherencyImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMLCToCoherencyImageFilterNew.cxx index 96212610514e14f43d320dc27f7348b261e2f8fe..d07c6da4a8f1349d98549a6b623d8ea8d3971cb8 100644 --- a/Testing/Code/SARPolarimetry/otbMLCToCoherencyImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMLCToCoherencyImageFilterNew.cxx @@ -37,7 +37,5 @@ int otbMLCToCoherencyImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilterNew.cxx index fa5c002d25bbd6bc1f36d666c4a0c096501c34d3..1b482a6bdf72f4331007ef17a5b80e902d772778 100644 --- a/Testing/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilterNew.cxx @@ -36,7 +36,5 @@ int otbMuellerToCircularPolarisationImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbMuellerToMLCImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMuellerToMLCImageFilterNew.cxx index da3ca7f311f4d2bb1453cbb83d142d0d5d4f1601..d533f1ed540bae4cca6f6c6ccebc281d6a615047 100644 --- a/Testing/Code/SARPolarimetry/otbMuellerToMLCImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMuellerToMLCImageFilterNew.cxx @@ -38,7 +38,5 @@ int otbMuellerToMLCImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilterNew.cxx index 18d94e90287a5a7b61c9e7c917a3e1cd6a405f66..f084149bd80a9674ae851e228645d1cedf4c17c7 100644 --- a/Testing/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilterNew.cxx @@ -36,7 +36,5 @@ int otbMuellerToPolarisationDegreeAndPowerImageFilterNew(int argc, char * argv[] FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilterNew.cxx index 95e195e45dc54bab87d072a9dbfa6c31837b7932..16ee6ce6077fc8ae897c2b18ecbb17f24467dd27 100644 --- a/Testing/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilterNew.cxx @@ -39,7 +39,5 @@ int otbMultiChannelsPolarimetricSynthesisFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbPolarimetricSynthesisFilterNew.cxx b/Testing/Code/SARPolarimetry/otbPolarimetricSynthesisFilterNew.cxx index 8db9eb8bc049c2dcdabdcbcf01152a7a72c1e0d4..718e186083e9dc248b050fedae5eb0d5e0857936 100644 --- a/Testing/Code/SARPolarimetry/otbPolarimetricSynthesisFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbPolarimetricSynthesisFilterNew.cxx @@ -40,7 +40,5 @@ int otbPolarimetricSynthesisFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilterNew.cxx index 7dbcfcc1a8e98ec9306d1985f1bdbb9352f67d64..47bef8d8d91b9e1a641ecd0ef4ec86b5617c6a80 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilterNew.cxx @@ -36,7 +36,5 @@ int otbReciprocalCoherencyToMuellerImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilterNew.cxx index 4cb17b6f32b6c4234267e4664c6a309b38697dd8..4f1e94be9a82f5e23dbb6a779a3034085cb5c16c 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilterNew.cxx @@ -36,7 +36,5 @@ int otbReciprocalHAlphaImageFilterNew(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); - std::cout << filter << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/SARPolarimetry/otbSARPolarimetryTests1.cxx b/Testing/Code/SARPolarimetry/otbSARPolarimetryTests1.cxx index 7dde2e00eea997d2b9b69a36251266d33a712384..95724e8111ca37c1f5c0a4a3114371186c663c90 100644 --- a/Testing/Code/SARPolarimetry/otbSARPolarimetryTests1.cxx +++ b/Testing/Code/SARPolarimetry/otbSARPolarimetryTests1.cxx @@ -35,6 +35,7 @@ void RegisterTests() REGISTER_TEST(otbMultiChannelsPolarimetricSynthesisFilter); REGISTER_TEST(otbVectorMultiChannelsPolarimetricSynthesisFilter); REGISTER_TEST(otbSinclairToReciprocalCovarianceFunctor); + REGISTER_TEST(otbSinclairToCovarianceFunctor); REGISTER_TEST(otbSinclairImageFilter); REGISTER_TEST(otbMLCToCoherencyImageFilterNew); REGISTER_TEST(otbMLCToCoherencyImageFilter); @@ -52,4 +53,5 @@ void RegisterTests() REGISTER_TEST(otbMuellerToPolarisationDegreeAndPowerImageFilter); REGISTER_TEST(otbMuellerToMLCImageFilterNew); REGISTER_TEST(otbMuellerToMLCImageFilter); + REGISTER_TEST(otbHermitianEigenAnalysisTest); } diff --git a/Testing/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.cxx b/Testing/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.cxx index 830fc9aecc1dcb4012ca7a4523492ccadcff7d51..db4b78440364180e540fb6c78f6f4a787246e6c3 100644 --- a/Testing/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.cxx +++ b/Testing/Code/SARPolarimetry/otbSinclairToCovarianceFunctor.cxx @@ -17,27 +17,31 @@ =========================================================================*/ #include "itkExceptionObject.h" -#include "otbSinclairToReciprocalCovarianceFunctor.h" +#include "otbSinclairToCovarianceFunctor.h" #include "itkVariableLengthVector.h" -int otbSinclairToReciprocalCovarianceFunctor(int argc, char * argv[]) +int otbSinclairToCovarianceFunctor(int argc, char * argv[]) { typedef std::complex<double> ScalarType; typedef itk::VariableLengthVector<ScalarType> OutputType; - typedef otb::Functor::SinclairToReciprocalCovarianceFunctor<ScalarType, ScalarType, + typedef otb::Functor::SinclairToCovarianceFunctor<ScalarType, ScalarType, ScalarType, ScalarType, OutputType > FunctorType; - OutputType result(6); + OutputType result(10); FunctorType funct; OutputType outputFunct; result[0] = 1.0; result[1] = 0.0; - result[2] = 1.0; - result[3] = 0.0; + result[2] = 0.0; + result[3] = 1.0; result[4] = 0.0; - result[5] = 1.0; + result[5] = 0.0; + result[6] = 0.0; + result[7] = 0.0; + result[8] = 0.0; + result[9] = 1.0; outputFunct = funct.operator ()( 1.0, 0.0, 0.0, 1.0); @@ -46,7 +50,11 @@ int otbSinclairToReciprocalCovarianceFunctor(int argc, char * argv[]) vcl_abs(result[2]-outputFunct[2]) > 1e-10 || vcl_abs(result[3]-outputFunct[3]) > 1e-10 || vcl_abs(result[4]-outputFunct[4]) > 1e-10 || - vcl_abs(result[5]-outputFunct[5]) > 1e-10) + vcl_abs(result[5]-outputFunct[5]) > 1e-10 || + vcl_abs(result[6]-outputFunct[6]) > 1e-10 || + vcl_abs(result[7]-outputFunct[7]) > 1e-10 || + vcl_abs(result[8]-outputFunct[8]) > 1e-10 || + vcl_abs(result[9]-outputFunct[9]) > 1e-10) { return EXIT_FAILURE; } diff --git a/Testing/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.cxx b/Testing/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.cxx new file mode 100644 index 0000000000000000000000000000000000000000..830fc9aecc1dcb4012ca7a4523492ccadcff7d51 --- /dev/null +++ b/Testing/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceFunctor.cxx @@ -0,0 +1,55 @@ +/*========================================================================= + + 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 "otbSinclairToReciprocalCovarianceFunctor.h" +#include "itkVariableLengthVector.h" + +int otbSinclairToReciprocalCovarianceFunctor(int argc, char * argv[]) +{ + typedef std::complex<double> ScalarType; + typedef itk::VariableLengthVector<ScalarType> OutputType; + + typedef otb::Functor::SinclairToReciprocalCovarianceFunctor<ScalarType, ScalarType, + ScalarType, ScalarType, OutputType > FunctorType; + + OutputType result(6); + FunctorType funct; + OutputType outputFunct; + + result[0] = 1.0; + result[1] = 0.0; + result[2] = 1.0; + result[3] = 0.0; + result[4] = 0.0; + result[5] = 1.0; + + outputFunct = funct.operator ()( 1.0, 0.0, 0.0, 1.0); + + if( vcl_abs(result[0]-outputFunct[0]) > 1e-10 || + vcl_abs(result[1]-outputFunct[1]) > 1e-10 || + vcl_abs(result[2]-outputFunct[2]) > 1e-10 || + vcl_abs(result[3]-outputFunct[3]) > 1e-10 || + vcl_abs(result[4]-outputFunct[4]) > 1e-10 || + vcl_abs(result[5]-outputFunct[5]) > 1e-10) + { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}