X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkDicomRTDoseIO.cxx;h=88e1289351a2badbd15979a7e634aa9849192ed9;hb=1dfeba065d7121eb27aa44a792095af817652683;hp=02d953e3a74eebadba37025b7d510f8257691437;hpb=495aeaf7af1cb34b0a87edf7f8de51440e0c2236;p=clitk.git diff --git a/common/clitkDicomRTDoseIO.cxx b/common/clitkDicomRTDoseIO.cxx index 02d953e..88e1289 100644 --- a/common/clitkDicomRTDoseIO.cxx +++ b/common/clitkDicomRTDoseIO.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ // clitk include #include "clitkDicomRTDoseIO.h" @@ -22,6 +22,10 @@ // itk include #if GDCM_MAJOR_VERSION == 2 +// IMPLEMENTATION NOTE: +// The following has been done without the use of vtkGDCMImageReader which directly +// handle RTDOSE image. Another approach would have been to use gdcm::ImageReader +// which also properly recognize RTDOSE #include #include #else @@ -147,7 +151,7 @@ void clitk::DicomRTDoseIO::ReadImageInformation() while (1) { int len; gfov = (double*) realloc (gfov, (gfov_len + 1) * sizeof(double)); - rc = sscanf (gfov_str, "%g%n", &gfov[gfov_len], &len); + rc = sscanf (gfov_str, "%lf%n", &gfov[gfov_len], &len); if (rc != 1) { break; } @@ -277,7 +281,28 @@ void clitk::DicomRTDoseIO::Read(void * buffer) /* PixelData */ #if GDCM_MAJOR_VERSION == 2 gdcm::Image &i = m_GdcmImageReader.GetImage(); - i.GetBuffer((char*)buffer); + + char* image_data = new char[i.GetBufferLength()]; + i.GetBuffer(image_data); + + gdcm::DataSet& ds = m_GdcmImageReader.GetFile().GetDataSet(); + float *img = (float*) buffer; + + gdcm::Attribute<0x28, 0x100> pixel_size; + pixel_size.SetFromDataSet(ds); + if (pixel_size.GetValue() == 16) { + unsigned short* image_data2 = (unsigned short*) image_data ; + dose_copy_raw (img, image_data2, npix, m_DoseScaling); + } + else if (pixel_size.GetValue() == 32) { + unsigned long* image_data2 = (unsigned long*) image_data; + dose_copy_raw (img, image_data2, npix, m_DoseScaling); + } else { + itkExceptionMacro(<< "Error RTDOSE not type 16U and 32U (type=" + << pixel_size.GetValue() << ")"); + } + + delete [] image_data; #else float *img = (float*) buffer;