]> Creatis software - gdcm.git/commitdiff
* vtkGdcmReader is now able to read rgb dicom file.
authormalaterre <malaterre>
Fri, 3 Oct 2003 14:48:31 +0000 (14:48 +0000)
committermalaterre <malaterre>
Fri, 3 Oct 2003 14:48:31 +0000 (14:48 +0000)
* src/gdcmHeaderHelper : GetNumberOfScalarComponents()

ChangeLog
vtk/vtkGdcmReader.cxx
vtk/vtkGdcmReader.h

index e0734ce2f38bdfe5296827ac9e131388f31dc3a8..1bf2e060473c4144303f89126dbb01bae0adf7e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2003-10-03  Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
+      * vtkGdcmReader is now able to read rgb dicom file.
+      * src/gdcmHeaderHelper : GetNumberOfScalarComponents()
 2003-10-02  Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
       * src/*.cxx removed pragma thingies to src/gdcmCommon.h
         Two reasons: - clear things
index 898245c60c79a90bbdd7873cec5b2855da783bd6..22947c87d4a5563ab2b3b08910c9a0834c06cec1 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.19 2003/09/10 09:31:55 malaterre Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.cxx,v 1.20 2003/10/03 14:48:31 malaterre Exp $
 // //////////////////////////////////////////////////////////////
 // WARNING TODO CLENAME 
 // Actual limitations of this code:
@@ -296,6 +296,7 @@ int vtkGdcmReader::CheckFileCoherence()
        ReturnedTotalNumberOfPlanes += NZ - 1; // First plane already added
        this->ImageType = type;
        this->PixelSize = GdcmHeader.GetPixelSize();
+       this->NumComponents = GdcmHeader.GetNumberOfScalarComponents(); //rgb or mono
        
        //Set image spacing
        this->DataSpacing[0] = GdcmHeader.GetXSpacing();
@@ -423,6 +424,9 @@ void vtkGdcmReader::ExecuteInformation()
     this->SetDataScalarTypeToInt();
     }
 
+  //Set number of scalar components:
+  this->SetNumberOfScalarComponents(this->NumComponents);
+
   vtkImageReader::ExecuteInformation();
 }
 
@@ -448,7 +452,7 @@ size_t vtkGdcmReader::LoadImageInMemory(
   int NumColumns = GdcmFile.GetXSize();
   int NumLines   = GdcmFile.GetYSize();
   int NumPlanes  = GdcmFile.GetZSize();
-  int LineSize   = NumColumns * GdcmFile.GetPixelSize();
+  int LineSize   = NumComponents * NumColumns * GdcmFile.GetPixelSize();
   unsigned char * Source      = (unsigned char*)GdcmFile.GetImageData();
   unsigned char * pSource     = Source; //pointer for later deletion
   unsigned char * Destination = Dest + size - LineSize;
@@ -503,7 +507,7 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
     // The memory size for a full stack of images of course depends
     // on the number of planes and the size of each image:
     size_t StackNumPixels = this->NumColumns * this->NumLines
-                          * this->TotalNumberOfPlanes;
+                          * this->TotalNumberOfPlanes * this->NumComponents;
     size_t stack_size = StackNumPixels * this->PixelSize;
     // Allocate pixel data space itself.
     unsigned char *mem = new unsigned char [stack_size];
index 284090c9a71041daa45a359b5c5dec0a5bfdcfc4..6c1507b6edaf26328fc4b51b6871d389b7a2b49e 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.h,v 1.9 2003/07/07 10:06:36 regrain Exp $
+// $Header: /cvs/public/gdcm/vtk/vtkGdcmReader.h,v 1.10 2003/10/03 14:48:31 malaterre Exp $
 
 #ifndef __vtkGdcmReader_h
 #define __vtkGdcmReader_h
@@ -37,6 +37,8 @@ private:
   int NumLines;
   // Total number of planes (or images) of the stack to be build.
   int TotalNumberOfPlanes;
+  // Number of scalar components of the image to be loaded (1=monochrome 3=rgb)
+  int NumComponents;
   // Type of the image[s]: 8/16/32 bits, signed/unsigned:
   std::string ImageType;
   // Pixel size (in number of bytes):