From f8e5982fc2d53058d72b5c96e8f4f53faf9a37d7 Mon Sep 17 00:00:00 2001 From: jpr Date: Fri, 3 Oct 2003 14:26:11 +0000 Subject: [PATCH] gdcmHeaderHelper::GetNumberOfScalarComponents() added, to allow displaying RGB images (not only by affim ;-) --- src/gdcmFile.cxx | 12 ++++++------ src/gdcmHeaderHelper.cxx | 22 +++++++++++++++++++++- src/gdcmHeaderHelper.h | 7 +++++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 1051765f..88dcdf6a 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -426,14 +426,14 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { return (size_t)0; } } + // Just to 'see' was was actually read on disk :-( // Some troubles expected -//FILE * fpSpurious; -//fpSpurious=fopen("SpuriousFile.raw","w"); -//fwrite(destination,lgrTotale, 1,fpSpurious); -//fclose(fpSpurious); - +FILE * fpSpurious; +fpSpurious=fopen("SpuriousFile.raw","w"); +fwrite(destination,lgrTotale, 1,fpSpurious); +fclose(fpSpurious); // *Try* to deal with the color @@ -444,7 +444,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { // Planar configuration = 2 : 1 gray Plane + 3 LUT // Well ... supposed to be ! - // See US-PAL-8-10x-echo.dcm, PlanarConfiguration=0,PhotometricInterpretation=PALETTE COLOR + // See US-PAL-8-10x-echo.dcm: PlanarConfiguration=0,PhotometricInterpretation=PALETTE COLOR // and heuristic has to be found :-( std::string str_PhotometricInterpretation = gdcmHeader::GetPubElValByNumber(0x0028,0x0004); diff --git a/src/gdcmHeaderHelper.cxx b/src/gdcmHeaderHelper.cxx index 35088039..cb4b3559 100644 --- a/src/gdcmHeaderHelper.cxx +++ b/src/gdcmHeaderHelper.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.9 2003/10/02 11:26:16 malaterre Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.10 2003/10/03 14:26:11 jpr Exp $ #include "gdcmHeaderHelper.h" @@ -89,6 +89,26 @@ int gdcmHeaderHelper::GetPixelSize() { dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type"); return 0; } + +//---------------------------------------------------------------------------- +/** + * \ingroup gdcmHeaderHelper + * \brief gets the info from 0028,0004 : Photometric Interp + * \ else 1. + * @return 1 if Gray level, 3 if Color + */ +int gdcmHeaderHelper::GetNumberOfScalarComponents() { + std::string PhotometricInterpretation = + gdcmHeader::GetPubElValByNumber(0x0028,0x0004); + +// The compiler will optimze, if it feels like ! + + if (PhotometricInterpretation == GDCM_UNFOUND) return 1; + if (PhotometricInterpretation == "MONOCHROME1") return 1; + if (PhotometricInterpretation == "MONOCHROME2") return 1; + + return 3; +} //---------------------------------------------------------------------------- /** * \ingroup gdcmHeaderHelper diff --git a/src/gdcmHeaderHelper.h b/src/gdcmHeaderHelper.h index ab5807c6..06455a49 100644 --- a/src/gdcmHeaderHelper.h +++ b/src/gdcmHeaderHelper.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.h,v 1.3 2003/09/11 13:44:17 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.h,v 1.4 2003/10/03 14:26:11 jpr Exp $ #ifndef GDCMHEADERHELPER_H #define GDCMHEADERHELPER_H @@ -76,7 +76,9 @@ public: float GetXSpacing(); float GetYSpacing(); float GetZSpacing(); - + + int GetNumberOfScalarComponents(); + std::string GetStudyUID(); std::string GetSeriesUID(); std::string GetClassUID(); @@ -96,6 +98,7 @@ public: ModalityType GetModality(); void GetImageOrientationPatient( float* iop ); + }; -- 2.45.1