]> Creatis software - cpPlugins.git/commitdiff
New plugin: RGB -> HSV
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 17 Dec 2014 19:31:10 +0000 (20:31 +0100)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 17 Dec 2014 19:31:10 +0000 (20:31 +0100)
appli/examples/CMakeLists.txt
appli/examples/example_RGBImageToHSVChannels.cxx [new file with mode: 0644]
lib/cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.h [new file with mode: 0644]
lib/cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.hxx [new file with mode: 0644]
lib/cpPlugins/Extensions/CMakeLists.txt
lib/cpPlugins/Plugins/Host.cxx
lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h [new file with mode: 0644]

index 705394aab662de957f1f60a00fd1c292a3f8d0cd..e210337ed72e46518f0a82f32e1ac614b3f207b8 100644 (file)
@@ -12,6 +12,7 @@ SET(
   example_ReadQuadEdgeMeshWithoutPlugins
   example_RenderQuadEdgeMesh
   example_RenderQuadEdgeMeshWithoutPlugins
+  example_RGBImageToHSVChannels
   example_MPR
   )
 
diff --git a/appli/examples/example_RGBImageToHSVChannels.cxx b/appli/examples/example_RGBImageToHSVChannels.cxx
new file mode 100644 (file)
index 0000000..7266800
--- /dev/null
@@ -0,0 +1,119 @@
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Interface     TInterface;
+typedef cpPlugins::Interface::DataObject    TDataObject;
+typedef TInterface::TClasses                TClasses;
+typedef cpPlugins::Interface::ProcessObject TProcessObject;
+typedef TProcessObject::TParameters         TParameters;
+
+// -------------------------------------------------------------------------
+void SaveImage(
+  TInterface& plugins, const std::string& fname, TDataObject* image
+  )
+{
+  cpPlugins::Interface::ProcessObject* writer;
+  writer =
+    dynamic_cast< TProcessObject* >(
+      plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" )
+      );
+  if( writer == NULL )
+  {
+    std::cerr << "No suitable writer found in plugins." << std::endl;
+    return;
+
+  } // fi
+  // Configure reader
+  TParameters writer_params = writer->GetDefaultParameters( );
+  writer_params[ "FileName" ].second = fname;
+  writer->SetParameters( writer_params );
+
+  writer->SetInput( 0, image );
+  std::string msg = writer->Update( );
+  if( msg != "" )
+    std::cerr << "ERROR: " << msg << std::endl;
+  delete writer;
+}
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+  if( argc < 8 )
+  {
+    std::cerr
+      << "Usage: " << argv[ 0 ]
+      << " plugins_file"
+      << " input_image"
+      << " output_hue_image output_saturation_image output_value_image"
+      << " dimensions pixel_type" << std::endl;
+    return( 1 );
+
+  } // fi
+  std::string plugins_file = argv[ 1 ];
+  std::string input_image_file = argv[ 2 ];
+  std::string output_hue_image_file = argv[ 3 ];
+  std::string output_saturation_image_file = argv[ 4 ];
+  std::string output_value_image_file = argv[ 5 ];
+  std::string dimensions = argv[ 6 ];
+  std::string pixel_type = argv[ 7 ];
+
+  // Create interface
+
+  TInterface plugins;
+  plugins.Load( plugins_file );
+
+  // Create objects
+  cpPlugins::Interface::ProcessObject* reader;
+  cpPlugins::Interface::ProcessObject* filter;
+
+  reader =
+    dynamic_cast< TProcessObject* >(
+      plugins.CreateObject( "cpPlugins::Plugins::ImageReader" )
+      );
+  if( reader == NULL )
+  {
+    std::cerr << "No suitable reader found in plugins." << std::endl;
+    return( 1 );
+
+  } // fi
+  filter =
+    dynamic_cast< TProcessObject* >(
+      plugins.CreateObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" )
+      );
+  if( filter == NULL )
+  {
+    std::cerr << "No suitable filter found in plugins." << std::endl;
+    return( 1 );
+
+  } // fi
+
+  // Configure reader
+  TParameters reader_params = reader->GetDefaultParameters( );
+  reader_params[ "FileName" ].second = input_image_file;
+  reader_params[ "PixelType" ].second = pixel_type;
+  reader_params[ "ImageDimension" ].second = dimensions;
+  reader_params[ "IsColorImage" ].second = "1";
+  reader->SetParameters( reader_params );
+
+  // Connect pipeline
+  filter->SetInput( 0, reader->GetOutput( 0 ) );
+
+  // Save outputs
+  SaveImage( plugins, output_hue_image_file, filter->GetOutput( 0 ) );
+  SaveImage( plugins, output_saturation_image_file, filter->GetOutput( 1 ) );
+  SaveImage( plugins, output_value_image_file, filter->GetOutput( 2 ) );
+
+  // Free memory
+  delete filter;
+  delete reader;
+
+  return( 0 );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.h b/lib/cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.h
new file mode 100644 (file)
index 0000000..c497d55
--- /dev/null
@@ -0,0 +1,84 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBIMAGETOHSVCHANNELSFILTER__H__
+#define __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBIMAGETOHSVCHANNELSFILTER__H__
+
+#include <itkImageToImageFilter.h>
+
+namespace cpPlugins
+{
+  namespace Extensions
+  {
+    namespace Algorithms
+    {
+      /**
+       */
+      template< class I, class O >
+      class RGBImageToHSVChannelsFilter
+        : public itk::ImageToImageFilter< I, O >
+      {
+      public:
+        typedef RGBImageToHSVChannelsFilter     Self;
+        typedef itk::ImageToImageFilter< I, O > Superclass;
+        typedef itk::SmartPointer< Self >       Pointer;
+        typedef itk::SmartPointer< const Self > ConstPointer;
+
+        typedef I TInputImage;
+        typedef O TOutputImage;
+        typedef typename I::PixelType TInputPixel;
+        typedef typename O::PixelType TOutputPixel;
+
+      public:
+        itkNewMacro( Self );
+        itkTypeMacro( RGBImageToHSVChannelsFilter, itkImageToImageFilter );
+
+      public:
+        O* GetHueOutput( );
+        O* GetSaturationOutput( );
+        O* GetValueOutput( );
+
+        const O* GetHueOutput( ) const;
+        const O* GetSaturationOutput( ) const;
+        const O* GetValueOutput( ) const;
+
+        void GraftHueOutput( O* hue );
+        void GraftSaturationOutput( O* saturation );
+        void GraftValueOutput( O* value );
+
+      protected:
+        RGBImageToHSVChannelsFilter( );
+        virtual ~RGBImageToHSVChannelsFilter( );
+
+        virtual void BeforeThreadedGenerateData( );
+        virtual void AfterThreadedGenerateData( );
+
+        virtual void ThreadedGenerateData(
+          const typename Superclass::OutputImageRegionType& region,
+          itk::ThreadIdType threadId
+          );
+
+      protected:
+        static void _RGB2HSV(
+          const TInputPixel& RGB,
+          TOutputPixel& H, TOutputPixel& S, TOutputPixel& V
+          );
+
+      private:
+        // Purposely not implemented
+        RGBImageToHSVChannelsFilter( const Self& other );
+        void operator=( const Self& other );
+      };
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#include <cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.hxx>
+
+#endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBIMAGETOHSVCHANNELSFILTER__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.hxx b/lib/cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.hxx
new file mode 100644 (file)
index 0000000..b45a953
--- /dev/null
@@ -0,0 +1,230 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBIMAGETOHSVCHANNELSFILTER__HXX__
+#define __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBIMAGETOHSVCHANNELSFILTER__HXX__
+
+#include <cmath>
+#include <limits>
+#include <vnl/vnl_math.h>
+
+#include <itkImageRegionIterator.h>
+#include <itkImageRegionConstIterator.h>
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+O* cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GetHueOutput( )
+{
+  return( this->GetOutput( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+O* cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GetSaturationOutput( )
+{
+  return( this->GetOutput( 1 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+O* cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GetValueOutput( )
+{
+  return( this->GetOutput( 2 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+const O*
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GetHueOutput( ) const
+{
+  if( this->GetNumberOfOutputs( ) > 0 )
+    return(
+      dynamic_cast< const O* >(
+        this->itk::ProcessObject::GetOutput( 0 )
+        )
+      );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+const O*
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GetSaturationOutput( ) const
+{
+  if( this->GetNumberOfOutputs( ) > 1 )
+    return(
+      dynamic_cast< const O* >(
+        this->itk::ProcessObject::GetOutput( 1 )
+        )
+      );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+const O*
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GetValueOutput( ) const
+{
+  if( this->GetNumberOfOutputs( ) > 2 )
+    return(
+      dynamic_cast< const O* >(
+        this->itk::ProcessObject::GetOutput( 2 )
+        )
+      );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GraftHueOutput( O* hue )
+{
+  this->GraftNthOutput( 0, hue );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GraftSaturationOutput( O* saturation )
+{
+  this->GraftNthOutput( 1, saturation );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+GraftValueOutput( O* value )
+{
+  this->GraftNthOutput( 2, value );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+RGBImageToHSVChannelsFilter( )
+  : Superclass( )
+{
+  this->SetNumberOfRequiredInputs( 1 );
+  this->SetNumberOfRequiredOutputs( 3 );
+  for( unsigned int i = 0; i < 3; i++ )
+  {
+    typename O::Pointer o = O::New( );
+    this->SetNthOutput( i, o );
+
+  } // rof
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+~RGBImageToHSVChannelsFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+BeforeThreadedGenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+AfterThreadedGenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void
+cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+ThreadedGenerateData(
+  const typename Superclass::OutputImageRegionType& region,
+  itk::ThreadIdType threadId
+  )
+{
+  typedef itk::ImageRegionConstIterator< I > TInIt;
+  typedef itk::ImageRegionIterator< O > TOutIt;
+
+  TInIt inIt( this->GetInput( ), region );
+  TOutIt hIt( this->GetHueOutput( ), region );
+  TOutIt sIt( this->GetSaturationOutput( ), region );
+  TOutIt vIt( this->GetValueOutput( ), region );
+  inIt.GoToBegin( );
+  hIt.GoToBegin( );
+  sIt.GoToBegin( );
+  vIt.GoToBegin( );
+  for( ; !inIt.IsAtEnd( ); ++inIt, ++hIt, ++sIt, ++vIt )
+  {
+    TOutputPixel H, S, V;
+    Self::_RGB2HSV( inIt.Get( ), H, S, V );
+    hIt.Set( H );
+    sIt.Set( S );
+    vIt.Set( V );
+
+  } // rof
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+void cpPlugins::Extensions::Algorithms::RGBImageToHSVChannelsFilter< I, O >::
+_RGB2HSV(
+  const TInputPixel& RGB,
+  TOutputPixel& H, TOutputPixel& S, TOutputPixel& V
+  )
+{
+  typedef typename TInputPixel::ComponentType TComponent;
+  const double mVal = double( std::numeric_limits< TComponent >::max( ) );
+  const double _0 = double( 0 );
+  const double _1 = double( 1 );
+  const double _2 = double( 2 );
+  const double _3 = double( 3 );
+  const double _2pi = _2 * double( vnl_math::pi );
+
+  double R = double( RGB.GetRed( ) );
+  double G = double( RGB.GetGreen( ) );
+  double B = double( RGB.GetBlue( ) );
+  double sRGB = R + G + B;
+  double RG = R - G;
+  double RB = R - B;
+  double GB = G - B;
+
+  // Hue
+  double A = std::sqrt( ( RG * RG ) + ( RB * GB ) );
+  if( A != _0 )
+    A = std::acos( ( RG + RB ) / ( _2 * A ) );
+  A /= _2pi;
+  H = TOutputPixel( mVal * ( ( G >= B )? A: _1 - A ) );
+
+  // Saturation
+  if( sRGB != _0 )
+  {
+    double C = ( G < R )? G: R;
+    C        = ( B < C )? B: C;
+    S = TOutputPixel( mVal * ( _1 - ( ( _3 * C ) / sRGB ) ) );
+  }
+  else
+    S = TOutputPixel( 0 );
+  
+  // Value
+  V = TOutputPixel( sRGB / _3 );
+}
+
+#endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBIMAGETOHSVCHANNELSFILTER__HXX__
+
+// eof - $RCSfile$
index 020469ef7da500f130d7a98b1ada928806cd78a2..550daf7e8796af333a9a573d04f642c9d53210fc 100644 (file)
@@ -18,6 +18,13 @@ FILE(GLOB LIB_DataStructures_SOURCES_C   "DataStructures/*.c")
 FILE(GLOB LIB_DataStructures_SOURCES_CPP "DataStructures/*.cpp")
 FILE(GLOB LIB_DataStructures_SOURCES_CXX "DataStructures/*.cxx")
 
+FILE(GLOB LIB_Algorithms_HEADERS_H   "Algorithms/*.h")
+FILE(GLOB LIB_Algorithms_HEADERS_HPP "Algorithms/*.hpp")
+FILE(GLOB LIB_Algorithms_HEADERS_HXX "Algorithms/*.hxx")
+FILE(GLOB LIB_Algorithms_SOURCES_C   "Algorithms/*.c")
+FILE(GLOB LIB_Algorithms_SOURCES_CPP "Algorithms/*.cpp")
+FILE(GLOB LIB_Algorithms_SOURCES_CXX "Algorithms/*.cxx")
+
 FILE(GLOB LIB_IO_HEADERS_H   "IO/*.h")
 FILE(GLOB LIB_IO_HEADERS_HPP "IO/*.hpp")
 FILE(GLOB LIB_IO_HEADERS_HXX "IO/*.hxx")
@@ -45,6 +52,9 @@ ADD_LIBRARY(
   ${LIB_DataStructures_SOURCES_C}
   ${LIB_DataStructures_SOURCES_CPP}
   ${LIB_DataStructures_SOURCES_CXX}
+  ${LIB_Algorithms_SOURCES_C}
+  ${LIB_Algorithms_SOURCES_CPP}
+  ${LIB_Algorithms_SOURCES_CXX}
   ${LIB_IO_SOURCES_C}
   ${LIB_IO_SOURCES_CPP}
   ${LIB_IO_SOURCES_CXX}
index aab20638a20e6a5c16c284939bbf7a03e7edf2c9..b8477ce4d90262692dfb03c30e625e0680dc1080 100644 (file)
@@ -4,16 +4,20 @@
 #include <cpPlugins/Plugins/ImageWriter.h>
 #include <cpPlugins/Plugins/MarchingCubes.h>
 #include <cpPlugins/Plugins/MeshReader.h>
+#include <cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h>
 
 /// TODO: doc
 PLUMA_CONNECTOR
 bool connect( pluma::Host& host )
 {
-  host.add( new cpPlugins::Plugins::ImageReaderProvider( ) );
-  host.add( new cpPlugins::Plugins::ImageSeriesReaderProvider( ) );
-  host.add( new cpPlugins::Plugins::ImageWriterProvider( ) );
-  host.add( new cpPlugins::Plugins::MarchingCubesProvider( ) );
-  host.add( new cpPlugins::Plugins::MeshReaderProvider( ) );
+  using namespace cpPlugins::Plugins;
+
+  host.add( new ImageReaderProvider( ) );
+  host.add( new ImageSeriesReaderProvider( ) );
+  host.add( new ImageWriterProvider( ) );
+  host.add( new MarchingCubesProvider( ) );
+  host.add( new MeshReaderProvider( ) );
+  host.add( new RGBImageToHSVChannelsFilterProvider( ) );
   return( true );
 }
 
diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx
new file mode 100644 (file)
index 0000000..8d54034
--- /dev/null
@@ -0,0 +1,113 @@
+#include <cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h>
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Extensions/Algorithms/RGBImageToHSVChannelsFilter.h>
+
+#define ITK_MANUAL_INSTANTIATION
+#include <itkImage.h>
+#include <itkRGBPixel.h>
+
+// -------------------------------------------------------------------------
+#define cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, d, o, f )   \
+  if( dynamic_cast< itk::ImageBase< d >* >( o ) != NULL )               \
+    r = this->f< d >( )
+
+// -------------------------------------------------------------------------
+#define cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, p, d, o, f )      \
+  if(                                                                   \
+    dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL   \
+    )                                                                   \
+    r = this->f< p, d >( )
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::RGBImageToHSVChannelsFilter::
+RGBImageToHSVChannelsFilter( )
+  : Superclass( )
+{
+  this->SetNumberOfInputs( 1 );
+  this->SetNumberOfOutputs( 3 );
+  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_MakeOutput< cpPlugins::Interface::Image >( 1 );
+  this->_MakeOutput< cpPlugins::Interface::Image >( 2 );
+
+  this->m_DefaultParameters.clear( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::RGBImageToHSVChannelsFilter::
+~RGBImageToHSVChannelsFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter::
+GetClassName( ) const
+{
+  return( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" );
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter::
+_GenerateData( )
+{
+  itk::DataObject* o = this->_GetInput( 0 );
+
+  std::string r = "cpPlugins::Plugins::RGBImageToHSVChannelsFilter: itk::Image dimension not supported.";
+  cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 1, o, _GD0 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 2, o, _GD0 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 3, o, _GD0 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 4, o, _GD0 );
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int D >
+std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter::
+_GD0( )
+{
+  itk::ImageBase< D >* i =
+    dynamic_cast< itk::ImageBase< D >* >( this->_GetInput( 0 ) );
+
+  std::string r = "cpPlugins::Plugins::RGBImageToHSVChannelsFilter: itk::Image pixel type not supported";
+  cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, char, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, short, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, int, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, long, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned char, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned short, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned int, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned long, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, float, D, i, _GD1 );
+  else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, double, D, i, _GD1 );
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class P, unsigned int D >
+std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter::
+_GD1( )
+{
+  typedef itk::Image< itk::RGBPixel< P >, D > _TImage;
+  typedef itk::Image< P, D > _TChannel;
+  typedef cpPlugins::Extensions::Algorithms::
+    RGBImageToHSVChannelsFilter< _TImage, _TChannel > _TFilter;
+
+  // Filter creation
+  _TFilter* filter =
+    dynamic_cast< _TFilter* >( this->m_Filter.GetPointer( ) );
+  if( filter == NULL )
+  {
+    this->m_Filter = _TFilter::New( );
+    filter = dynamic_cast< _TFilter* >( this->m_Filter.GetPointer( ) );
+
+  } // fi
+  filter->SetInput( dynamic_cast< _TImage* >( this->_GetInput( 0 ) ) );
+  filter->Update( );
+
+  this->_SetOutput( 0, filter->GetHueOutput( ) );
+  this->_SetOutput( 1, filter->GetSaturationOutput( ) );
+  this->_SetOutput( 2, filter->GetValueOutput( ) );
+
+  return( "" );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h
new file mode 100644 (file)
index 0000000..bbe124a
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __CPPLUGINS__PLUGINS__RGBIMAGETOHSVCHANNELSFILTER__H__
+#define __CPPLUGINS__PLUGINS__RGBIMAGETOHSVCHANNELSFILTER__H__
+
+#include <cpPlugins/Plugins/cpPlugins_Export.h>
+#include <cpPlugins/Interface/ImageToImageFilter.h>
+#include <itkProcessObject.h>
+
+namespace cpPlugins
+{
+  namespace Plugins
+  {
+    /**
+     */
+    class cpPlugins_EXPORT RGBImageToHSVChannelsFilter
+      : public cpPlugins::Interface::ImageToImageFilter
+    {
+    public:
+      typedef RGBImageToHSVChannelsFilter              Self;
+      typedef cpPlugins::Interface::ImageToImageFilter Superclass;
+
+      typedef Superclass::TParameter  TParameter;
+      typedef Superclass::TParameters TParameters;
+
+    public:
+      RGBImageToHSVChannelsFilter( );
+      virtual ~RGBImageToHSVChannelsFilter( );
+
+      virtual std::string GetClassName( ) const;
+
+    protected:
+      virtual std::string _GenerateData( );
+
+      template< unsigned int D >
+      std::string _GD0( );
+
+      template< class P, unsigned int D >
+      std::string _GD1( );
+
+    protected:
+      itk::ProcessObject::Pointer m_Filter;
+    };
+
+    // ---------------------------------------------------------------------
+    PLUMA_INHERIT_PROVIDER(
+      RGBImageToHSVChannelsFilter,
+      cpPlugins::Interface::Object
+      );
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__RGBIMAGETOHSVCHANNELSFILTER__H__
+
+// eof - $RCSfile$