From: jpr Date: Wed, 23 Jun 2004 09:30:22 +0000 (+0000) Subject: gdcmDocument.cxx X-Git-Tag: Version0.5.bp~110 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;ds=sidebyside;h=934741ba56fd719a775e93cc93616c25b3d10901;p=gdcm.git gdcmDocument.cxx - Now we do recognize the JpegLossLess format (there was a misstyping in code 'beautyfication' :-( - Now we automaticaticaly load the Luts, if any --- diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 550443d8..43f9b0a1 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/06/22 15:31:17 $ - Version: $Revision: 1.25 $ + Date: $Date: 2004/06/23 09:30:22 $ + Version: $Revision: 1.26 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -126,6 +126,25 @@ gdcmDocument::gdcmDocument(std::string const & inFilename, long l=ParseDES( this, beg, lgt, false); // le Load sera fait a la volee (void)l; //is l used anywhere ? + + rewind(fp); + + // Load 'non string' values + + std::string PhotometricInterpretation = GetEntryByNumber(0x0028,0x0004); + if( PhotometricInterpretation == "PALETTE COLOR " ) { + LoadEntryVoidArea(0x0028,0x1200); // gray LUT + LoadEntryVoidArea(0x0028,0x1201); // R LUT + LoadEntryVoidArea(0x0028,0x1202); // G LUT + LoadEntryVoidArea(0x0028,0x1203); // B LUT + + LoadEntryVoidArea(0x0028,0x1221); // Segmented Red Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1222); // Segmented Green Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1223); // Segmented Blue Palette Color LUT Data + } + //FIXME later : how to use it? + LoadEntryVoidArea(0x0028,0x3006); //LUT Data (CTX dependent) + CloseFile(); // -------------------------------------------------------------- @@ -390,11 +409,12 @@ bool gdcmDocument::IsRLELossLessTransferSyntax(void) * @return True when RLE Lossless found. False in all * other cases. */ + bool gdcmDocument::IsJPEGLossless(void) { return ( IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_55) || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_57) - || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_90) ); + || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_70) ); // was 90 } /** @@ -1349,7 +1369,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry *Entry) // to be sure we are at the end of the value ... fseek(fp,(long)Entry->GetOffset()+(long)Entry->GetLength(),SEEK_SET); return; - // Be carefull : a BinEntry IS_A valEntry ... + // Be carefull : a BinEntry IS_A ValEntry ... if (gdcmValEntry* ValEntryPtr = dynamic_cast< gdcmValEntry* >(Entry) ) { std::ostringstream s; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 97797c86..bd35f100 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/06/23 03:36:24 $ - Version: $Revision: 1.107 $ + Date: $Date: 2004/06/23 09:30:22 $ + Version: $Revision: 1.108 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -237,7 +237,8 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { // from Lut R + Lut G + Lut B unsigned char *newDest = new unsigned char[lgrTotale]; unsigned char *a = (unsigned char *)destination; - unsigned char *lutRGBA = Header->GetLUTRGBA(); + unsigned char *lutRGBA = Header->GetLUTRGBA(); + if (lutRGBA) { int l = lgrTotaleRaw; memmove(newDest, destination, l);// move Gray pixels to temp area @@ -264,8 +265,8 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { } else { // need to make RGB Pixels (?) - // from grey Pixels (?!) - // and Gray Lut (!?!) + // from grey Pixels (?!) + // and Gray Lut (!?!) // or Segmented xxx Palette Color Lookup Table Data and so on // Oops! I get one (gdcm-US-ALOKA-16.dcm) @@ -911,7 +912,7 @@ bool gdcmFile::ReadPixelData(void *destination) { bool jpg2000 = Header->IsJPEG2000(); bool jpgLossless = Header->IsJPEGLossless(); - + bool res = true; guint16 ItemTagGr,ItemTagEl; int ln; @@ -959,7 +960,6 @@ bool gdcmFile::ReadPixelData(void *destination) { } // ------------------------------------- endif (JPEG2000) else if (jpgLossless) { // JPEG LossLess : call to xmedcom JPEG - JPEGLosslessDecodeImage (fp, // Reading Fragment pixels (unsigned short *)destination, Header->GetPixelSize() * 8 * Header->GetSamplesPerPixel(), diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index aa808aeb..9a3e9cf5 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2004/06/23 03:36:24 $ - Version: $Revision: 1.168 $ + Date: $Date: 2004/06/23 09:30:22 $ + Version: $Revision: 1.169 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,14 +41,7 @@ gdcmHeader::gdcmHeader(std::string const & filename, bool enable_sequences, bool ignore_shadow): gdcmDocument(filename,exception_on_error,enable_sequences,ignore_shadow) -{ -/* - typedef struct { - guint32 totalSQlength; - guint32 alreadyParsedlength; - } pileElem; -*/ - +{ // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 // We may encounter the 'RETired' (0x0028, 0x0200) tag // (Image Location") . This Element contains the number of @@ -144,7 +137,7 @@ int gdcmHeader::GetXSize() { * \brief Retrieve the number of lines of image. * \warning The defaulted value is 1 as opposed to gdcmHeader::GetXSize() * @return The encountered size when found, 1 by default - * (The ACR-MEMA file contains a Signal, not an Image). + * (The ACR-NEMA file contains a Signal, not an Image). */ int gdcmHeader::GetYSize() { std::string StrSize = GetEntryByNumber(0x0028,0x0010); @@ -841,7 +834,7 @@ unsigned char * gdcmHeader::GetLUTRGBA() { // http://www.barre.nom.fr/medical/dicom2/limitations.html#Color%20Lookup%20Tables // if Photometric Interpretation # PALETTE COLOR, no LUT to be done - if (GetEntryByNumber(0x0028,0x0004) != "PALETTE COLOR ") { + if (GetEntryByNumber(0x0028,0x0004) != "PALETTE COLOR ") { return NULL; } int lengthR, debR, nbitsR; @@ -859,7 +852,7 @@ unsigned char * gdcmHeader::GetLUTRGBA() { std::string LutDescriptionB = GetEntryByNumber(0x0028,0x1103); if (LutDescriptionB == GDCM_UNFOUND) return NULL; - + std::vector tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value @@ -890,7 +883,7 @@ unsigned char * gdcmHeader::GetLUTRGBA() { GetEntryVoidAreaByNumber(0x0028,0x1202); unsigned char *lutB = (unsigned char *) GetEntryVoidAreaByNumber(0x0028,0x1203); - + if (!lutR || !lutG || !lutB ) { return NULL; }