]> Creatis software - creaMaracasVisu.git/blobdiff - lib/Kernel/ITKVTK/itkvtkcolortransferfunction.txx
addition of files
[creaMaracasVisu.git] / lib / Kernel / ITKVTK / itkvtkcolortransferfunction.txx
diff --git a/lib/Kernel/ITKVTK/itkvtkcolortransferfunction.txx b/lib/Kernel/ITKVTK/itkvtkcolortransferfunction.txx
new file mode 100644 (file)
index 0000000..e3e044e
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef ITKVTKCOLORTRANSFERFUNCTION_TXX
+#define ITKVTKCOLORTRANSFERFUNCTION_TXX
+
+namespace itk{
+
+
+template< class TypeImage>
+VTKColorTransferFunction<TypeImage>::VTKColorTransferFunction()
+{
+
+}
+
+template< class TypeImage>
+VTKColorTransferFunction<TypeImage>::~VTKColorTransferFunction()
+{
+    m_Output->Delete();
+}
+
+template< class TypeImage>
+void VTKColorTransferFunction<TypeImage>::Update(){
+    GenerateOutputInformation();
+    GenerateData();
+}
+
+template< class TypeImage>
+void VTKColorTransferFunction<TypeImage>::GenerateOutputInformation(){
+     m_Output = vtkColorTransferFunction::New();
+}
+
+
+
+template< class TypeImage>
+void VTKColorTransferFunction<TypeImage>::GenerateData(){
+
+
+
+    InputImagePointerType imagergb = this->GetInput();
+
+    if(!imagergb){
+        itkExceptionMacro(<<"Set the image first!");
+    }
+
+
+    typedef itk::ImageRegionConstIterator< InputImageType > rgbiteratorType;
+    rgbiteratorType rgbit(imagergb, imagergb->GetLargestPossibleRegion());
+
+
+    rgbit.GoToBegin();
+
+
+    m_Output->RemoveAllPoints ();
+
+
+    while(!rgbit.IsAtEnd()){
+
+
+        typename InputImageType::PixelType::ComponentType lum = 0.299*rgbit.Get()[0] + 0.587*rgbit.Get()[1] + 0.114*rgbit.Get()[2];
+
+        m_Output->AddRGBPoint(lum, rgbit.Get()[0]/255.0, rgbit.Get()[1]/255.0, rgbit.Get()[2]/255.0);
+
+        ++rgbit;        
+
+    }
+
+
+
+
+}
+
+}
+#endif