From: malaterre Date: Fri, 3 Oct 2003 14:48:31 +0000 (+0000) Subject: * vtkGdcmReader is now able to read rgb dicom file. X-Git-Tag: Version0.3.1~135 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a98b837248a1f05b056fe347d606d6b1540d40a3;p=gdcm.git * vtkGdcmReader is now able to read rgb dicom file. * src/gdcmHeaderHelper : GetNumberOfScalarComponents() --- diff --git a/ChangeLog b/ChangeLog index e0734ce2..1bf2e060 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2003-10-03 Mathieu Malaterre + * vtkGdcmReader is now able to read rgb dicom file. + * src/gdcmHeaderHelper : GetNumberOfScalarComponents() 2003-10-02 Mathieu Malaterre * src/*.cxx removed pragma thingies to src/gdcmCommon.h Two reasons: - clear things diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index 898245c6..22947c87 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -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]; diff --git a/vtk/vtkGdcmReader.h b/vtk/vtkGdcmReader.h index 284090c9..6c1507b6 100644 --- a/vtk/vtkGdcmReader.h +++ b/vtk/vtkGdcmReader.h @@ -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):