]> Creatis software - gdcm.git/commitdiff
*ENH: vtkgdcmViewer now works with LUT dicom (OT-PAL-face ...)
authormalaterre <malaterre>
Thu, 6 Nov 2003 14:14:10 +0000 (14:14 +0000)
committermalaterre <malaterre>
Thu, 6 Nov 2003 14:14:10 +0000 (14:14 +0000)
vtk/vtkGdcmReader.cxx
vtk/vtkgdcmViewer.cxx

index 64750a0da01e20a3dd22a96bf08c670fc8e47c68..83ec322f16dcbb769f4379aa18cf23161182a32a 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.25 2003/11/05 18:15:41 malaterre Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.26 2003/11/06 14:14:10 malaterre Exp $
 // //////////////////////////////////////////////////////////////
 // WARNING TODO CLENAME 
 // Actual limitations of this code:
@@ -54,7 +54,7 @@
 vtkGdcmReader::vtkGdcmReader()
 {
   // Constructor
-  this->LookupTable = vtkLookupTable::New();
+  this->LookupTable = NULL;
 }
 
 //----------------------------------------------------------------------------
@@ -62,7 +62,7 @@ vtkGdcmReader::~vtkGdcmReader()
 { 
   this->RemoveAllFileName();
   this->InternalFileNameList.clear();
-  this->LookupTable->Delete();
+  if(this->LookupTable) this->LookupTable->Delete();
 }
 
 //----------------------------------------------------------------------------
@@ -480,7 +480,8 @@ size_t vtkGdcmReader::LoadImageInMemory(
     size               = GdcmFile.GetImageDataSizeRaw();
     Source             = (unsigned char*) GdcmFile.GetImageDataRaw();
     unsigned char *Lut = (unsigned char*) GdcmFile.GetLUTRGBA();
-
+  
+    if(!this->LookupTable) this->LookupTable = vtkLookupTable::New();
     this->LookupTable->SetNumberOfTableValues(256);
     for (int tmp=0; tmp<256; tmp++)
       {
index 97f305cec343c08b892460214ca0898efa9fd1a1..ce5afd62a67c1d0bfcf2ba5033c2e9b3df13df04 100644 (file)
@@ -4,6 +4,8 @@
 #include <vtkStructuredPointsWriter.h>
 #include <vtkCommand.h>
 #include <vtkRenderer.h>
+#include <vtkImageMapToColors.h>
+#include <vtkLookupTable.h>
 
 #include "vtkGdcmReader.h"
 
@@ -59,7 +61,20 @@ int main(int argc, char *argv[])
   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
 
   vtkImageViewer2 *viewer = vtkImageViewer2::New();
-  viewer->SetInput ( reader->GetOutput() );
+  if( reader->GetLookupTable() )
+  {
+    //convert to color:
+    vtkImageMapToColors *map = vtkImageMapToColors::New ();
+    map->SetInput (reader->GetOutput());
+    map->SetLookupTable (reader->GetLookupTable());
+    map->SetOutputFormatToRGB();
+    viewer->SetInput ( map->GetOutput() );
+    map->Delete();
+  }
+  else
+  {
+    viewer->SetInput ( reader->GetOutput() );
+  }
   viewer->SetupInteractor (iren);
   
 //  float *range = reader->GetOutput()->GetScalarRange();