Skip to content
Snippets Groups Projects
Commit d36f2a8d authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: tuning AmplitudePhaseToRGB representation

parent c9add2cf
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ namespace otb ...@@ -42,7 +42,7 @@ namespace otb
* and itk::ComplexToPhaseImageFilter for example. * 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 class ITK_EXPORT AmplitudePhaseToRGBFunctor
{ {
public: public:
...@@ -68,7 +68,7 @@ namespace otb ...@@ -68,7 +68,7 @@ namespace otb
this->m_Minimum = min; 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; // std::cout << amplitude << " - " << phase << std::endl;
double hinc, sinc, vinc; double hinc, sinc, vinc;
...@@ -79,8 +79,9 @@ namespace otb ...@@ -79,8 +79,9 @@ namespace otb
double hue, sat, val; double hue, sat, val;
hue = 0.6 - (phase+M_PI)*hinc; hue = 0.6 - (phase+M_PI)*hinc;
sat = 0.99; sat = 0.6*coherence+0.3;
val = itk::NumericTraits<RGBComponentType>::max()/(m_Maximum-m_Minimum) * (amplitude-m_Minimum); val = itk::NumericTraits<RGBComponentType>::max()/2
* ( (amplitude-m_Minimum)/(m_Maximum-m_Minimum)+1.0);
if (amplitude < m_Minimum) if (amplitude < m_Minimum)
{ {
......
...@@ -30,10 +30,11 @@ ...@@ -30,10 +30,11 @@
#include "otbImageFileReader.h" #include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h" #include "otbStreamingImageFileWriter.h"
#include "itkBinaryFunctorImageFilter.h" #include "itkTernaryFunctorImageFilter.h"
#include "otbAmplitudePhaseToRGBFunctor.h" #include "otbAmplitudePhaseToRGBFunctor.h"
#include "itkComplexToModulusImageFilter.h" #include "itkComplexToModulusImageFilter.h"
#include "itkComplexToPhaseImageFilter.h" #include "itkComplexToPhaseImageFilter.h"
#include "itkShiftScaleImageFilter.h"
int otbAmplitudePhaseToRGBFunctor(int argc, char * argv[]) int otbAmplitudePhaseToRGBFunctor(int argc, char * argv[])
{ {
...@@ -64,18 +65,23 @@ int otbAmplitudePhaseToRGBFunctor(int argc, char * argv[]) ...@@ -64,18 +65,23 @@ int otbAmplitudePhaseToRGBFunctor(int argc, char * argv[])
PhaseFilterType::Pointer phaseFilter = PhaseFilterType::New(); PhaseFilterType::Pointer phaseFilter = PhaseFilterType::New();
phaseFilter->SetInput(reader->GetOutput()); 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 typedef otb::Functor::AmplitudePhaseToRGBFunctor
<PixelType,PixelType,RGBPixelType> ColorMapFunctorType; <PixelType,PixelType,PixelType,RGBPixelType> ColorMapFunctorType;
typedef itk::BinaryFunctorImageFilter typedef itk::TernaryFunctorImageFilter
<ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; <ImageType, ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New(); ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->GetFunctor().SetMaximum(4000); colormapper->GetFunctor().SetMaximum(4000);
colormapper->GetFunctor().SetMinimum(0); colormapper->GetFunctor().SetMinimum(0);
colormapper->SetInput1(modulusFilter->GetOutput()); colormapper->SetInput1(modulusFilter->GetOutput());
colormapper->SetInput2(phaseFilter->GetOutput()); colormapper->SetInput2(constFilter->GetOutput());
colormapper->SetInput3(phaseFilter->GetOutput());
colormapper->SetNumberOfThreads(1); colormapper->SetNumberOfThreads(1);
writer->SetInput(colormapper->GetOutput()); writer->SetInput(colormapper->GetOutput());
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "otbImage.h" #include "otbImage.h"
#include "itkBinaryFunctorImageFilter.h" #include "itkTernaryFunctorImageFilter.h"
#include "otbAmplitudePhaseToRGBFunctor.h" #include "otbAmplitudePhaseToRGBFunctor.h"
int otbAmplitudePhaseToRGBFunctorNew(int argc, char * argv[]) int otbAmplitudePhaseToRGBFunctorNew(int argc, char * argv[])
...@@ -41,9 +41,9 @@ int otbAmplitudePhaseToRGBFunctorNew(int argc, char * argv[]) ...@@ -41,9 +41,9 @@ int otbAmplitudePhaseToRGBFunctorNew(int argc, char * argv[])
typedef otb::Image<RGBPixelType, 2> RGBImageType; typedef otb::Image<RGBPixelType, 2> RGBImageType;
typedef otb::Functor::AmplitudePhaseToRGBFunctor typedef otb::Functor::AmplitudePhaseToRGBFunctor
<PixelType,PixelType,RGBPixelType> ColorMapFunctorType; <PixelType,PixelType,PixelType,RGBPixelType> ColorMapFunctorType;
typedef itk::BinaryFunctorImageFilter typedef itk::TernaryFunctorImageFilter
<ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; <ImageType, ImageType, ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New(); ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->GetFunctor().SetMaximum(150); colormapper->GetFunctor().SetMaximum(150);
colormapper->GetFunctor().SetMinimum(70); colormapper->GetFunctor().SetMinimum(70);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment