From: jpr Date: Wed, 12 Mar 2003 13:09:00 +0000 (+0000) Subject: POur traiter certaines (?) images Philips pour lesquelles le File Preamble X-Git-Tag: April2003~25 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b6c826571b5f85de9256b0973df29e916c40d243;p=gdcm.git POur traiter certaines (?) images Philips pour lesquelles le File Preamble est suivi de l'elem (0002,0001) et non pas de l'elem (0002,0000) -pas d'autre possibilité envisageable ...- Peut-etre --- diff --git a/src/Makefile.am b/src/Makefile.am index c5506f18..ec064d88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,8 @@ libgdcm_la_SOURCES= \ gdcmDictSet.cxx \ gdcmElValSet.cxx \ gdcmHeaderIdo.cxx \ - gdcmFile.cxx + gdcmFile.cxx \ + gdcmJpeg.cxx libgdcmincludedir = $(includedir) libgdcminclude_HEADERS = \ @@ -34,4 +35,5 @@ libgdcminclude_HEADERS = \ gdcm.h \ gdcmException.h \ gdcmIdo.h \ - gdcmUtil.h + gdcmUtil.h \ + iddcmjpeg.h diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 231b5bc4..37b2e1ec 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -13,6 +13,8 @@ #include "gdcmUtil.h" #include "gdcmHeader.h" +#include + // Refer to gdcmHeader::CheckSwap() #define HEADER_LENGTH_TO_READ 256 // Refer to gdcmHeader::SetMaxSizeLoadElementValue() @@ -128,8 +130,9 @@ void gdcmHeader::CheckSwap() if(filetype == TrueDicom) { // Next, determine the value representation (VR). Let's skip to the - // first element (0002, 0000) and check there if we find "UL", in - // which case we (almost) know it is explicit VR. + // first element (0002, 0000) and check there if we find "UL" + // - or "OB" if the 1st one is (0002,0001) -, + // in which case we (almost) know it is explicit VR. // WARNING: if it happens to be implicit VR then what we will read // is the length of the group. If this ascii representation of this // length happens to be "UL" then we shall believe it is explicit VR. @@ -139,10 +142,12 @@ void gdcmHeader::CheckSwap() // We need to skip : // * the 128 bytes of File Preamble (often padded with zeroes), // * the 4 bytes of "DICM" string, - // * the 4 bytes of the first tag (0002, 0000), + // * the 4 bytes of the first tag (0002, 0000),or (0002, 0001) // i.e. a total of 136 bytes. entCur = deb + 136; - if(memcmp(entCur, "UL", (size_t)2) == 0) { + if( (memcmp(entCur, "UL", (size_t)2) == 0) || + (memcmp(entCur, "OB", (size_t)2) == 0) ) + { filetype = ExplicitVR; dbg.Verbose(1, "gdcmHeader::CheckSwap:", "explicit Value Representation"); @@ -241,7 +246,11 @@ void gdcmHeader::GetPixels(size_t lgrTotale, void* _Pixels) { size_t pixelsOffset; pixelsOffset = GetPixelOffset(); fseek(fp, pixelsOffset, SEEK_SET); - fread(_Pixels, 1, lgrTotale, fp); + if (IsJPEGLossless()) { + _Pixels=_IdDcmJpegRead(fp); + } else { + fread(_Pixels, 1, lgrTotale, fp); + } } @@ -286,7 +295,7 @@ void gdcmHeader::FindVR( ElValue *ElVal) { // PostPone this test in an optional integrity check at the end // of parsing or only in debug mode. if ( RealExplicit && !dicom_vr->count(vr) ) - RealExplicit = false; + RealExplicit= false; if ( RealExplicit ) { if ( ElVal->IsVrUnknown() ) { @@ -393,7 +402,7 @@ bool gdcmHeader::IsExplicitVRBigEndianTransferSyntax(void) { return false; LoadElementValueSafe(Element); string Transfer = Element->GetValue(); - if ( Transfer == "1.2.840.10008.1.2.2" ) + if ( Transfer == "1.2.840.10008.1.2.2" ) //1.2.2 ??? A verifier ! return true; return false; } @@ -416,6 +425,20 @@ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) { return false; } +// faire qq chose d'intelligent a la place de ça + +bool gdcmHeader::IsJPEGLossless(void) { + ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010); + if ( !Element ) + return false; + LoadElementValueSafe(Element); + const char * Transfert = Element->GetValue().c_str(); + if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true; + if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true; + return false; +} + + /** * \ingroup gdcmHeader * \brief Determines if the Transfer Syntax was allready encountered diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 02c58ef6..fa33ebc8 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -105,6 +105,8 @@ private: bool IsJPEGExtendedProcess2_4TransferSyntax(void); bool IsJPEGExtendedProcess3_5TransferSyntax(void); bool IsJPEGSpectralSelectionProcess6_8TransferSyntax(void); + + bool IsJPEGLossless(void); protected: // FIXME: is this enum still necessary ??