From e59e2d83d86f77f608f6620fca3cf77e5e21d201 Mon Sep 17 00:00:00 2001 From: malaterre Date: Thu, 6 Nov 2003 14:14:10 +0000 Subject: [PATCH] *ENH: vtkgdcmViewer now works with LUT dicom (OT-PAL-face ...) --- vtk/vtkGdcmReader.cxx | 9 +++++---- vtk/vtkgdcmViewer.cxx | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index 64750a0d..83ec322f 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -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++) { diff --git a/vtk/vtkgdcmViewer.cxx b/vtk/vtkgdcmViewer.cxx index 97f305ce..ce5afd62 100644 --- a/vtk/vtkgdcmViewer.cxx +++ b/vtk/vtkgdcmViewer.cxx @@ -4,6 +4,8 @@ #include #include #include +#include +#include #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(); -- 2.48.1