REFAC: otbImageSeriesFileReader
authorGregoire Mercier <gregoire.mercier@telecom-bretagne.eu>
Fri Jul 03 18:17:54 2009 +0200 (14 months ago)
changeset 58755866d083b0aa
parent 5874 6327c8343969
parent 5873 208acfc391d9
child 5878 8404b93702e8
REFAC: otbImageSeriesFileReader
Code/Visualization/otbDirectRenderingFunction.h
     1.1 --- a/Code/Visualization/otbCurves2DWidget.h	Fri Jul 03 18:17:40 2009 +0200
     1.2 +++ b/Code/Visualization/otbCurves2DWidget.h	Fri Jul 03 18:17:54 2009 +0200
     1.3 @@ -24,7 +24,7 @@
     1.4  
     1.5  namespace otb
     1.6  {
     1.7 -/** \class 2DCurveWidget
     1.8 +/** \class Curves2DWidget
     1.9   *
    1.10   *  \brief This widget renders a set of curves to the screen.
    1.11   *
     2.1 --- a/Code/Visualization/otbDirectRenderingFunction.h	Fri Jul 03 18:17:40 2009 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,204 +0,0 @@
     2.4 -/*=========================================================================
     2.5 -
     2.6 -  Program:   ORFEO Toolbox
     2.7 -  Language:  C++
     2.8 -  Date:      $Date$
     2.9 -  Version:   $Revision$
    2.10 -
    2.11 -
    2.12 -  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
    2.13 -  See OTBCopyright.txt for details.
    2.14 -
    2.15 -
    2.16 -     This software is distributed WITHOUT ANY WARRANTY; without even
    2.17 -     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    2.18 -     PURPOSE.  See the above copyright notices for more information.
    2.19 -
    2.20 -=========================================================================*/
    2.21 -#ifndef __otbDirectRenderingFunction_h
    2.22 -#define __otbDirectRenderingFunction_h
    2.23 -
    2.24 -#include "otbRenderingFunction.h"
    2.25 -#include "otbMacro.h"
    2.26 -#include <assert.h>
    2.27 -#include <iomanip>
    2.28 -
    2.29 -namespace otb
    2.30 -{
    2.31 -namespace Function
    2.32 -{
    2.33 -
    2.34 -/** \class DirectRenderingFunction
    2.35 - * \brief Standard rendering.
    2.36 - *
    2.37 - * This function just reproduce the input value at the output
    2.38 - * with the risk of truncated values. Use it if you know that
    2.39 - * your input values are between 0 and 255.
    2.40 - *
    2.41 - *  \ingroup Visualization
    2.42 - */
    2.43 -template <class TPixelPrecision, class TRGBPixel >
    2.44 -class DirectRenderingFunction
    2.45 -  : public RenderingFunction<TPixelPrecision,TRGBPixel>
    2.46 -{
    2.47 -public:
    2.48 -  /** Standard class typedefs */
    2.49 -  typedef DirectRenderingFunction                   Self;
    2.50 -  typedef RenderingFunction<TPixelPrecision,TRGBPixel> Superclass;
    2.51 -  typedef itk::SmartPointer<Self>                      Pointer;
    2.52 -  typedef itk::SmartPointer<const Self>                ConstPointer;
    2.53 -
    2.54 -  /** type macro */
    2.55 -  itkTypeMacro(DirectRenderingFunction,RenderingFunction);
    2.56 -
    2.57 -  /** new macro */
    2.58 -  itkNewMacro(Self);
    2.59 -
    2.60 -  /** PixelType macros */
    2.61 -  typedef TRGBPixel                                  OutputPixelType;
    2.62 -  typedef typename OutputPixelType::ValueType        OutputValueType;
    2.63 -  typedef TPixelPrecision                            PixelType;
    2.64 -  typedef typename itk::NumericTraits<PixelType>::ValueType ScalarType;
    2.65 -  typedef itk::VariableLengthVector<ScalarType>       VectorPixelType;
    2.66 -  typedef itk::RGBPixel<ScalarType> RGBPixelType;
    2.67 -  typedef itk::RGBAPixel<ScalarType> RGBAPixelType;
    2.68 -
    2.69 -  /** Evaluate method (scalar version) */
    2.70 -  inline virtual const OutputPixelType Evaluate(ScalarType spixel) const
    2.71 -  {
    2.72 -    OutputPixelType resp;
    2.73 -    resp.SetRed(spixel);
    2.74 -    resp.SetGreen(spixel);
    2.75 -    resp.SetBlue(spixel);
    2.76 -    return resp;
    2.77 -  }
    2.78 -  /** Evaluate method (vector version) */
    2.79 -  inline virtual const OutputPixelType Evaluate(const VectorPixelType & vpixel) const
    2.80 -  {
    2.81 -    OutputPixelType resp;
    2.82 -    resp.Fill(itk::NumericTraits<typename OutputPixelType::ValueType>::max());
    2.83 -    resp.SetRed(vpixel[m_RedChannelIndex]);
    2.84 -    resp.SetGreen(vpixel[m_GreenChannelIndex]);
    2.85 -    resp.SetBlue(vpixel[m_BlueChannelIndex]);
    2.86 -    return resp;
    2.87 -  }
    2.88 -  /** Evaluate method (RGB pixel version) */
    2.89 -  inline virtual const OutputPixelType Evaluate(const RGBPixelType & vpixel) const
    2.90 -  {
    2.91 -    OutputPixelType resp;
    2.92 -    resp.Fill(itk::NumericTraits<typename OutputPixelType::ValueType>::max());
    2.93 -    resp.SetRed(vpixel[m_RedChannelIndex]);
    2.94 -    resp.SetGreen(vpixel[m_GreenChannelIndex]);
    2.95 -    resp.SetBlue(vpixel[m_BlueChannelIndex]);
    2.96 -    return resp;
    2.97 -  }
    2.98 -  /** Evaluate method (RGBA pixel version) */
    2.99 -  inline virtual const OutputPixelType Evaluate(const RGBAPixelType & vpixel) const
   2.100 -  {
   2.101 -    OutputPixelType resp;
   2.102 -//     resp.Fill(itk::NumericTraits<typename OutputPixelType::ValueType>::max());
   2.103 -    if (OutputPixelType::Length == 4)
   2.104 -    {//Propagate the alpha channel
   2.105 -      resp[3] = vpixel[3];
   2.106 -    }
   2.107 -    resp.SetRed(vpixel[m_RedChannelIndex]);
   2.108 -    resp.SetGreen(vpixel[m_GreenChannelIndex]);
   2.109 -    resp.SetBlue(vpixel[m_BlueChannelIndex]);
   2.110 -    return resp;
   2.111 -  }
   2.112 -
   2.113 -  inline const std::string Describe(ScalarType spixel) const
   2.114 -  {
   2.115 -    itk::OStringStream oss;
   2.116 -    OutputPixelType output = this->Evaluate(spixel);
   2.117 -    oss<<"Grayscale [value: "<< static_cast<typename itk::NumericTraits<PixelType>::PrintType>(spixel)<<", displayed: "<< static_cast<unsigned int>(output[0])<<"]";
   2.118 -    return oss.str();
   2.119 -  }
   2.120 -
   2.121 -  inline const std::string Describe(const VectorPixelType & vpixel) const
   2.122 -  {
   2.123 -    itk::OStringStream oss;
   2.124 -    OutputPixelType output = this->Evaluate(vpixel);
   2.125 -    for(unsigned int channel = 0; channel < vpixel.Size();++channel)
   2.126 -      {
   2.127 -      oss<<"c= "<< channel << ", ";
   2.128 -      if(channel == m_RedChannelIndex)
   2.129 -        {
   2.130 -        oss <<"R= " << std::setw(3) <<(int)output[0]<< ", ";
   2.131 -        }
   2.132 -      else if(channel == m_GreenChannelIndex)
   2.133 -        {
   2.134 -        oss <<"G= " << std::setw(3) <<(int)output[1]<< ", ";
   2.135 -        }
   2.136 -      else if(channel == m_BlueChannelIndex)
   2.137 -        {
   2.138 -        oss <<"B= " << std::setw(3) <<(int)output[2]<< ", ";
   2.139 -        }
   2.140 -      else
   2.141 -        {
   2.142 -        oss <<"       ";
   2.143 -        }
   2.144 -        oss<<"v= "<<static_cast<typename itk::NumericTraits<PixelType>::PrintType>(vpixel[channel])<<std::endl;
   2.145 -      }
   2.146 -    return oss.str();
   2.147 -  }
   2.148 -
   2.149 -  inline const std::string Describe(const RGBPixelType & spixel) const
   2.150 -  {
   2.151 -    itk::OStringStream oss;
   2.152 -    OutputPixelType output = this->Evaluate(spixel);
   2.153 -    oss<<"RGB value: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[0])
   2.154 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[1])
   2.155 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[2])
   2.156 -        << std::endl;
   2.157 -    oss <<"   displayed: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[0])
   2.158 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[1])
   2.159 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[2])
   2.160 -        <<std::endl;
   2.161 -    return oss.str();
   2.162 -  }
   2.163 -
   2.164 -  inline const std::string Describe(const RGBAPixelType & spixel) const
   2.165 -  {
   2.166 -    itk::OStringStream oss;
   2.167 -    OutputPixelType output = this->Evaluate(spixel);
   2.168 -    oss<<"RGBA value: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[0])
   2.169 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[1])
   2.170 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[2])
   2.171 -        << " alpha: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[3])
   2.172 -        << std::endl;
   2.173 -    oss <<"   displayed: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[0])
   2.174 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[1])
   2.175 -        << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[2])
   2.176 -        << " alpha: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(output[3])
   2.177 -        <<std::endl;
   2.178 -    return oss.str();
   2.179 -  }
   2.180 -
   2.181 -
   2.182 -
   2.183 -protected:
   2.184 -  /** Constructor */
   2.185 -  DirectRenderingFunction() : m_RedChannelIndex(0), m_GreenChannelIndex(1), m_BlueChannelIndex(2)
   2.186 -  {}
   2.187 -  /** Destructor */
   2.188 -  ~DirectRenderingFunction() {}
   2.189 -
   2.190 -private:
   2.191 -  DirectRenderingFunction(const Self&); //purposely not implemented
   2.192 -  void operator=(const Self&); //purposely not implemented
   2.193 -
   2.194 -  /** Index of the channels to display (vector mode only, has no effet
   2.195 -   *  on scalar mode)
   2.196 -   */
   2.197 -  unsigned int m_RedChannelIndex;
   2.198 -  unsigned int m_GreenChannelIndex;
   2.199 -  unsigned int m_BlueChannelIndex;
   2.200 -
   2.201 -};
   2.202 -} // end namespace Functor
   2.203 -} // end namespace otb
   2.204 -
   2.205 -#endif
   2.206 -
   2.207 -
     3.1 --- a/Code/Visualization/otbRenderingFunction.h	Fri Jul 03 18:17:40 2009 +0200
     3.2 +++ b/Code/Visualization/otbRenderingFunction.h	Fri Jul 03 18:17:54 2009 +0200
     3.3 @@ -126,6 +126,11 @@
     3.4      itkExceptionMacro(<<"Subclasses should override this method");
     3.5    }
     3.6  
     3.7 +  virtual void SetAutoMinMax(bool autoMinMax)
     3.8 +  {
     3.9 +    itkExceptionMacro(<<"Subclasses should override this method");
    3.10 +  }
    3.11 +
    3.12    /** Get the histogram of the pixel representation generated from the sample list */
    3.13    virtual HistogramListPointerType GetHistogramList()
    3.14    {
     4.1 --- a/Code/Visualization/otbRenderingImageFilter.h	Fri Jul 03 18:17:40 2009 +0200
     4.2 +++ b/Code/Visualization/otbRenderingImageFilter.h	Fri Jul 03 18:17:54 2009 +0200
     4.3 @@ -197,7 +197,9 @@
     4.4  
     4.5      //Check if the rendering function channels are compatible with the image
     4.6      //might want to be more generic here one day.
     4.7 -    unsigned int numberOfInputChannels = this->GetInput()->GetNumberOfComponentsPerPixel();
     4.8 +//     unsigned int numberOfInputChannels = this->GetInput()->GetNumberOfComponentsPerPixel();
     4.9 +    itk::ImageRegionConstIterator<TInputImage> it(this->GetInput(),this->GetInput()->GetBufferedRegion());
    4.10 +    unsigned int numberOfInputChannels = VisualizationPixelTraits::PixelSize(it.Get());
    4.11      std::vector<unsigned int> channels = (this->GetFunctor().GetFunction())->GetChannelList();
    4.12      for (unsigned int i=0; i<channels.size(); ++i)
    4.13      {
     5.1 --- a/Code/Visualization/otbStandardRenderingFunction.h	Fri Jul 03 18:17:40 2009 +0200
     5.2 +++ b/Code/Visualization/otbStandardRenderingFunction.h	Fri Jul 03 18:17:54 2009 +0200
     5.3 @@ -142,14 +142,7 @@
     5.4  //            << "m_TransferFunction(spixel[0])" << m_TransferFunction(spixel[0])
     5.5  //            << ", m_TransferedMinimum[0] " << m_TransferedMinimum[0]
     5.6  //            << ", m_TransferedMaximum[0] " << m_TransferedMaximum[0])
     5.7 -//     otbMsgDevMacro(<<"StandardRenderingFunction::EvaluateTransferFunction "
     5.8 -//            << "m_TransferFunction(spixel[1])" << m_TransferFunction(spixel[1])
     5.9 -//            << ", m_TransferedMinimum[1] " << m_TransferedMinimum[1]
    5.10 -//            << ", m_TransferedMaximum[1] " << m_TransferedMaximum[1])
    5.11 -//     otbMsgDevMacro(<<"StandardRenderingFunction::EvaluateTransferFunction "
    5.12 -//            << "m_TransferFunction(spixel[2])" << m_TransferFunction(spixel[2])
    5.13 -//            << ", m_TransferedMinimum[2] " << m_TransferedMinimum[2]
    5.14 -//            << ", m_TransferedMaximum[2] " << m_TransferedMaximum[2])
    5.15 +
    5.16      if (spixel.Size() == 1)
    5.17      {
    5.18        OutputValueType value = ClampRescale(m_TransferFunction(spixel[0]),m_TransferedMinimum[0],m_TransferedMaximum[0]);
    5.19 @@ -225,6 +218,18 @@
    5.20          }
    5.21  
    5.22        }
    5.23 +      else
    5.24 +      {
    5.25 +        unsigned int nbComps = m_PixelRepresentationFunction.GetOutputSize();
    5.26 +        if (m_Minimum.empty())
    5.27 +        {
    5.28 +          m_Minimum.resize(nbComps,0);
    5.29 +        }
    5.30 +        if (m_Maximum.empty())
    5.31 +        {
    5.32 +          m_Maximum.resize(nbComps,255);
    5.33 +        }
    5.34 +      }
    5.35  
    5.36        typename ExtremaVectorType::const_iterator minIt = this->m_Minimum.begin();
    5.37        typename ExtremaVectorType::const_iterator maxIt = this->m_Maximum.begin();
    5.38 @@ -280,75 +285,6 @@
    5.39      return oss.str();
    5.40    }
    5.41  
    5.42 -//   inline const std::string Describe(const ScalarType & spixel) const //FIXME not updated yet
    5.43 -//   {
    5.44 -//     itk::OStringStream oss;
    5.45 -//     OutputPixelType output = this->Evaluate(spixel);
    5.46 -//     oss<<"Grayscale [value: "<< static_cast<typename itk::NumericTraits<PixelType>::PrintType>(spixel)<<", displayed: "<< static_cast<unsigned int>(output[0])<<"]";
    5.47 -//     return oss.str();
    5.48 -//   }
    5.49 -//
    5.50 -//   inline const std::string Describe(const VectorPixelType & vpixel) const//FIXME not updated yet
    5.51 -//   {
    5.52 -//     itk::OStringStream oss;
    5.53 -//     OutputPixelType output = this->Evaluate(vpixel);
    5.54 -//
    5.55 -//     for(unsigned int channel = 0; channel < vpixel.Size();++channel)
    5.56 -//       {
    5.57 -//       oss<<"c= "<< channel << ", ";
    5.58 -//       if(channel == m_RedChannelIndex)
    5.59 -//         {
    5.60 -//         oss <<"R= " << std::setw(3) <<(int)output[0]<< ", ";
    5.61 -//         }
    5.62 -//       else if(channel == m_GreenChannelIndex)
    5.63 -//         {
    5.64 -//         oss <<"G= " << std::setw(3) <<(int)output[1]<< ", ";
    5.65 -//         }
    5.66 -//       else if(channel == m_BlueChannelIndex)
    5.67 -//         {
    5.68 -//         oss <<"B= " << std::setw(3) <<(int)output[2]<< ", ";
    5.69 -//         }
    5.70 -//       else
    5.71 -//         {
    5.72 -//         oss <<"       ";
    5.73 -//         }
    5.74 -//         oss<<"v= "<<static_cast<typename itk::NumericTraits<PixelType>::PrintType>(vpixel[channel])<<std::endl;
    5.75 -//       }
    5.76 -//     return oss.str();
    5.77 -//   }
    5.78 -//
    5.79 -//   inline const std::string Describe(const RGBPixelType & spixel) const //FIXME not updated yet
    5.80 -//   {
    5.81 -//     itk::OStringStream oss;
    5.82 -//     OutputPixelType output = this->Evaluate(spixel);
    5.83 -//     oss<<"RGB value: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[0])
    5.84 -//         << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[1])
    5.85 -//         << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[2])
    5.86 -//         << std::endl;
    5.87 -//     oss <<"   displayed: "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[0])
    5.88 -//         << ", "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[1])
    5.89 -//         << ", "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[2])
    5.90 -//         <<std::endl;
    5.91 -//     return oss.str();
    5.92 -//   }
    5.93 -//
    5.94 -//   inline const std::string Describe(const RGBAPixelType & spixel) const //FIXME not updated yet
    5.95 -//   {
    5.96 -//     itk::OStringStream oss;
    5.97 -//     OutputPixelType output = this->Evaluate(spixel);
    5.98 -//     oss<<"RGBA value: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[0])
    5.99 -//         << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[1])
   5.100 -//         << ", "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[2])
   5.101 -//         << " alpha: "<< static_cast<typename itk::NumericTraits<ScalarType>::PrintType>(spixel[3])
   5.102 -//         << std::endl;
   5.103 -//     oss <<"   displayed: "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[0])
   5.104 -//         << ", "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[1])
   5.105 -//         << ", "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[2])
   5.106 -//         << " alpha: "<< static_cast<typename itk::NumericTraits<OutputPixelType>::PrintType>(output[3])
   5.107 -//         <<std::endl;
   5.108 -//     return oss.str();
   5.109 -//   }
   5.110 -
   5.111     /** Set the minimum and maximum for the different bands.
   5.112       * Has to be provided as [minBand0, maxBand0, minBand1, maxBand1,...]
   5.113       */
     6.1 --- a/Code/Visualization/otbVisualizationPixelTraits.h	Fri Jul 03 18:17:40 2009 +0200
     6.2 +++ b/Code/Visualization/otbVisualizationPixelTraits.h	Fri Jul 03 18:17:54 2009 +0200
     6.3 @@ -105,9 +105,7 @@
     6.4    template< class TScalarTypeInput >
     6.5    static unsigned int PixelSize(const itk::RGBAPixel<TScalarTypeInput>& in)
     6.6    {
     6.7 -    //We return only the useful size of the pixel, the alpha channel may be used later
     6.8 -    //but only for display purposes
     6.9 -    return 3;
    6.10 +    return 4;
    6.11    }
    6.12  
    6.13    template< class TScalarTypeInput >