]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx
yet another refactoring
[cpPlugins.git] / lib / cpExtensions / Algorithms / RGBImageToOtherChannelsFilter.hxx
diff --git a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx
new file mode 100644 (file)
index 0000000..74578d4
--- /dev/null
@@ -0,0 +1,71 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__
+#define __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__
+
+#include <cmath>
+#include <limits>
+#include <vnl/vnl_math.h>
+
+#include <itkImageRegionIterator.h>
+#include <itkImageRegionConstIterator.h>
+
+// -------------------------------------------------------------------------
+template< class I, class O, class C >
+cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
+RGBImageToOtherChannelsFilter( )
+  : Superclass( )
+{
+  this->SetNumberOfRequiredInputs( 1 );
+  this->SetNumberOfRequiredOutputs( 1 );
+
+  typename O::Pointer o = O::New( );
+  this->SetNthOutput( 0, o );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O, class C >
+cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
+~RGBImageToOtherChannelsFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O, class C >
+void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
+BeforeThreadedGenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O, class C >
+void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
+AfterThreadedGenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O, class C >
+void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
+ThreadedGenerateData(
+  const typename Superclass::OutputImageRegionType& region,
+  itk::ThreadIdType threadId
+  )
+{
+  // typedef typename TInputPixel::ComponentType _TComponent;
+  typedef itk::ImageRegionConstIterator< I > _TInIt;
+  typedef itk::ImageRegionIterator< O >      _TOutIt;
+
+  _TInIt inIt( this->GetInput( ), region );
+  _TOutIt outIt( this->GetOutput( ), region );
+  inIt.GoToBegin( );
+  outIt.GoToBegin( );
+  for( ; !inIt.IsAtEnd( ); ++inIt, ++outIt )
+    outIt.Set( this->Converter( inIt.Get( ) ) );
+}
+
+#endif // __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__
+
+// eof - $RCSfile$