From f9e4168bda7fe9bf68eb71da3655d44b4481f13b Mon Sep 17 00:00:00 2001 From: Guillaume Borrut <guillaume.borrut@c-s.fr> Date: Tue, 19 Aug 2008 16:28:38 +0000 Subject: [PATCH] Ajout de methodes pour prise en compte Mode copolar... Mode Emission... --- ...MultiChannelsPolarimetricSynthesisFilter.h | 33 +++- ...ltiChannelsPolarimetricSynthesisFilter.txx | 162 ++++++++++++------ .../otbPolarimetricSynthesisFilter.h | 12 +- .../otbPolarimetricSynthesisFilter.txx | 60 ++++--- 4 files changed, 186 insertions(+), 81 deletions(-) diff --git a/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h b/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h index 9b8222298c..2570deae0c 100755 --- a/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h +++ b/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h @@ -71,7 +71,7 @@ public: typedef typename OutputImageType::PixelType OutputImagePixelType; typedef typename std::complex <double> ComplexType; typedef typename itk::FixedArray<ComplexType,2> ComplexArrayType; - typedef enum {HH_HV_VH_VV=0,HH_HV_VV=1,HH_VH_VV=2,HH_HV=3,VH_VV=4} ArchitectureType; + typedef enum {HH_HV_VH_VV=0,HH_HV_VV=1,HH_HV=2,VH_VV=3,HH_VV=4} ArchitectureType; //HH_VH_VV=2 /** Get the functor object. The functor is returned by reference. @@ -125,7 +125,20 @@ public: itkGetMacro(TauR,double); /** Set/Get ArchitectureType */ itkGetMacro(ArchitectureType,int); - itkSetMacro(ArchitectureType,int); + itkSetMacro(ArchitectureType,int); + /** Set/Get EmissionH */ + itkSetMacro(EmissionH,bool); + itkGetMacro(EmissionH,bool); + /** Set/Get EmissionV */ + itkSetMacro(EmissionV,bool); + itkGetMacro(EmissionV,bool); + /** Set/Get Mode */ + itkSetMacro(Mode,int); + itkGetMacro(Mode,int); + + void ForceCoPolar(); + + void ForceCrossPolar(); protected: @@ -158,13 +171,20 @@ protected: void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); + /** */ + void DetermineArchitecture(); + /** Computation of the electromagnetic fields Ei Er */ void ComputeElectromagneticFields(); /** Verify and force the inputs, if only 2 or 3 channels are present */ void VerifyAndForceInputs(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + void Print(); + + private : MultiChannelsPolarimetricSynthesisFilter(const Self&); //purposely not implemented @@ -177,6 +197,13 @@ private : double m_PsiR; /** Tau Relechi */ double m_TauR; + + /** None = 0 , copolar = 1 , crosspolar = 2 */ + int m_Mode; + + /** Emission mode */ + bool m_EmissionH; + bool m_EmissionV; /** Champs Electromagnetic Incident */ ComplexArrayType m_Ei; diff --git a/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.txx b/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.txx index fe4de50f90..91507a2748 100755 --- a/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.txx +++ b/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.txx @@ -36,6 +36,8 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> { this->SetNumberOfRequiredInputs( 1 ); this->InPlaceOff(); + SetEmissionH(false); + SetEmissionV(false); m_ArchitectureType=0; } @@ -174,8 +176,6 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> switch (m_ArchitectureType) { case 0 : - if ( inputPtr->GetNumberOfComponentsPerPixel()==4 ) - { while( !inputIt.IsAtEnd() ) { outputIt.Set( m_Functor( inputIt.Get()[0], inputIt.Get()[1], inputIt.Get()[2], inputIt.Get()[3] ) ); @@ -183,14 +183,10 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> ++outputIt; progress.CompletedPixel(); // potential exception thrown here } - } -// else break; // With 3 channels : HH HV VV case 1 : -// if ( inputPtr->GetNumberOfComponentsPerPixel()==3 ) -// { while( !inputIt.IsAtEnd() ) { outputIt.Set( m_Functor( inputIt.Get()[0], inputIt.Get()[1], inputIt.Get()[1], inputIt.Get()[2] ) ); @@ -201,9 +197,7 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> break; // With 3 channels : HH VH VV - case 2 : - if ( inputPtr->GetNumberOfComponentsPerPixel()==3 ) - { +/* case 2 : while( !inputIt.IsAtEnd() ) { outputIt.Set( m_Functor( inputIt.Get()[0], inputIt.Get()[1], inputIt.Get()[1], inputIt.Get()[2] ) ); @@ -211,13 +205,10 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> ++outputIt; progress.CompletedPixel(); // potential exception thrown here } - } break; - +*/ // Only HH and HV are present - case 3 : - if ( inputPtr->GetNumberOfComponentsPerPixel()==2 ) - { + case 2 : while( !inputIt.IsAtEnd() ) { outputIt.Set( m_Functor( inputIt.Get()[0], inputIt.Get()[1], 0, 0 ) ); @@ -225,13 +216,10 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> ++outputIt; progress.CompletedPixel(); // potential exception thrown here } - } break; // Only VH and VV are present - case 4 : - if ( inputPtr->GetNumberOfComponentsPerPixel()==2 ) - { + case 3 : while( !inputIt.IsAtEnd() ) { outputIt.Set( m_Functor( 0, 0, inputIt.Get()[2], inputIt.Get()[3] ) ); @@ -239,13 +227,13 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> ++outputIt; progress.CompletedPixel(); // potential exception thrown here } - } break; default : itkExceptionMacro("Unknown architecture : Polarimetric synthesis is impossible !"); return; - } + } + } /** @@ -281,25 +269,41 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> this->SetEi(AEi); this->SetEr(AEr); - - std::cout<<"PsiI: "<<m_PsiI<<std::endl; - std::cout<<"TauI: "<<m_TauI<<std::endl; - std::cout<<"PsiR: "<<m_PsiR<<std::endl; - std::cout<<"TauR: "<<m_TauR<<std::endl; - - std::cout<<"Ei0 im: "<<m_Ei[0].imag()<<std::endl; - std::cout<<"Ei0 re: "<<m_Ei[0].real()<<std::endl; - std::cout<<"Ei1 im: "<<m_Ei[1].imag()<<std::endl; - std::cout<<"Ei1 re: "<<m_Ei[1].real()<<std::endl; - - std::cout<<"Er0 im: "<<m_Er[0].imag()<<std::endl; - std::cout<<"Er0 re: "<<m_Er[0].real()<<std::endl; - std::cout<<"Er1 im: "<<m_Er[1].imag()<<std::endl; - std::cout<<"Er1 re: "<<m_Er[1].real()<<std::endl; - - std::cout<<"DTOR: "<<DTOR<<std::endl; + } +/** + * Determine the kind of architecture + */ +template <class TInputImage, class TOutputImage, class TFunction > +void +MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> +::DetermineArchitecture() +{ + + int NumberOfImages = this->GetInput()->GetNumberOfComponentsPerPixel(); + + if ( NumberOfImages == 4 ) + SetArchitectureType(0); + +// METTRE ICI DES WARNINGS ou ERREUR si INCOHERENCE + + if ( NumberOfImages == 3 ) + SetArchitectureType(1); + + if ( ( NumberOfImages == 2 ) && + GetEmissionH() && !GetEmissionV() ) + SetArchitectureType(2); + + if ( ( NumberOfImages == 2 ) && + !GetEmissionH() && GetEmissionV() ) + SetArchitectureType(3); + + std::cout<<"Architecture: "<<GetArchitectureType()<<std::endl; + +} + + /** * Verify and force the inputs, if only 2 or 3 channels are present */ @@ -311,8 +315,7 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> InputPixelType pix; pix.imag()=0; pix.real()=0; - - // With 3 channels : HH VH VV + switch (m_ArchitectureType) { case 0 : @@ -325,27 +328,32 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> break; // With 3 channels : HH VH VV - case 2 : +/* case 2 : std::cout<<"Case 3 channels !!"<<std::endl; break; - +*/ // Only HH and HV are present - case 3 : - std::cout<<"Case HH HV present !!"<<std::endl; + case 2 : + std::cout<<"Case HH HV !!"<<std::endl; // Forcing TauI=0 PsiI=0 this->SetTauI(0); - this->SetPsiI(0); + this->SetPsiI(0); + if(GetMode()==1)ForceCoPolar(); + else if(GetMode()==2)ForceCrossPolar(); break; // Only VH and VV are present - case 4 : - std::cout<<"Case VH VV present !!"<<std::endl; + case 3 : + std::cout<<"Case VH VV !!"<<std::endl; // Forcing TauI=0 PsiI=90 this->SetTauI(0); this->SetPsiI(90); - + if(GetMode()==1)ForceCoPolar(); + else if(GetMode()==2)ForceCrossPolar(); + break; + default : itkExceptionMacro("Unknown architecture : Polarimetric synthesis is impossible !"); return; @@ -361,12 +369,44 @@ void MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> ::BeforeThreadedGenerateData() { + + // Determine the kind of architecture of the input picture + DetermineArchitecture(); + // First Part. Verify and force the inputs VerifyAndForceInputs(); // Second Part. Estimation of the incident field Ei and the reflected field Er ComputeElectromagneticFields(); + Print(); + +} + +/** + * Force Copolar mode + */ +template <class TInputImage, class TOutputImage, class TFunction > +void +MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> +::ForceCoPolar() +{ + SetPsiR(m_PsiI); + SetTauR(m_TauI); + std::cout<<"PsiI: "<<m_PsiI<<std::endl; SetMode(1); +} + +/** + * Force Crosspolar mode + */ +template <class TInputImage, class TOutputImage, class TFunction > +void +MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> +::ForceCrossPolar() +{ + SetPsiR(m_PsiI+90); + SetTauR(-m_TauI); + SetMode(2); } /** @@ -378,10 +418,30 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); - os << indent << "Psi I: "<<m_PsiI<<std::endl; - os << indent << "Tau I: "<<m_TauI<<std::endl; - os << indent << "Psi R: "<<m_PsiR<<std::endl; - os << indent << "Tau R: "<<m_TauR<<std::endl; +} + +/** + * Print + */ +template <class TInputImage, class TOutputImage, class TFunction > +void +MultiChannelsPolarimetricSynthesisFilter<TInputImage,TOutputImage,TFunction> +::Print() +{ + std::cout<<"PsiI: "<<m_PsiI<<std::endl; + std::cout<<"TauI: "<<m_TauI<<std::endl; + std::cout<<"PsiR: "<<m_PsiR<<std::endl; + std::cout<<"TauR: "<<m_TauR<<std::endl; + + std::cout<<"Ei0 im: "<<m_Ei[0].imag()<<std::endl; + std::cout<<"Ei0 re: "<<m_Ei[0].real()<<std::endl; + std::cout<<"Ei1 im: "<<m_Ei[1].imag()<<std::endl; + std::cout<<"Ei1 re: "<<m_Ei[1].real()<<std::endl; + + std::cout<<"Er0 im: "<<m_Er[0].imag()<<std::endl; + std::cout<<"Er0 re: "<<m_Er[0].real()<<std::endl; + std::cout<<"Er1 im: "<<m_Er[1].imag()<<std::endl; + std::cout<<"Er1 re: "<<m_Er[1].real()<<std::endl; } } // end namespace otb diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h index 728506bce1..6e55d2b2f7 100755 --- a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h +++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h @@ -85,6 +85,9 @@ public: /** Set/Get TauR */ itkSetMacro(TauR,double); itkGetMacro(TauR,double); + /** Set/Get Mode */ + itkSetMacro(Mode,int); + itkGetMacro(Mode,int); void SetEi(ComplexArrayType ei) { @@ -122,6 +125,8 @@ protected: void PrintSelf(std::ostream& os, itk::Indent indent) const; + void Print(); + private: PolarimetricSynthesisFilter(const Self&); //purposely not implemented @@ -135,10 +140,9 @@ private: double m_PsiR; /** Tau Reflected */ double m_TauR; - - /** Emission mode */ - bool m_EmissionH; - bool m_EmissionV; + + /** None = 0 , copolar = 1 , crosspolar = 2 */ + int m_Mode; /** Champs Electromagnetic Incident */ ComplexArrayType m_Ei; diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.txx b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.txx index 2033434957..b26db12511 100755 --- a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.txx +++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.txx @@ -31,8 +31,9 @@ template <class TInputImageHH,class TInputImageHV,class TInputImageVH,class TInp PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImageVV,TOutputImage,TFunction> ::PolarimetricSynthesisFilter() { - this->SetNumberOfRequiredInputs(1); + this->SetNumberOfRequiredInputs(0); this->SetNumberOfInputs(4); + SetMode(0); } /** @@ -91,6 +92,27 @@ PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImag Superclass::PrintSelf(os,indent); } +template <class TInputImageHH,class TInputImageHV,class TInputImageVH,class TInputImageVV,class TOutputImage,class TFunction > +void +PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImageVV,TOutputImage,TFunction> +::Print() +{ + std::cout<<"PsiI: "<<m_PsiI<<std::endl; + std::cout<<"TauI: "<<m_TauI<<std::endl; + std::cout<<"PsiR: "<<m_PsiR<<std::endl; + std::cout<<"TauR: "<<m_TauR<<std::endl; + + std::cout<<"Ei0 im: "<<m_Ei[0].imag()<<std::endl; + std::cout<<"Ei0 re: "<<m_Ei[0].real()<<std::endl; + std::cout<<"Ei1 im: "<<m_Ei[1].imag()<<std::endl; + std::cout<<"Ei1 re: "<<m_Ei[1].real()<<std::endl; + + std::cout<<"Er0 im: "<<m_Er[0].imag()<<std::endl; + std::cout<<"Er0 re: "<<m_Er[0].real()<<std::endl; + std::cout<<"Er1 im: "<<m_Er[1].imag()<<std::endl; + std::cout<<"Er1 re: "<<m_Er[1].real()<<std::endl; +} + /** * Force Copolar mode */ @@ -99,8 +121,9 @@ void PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImageVV,TOutputImage,TFunction> ::ForceCoPolar() { - this->SetPsiR(m_PsiI); - this->SetTauR(m_TauI); + SetPsiR(m_PsiI); + SetTauR(m_TauI); + SetMode(1); } /** @@ -111,8 +134,9 @@ void PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImageVV,TOutputImage,TFunction> ::ForceCrossPolar() { - this->SetPsiR(m_PsiI+90); - this->SetTauR(-m_TauI); + SetPsiR(m_PsiI+90); + SetTauR(-m_TauI); + SetMode(2); } /** @@ -148,23 +172,7 @@ PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImag this->SetEi(AEi); this->SetEr(AEr); - - std::cout<<"PsiI: "<<m_PsiI<<std::endl; - std::cout<<"TauI: "<<m_TauI<<std::endl; - std::cout<<"PsiR: "<<m_PsiR<<std::endl; - std::cout<<"TauR: "<<m_TauR<<std::endl; - - std::cout<<"Ei0 im: "<<m_Ei[0].imag()<<std::endl; - std::cout<<"Ei0 re: "<<m_Ei[0].real()<<std::endl; - std::cout<<"Ei1 im: "<<m_Ei[1].imag()<<std::endl; - std::cout<<"Ei1 re: "<<m_Ei[1].real()<<std::endl; - - std::cout<<"Er0 im: "<<m_Er[0].imag()<<std::endl; - std::cout<<"Er0 re: "<<m_Er[0].real()<<std::endl; - std::cout<<"Er1 im: "<<m_Er[1].imag()<<std::endl; - std::cout<<"Er1 re: "<<m_Er[1].real()<<std::endl; - - std::cout<<"DTOR: "<<DTOR<<std::endl; + } /** @@ -237,6 +245,8 @@ PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImag // Forcing TauI=0 PsiI=90 this->SetTauI(0); this->SetPsiI(90); + if(GetMode()==1)ForceCoPolar(); + else if(GetMode()==2)ForceCrossPolar(); } else // Only HH and HV are present @@ -270,7 +280,9 @@ PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImag // Forcing TauI=0 PsiI=0 this->SetTauI(0); - this->SetPsiI(0); + this->SetPsiI(0); + if(GetMode()==1)ForceCoPolar(); + else if(GetMode()==2)ForceCrossPolar(); } else // Only HH and VV are present @@ -301,6 +313,8 @@ PolarimetricSynthesisFilter<TInputImageHH,TInputImageHV,TInputImageVH,TInputImag // Second Part. Estimation of the incident field Ei and the reflected field Er ComputeElectromagneticFields(); + + Print(); } } -- GitLab