]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h
New pixel converter
[cpPlugins.git] / lib / cpPlugins / Extensions / Algorithms / RGBToRGBFunction.h
diff --git a/lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h b/lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h
new file mode 100644 (file)
index 0000000..177eee5
--- /dev/null
@@ -0,0 +1,55 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__
+#define __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__
+
+#include <itkRGBPixel.h>
+#include <itkMatrix.h>
+#include <itkVector.h>
+
+namespace cpPlugins
+{
+  namespace Extensions
+  {
+    namespace Algorithms
+    {
+      /**
+       */
+      template< class O >
+      struct RGBToRGBFunction
+      {
+        typedef RGBToRGBFunction  Self;
+        typedef itk::Vector< O, 3 > TOutPixel;
+
+        template< class Tr, class Tg, class Tb >
+        TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const
+          {
+            TOutPixel rgb;
+            rgb[ 0 ] = O( r );
+            rgb[ 1 ] = O( g );
+            rgb[ 2 ] = O( b );
+            return( rgb );
+          }
+
+        template< class C >
+        TOutPixel operator()( const itk::RGBPixel< C >& rgb ) const
+          {
+            return(
+              this->operator()(
+                rgb.GetRed( ), rgb.GetGreen( ), rgb.GetBlue( )
+                )
+              );
+          }
+      };
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__
+
+// eof - $RCSfile$