diff --git a/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.h b/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.h index 41f51633a49879aeb1e7602ec125a669ada0e719..e74c42dd5bce5785ec4750441a17242756142809 100644 --- a/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.h +++ b/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.h @@ -42,7 +42,7 @@ namespace otb * and itk::ComplexToPhaseImageFilter for example. * */ - template< class TInput1, class TInput2=TInput1, class TOutput=TInput1> + template< class TInput1, class TInput2=TInput1, class TInput3=TInput1, class TOutput=TInput1> class ITK_EXPORT AmplitudePhaseToRGBFunctor { public: @@ -68,7 +68,7 @@ namespace otb this->m_Minimum = min; } - inline TOutput operator()( const TInput1 & amplitude, const TInput2 & phase) const + inline TOutput operator()( const TInput1 & amplitude, const TInput2 & coherence, const TInput3 & phase) const { // std::cout << amplitude << " - " << phase << std::endl; double hinc, sinc, vinc; @@ -79,8 +79,9 @@ namespace otb double hue, sat, val; hue = 0.6 - (phase+M_PI)*hinc; - sat = 0.99; - val = itk::NumericTraits<RGBComponentType>::max()/(m_Maximum-m_Minimum) * (amplitude-m_Minimum); + sat = 0.6*coherence+0.3; + val = itk::NumericTraits<RGBComponentType>::max()/2 + * ( (amplitude-m_Minimum)/(m_Maximum-m_Minimum)+1.0); if (amplitude < m_Minimum) { diff --git a/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.cxx b/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.cxx index 0c32d4d5692ed5eb05c32d9d54e1a0630433e683..d351b5b453003e73860fd0972929da62388a899e 100644 --- a/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.cxx +++ b/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctor.cxx @@ -30,10 +30,11 @@ #include "otbImageFileReader.h" #include "otbStreamingImageFileWriter.h" -#include "itkBinaryFunctorImageFilter.h" +#include "itkTernaryFunctorImageFilter.h" #include "otbAmplitudePhaseToRGBFunctor.h" #include "itkComplexToModulusImageFilter.h" #include "itkComplexToPhaseImageFilter.h" +#include "itkShiftScaleImageFilter.h" int otbAmplitudePhaseToRGBFunctor(int argc, char * argv[]) { @@ -64,18 +65,23 @@ int otbAmplitudePhaseToRGBFunctor(int argc, char * argv[]) PhaseFilterType::Pointer phaseFilter = PhaseFilterType::New(); phaseFilter->SetInput(reader->GetOutput()); + typedef itk::ShiftScaleImageFilter<ImageType, ImageType> ConstFilterType; + ConstFilterType::Pointer constFilter = ConstFilterType::New(); + constFilter->SetScale(0.0); + constFilter->SetInput(modulusFilter->GetOutput()); typedef otb::Functor::AmplitudePhaseToRGBFunctor - <PixelType,PixelType,RGBPixelType> ColorMapFunctorType; - typedef itk::BinaryFunctorImageFilter - <ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; + <PixelType,PixelType,PixelType,RGBPixelType> ColorMapFunctorType; + typedef itk::TernaryFunctorImageFilter + <ImageType, ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New(); colormapper->GetFunctor().SetMaximum(4000); colormapper->GetFunctor().SetMinimum(0); colormapper->SetInput1(modulusFilter->GetOutput()); - colormapper->SetInput2(phaseFilter->GetOutput()); + colormapper->SetInput2(constFilter->GetOutput()); + colormapper->SetInput3(phaseFilter->GetOutput()); colormapper->SetNumberOfThreads(1); writer->SetInput(colormapper->GetOutput()); diff --git a/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctorNew.cxx b/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctorNew.cxx index 6c6fc24c05c604f6b98f3365db40cbe72b585a20..9532c4ce4c336feb175a9a904538cf0348991a01 100644 --- a/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctorNew.cxx +++ b/Testing/Code/BasicFilters/otbAmplitudePhaseToRGBFunctorNew.cxx @@ -28,7 +28,7 @@ #include "otbImage.h" -#include "itkBinaryFunctorImageFilter.h" +#include "itkTernaryFunctorImageFilter.h" #include "otbAmplitudePhaseToRGBFunctor.h" int otbAmplitudePhaseToRGBFunctorNew(int argc, char * argv[]) @@ -41,9 +41,9 @@ int otbAmplitudePhaseToRGBFunctorNew(int argc, char * argv[]) typedef otb::Image<RGBPixelType, 2> RGBImageType; typedef otb::Functor::AmplitudePhaseToRGBFunctor - <PixelType,PixelType,RGBPixelType> ColorMapFunctorType; - typedef itk::BinaryFunctorImageFilter - <ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; + <PixelType,PixelType,PixelType,RGBPixelType> ColorMapFunctorType; + typedef itk::TernaryFunctorImageFilter + <ImageType, ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New(); colormapper->GetFunctor().SetMaximum(150); colormapper->GetFunctor().SetMinimum(70);