]> Creatis software - gdcm.git/commitdiff
Final solution (?) to embedded icone images
authorjpr <jpr>
Wed, 4 Feb 2004 08:36:06 +0000 (08:36 +0000)
committerjpr <jpr>
Wed, 4 Feb 2004 08:36:06 +0000 (08:36 +0000)
src/gdcmHeader.cxx
src/gdcmHeaderEntry.cxx
src/gdcmParser.cxx

index 5351d35b0516f2f2ac398397d4216eddb2ab47fb..6aa3cadbb240b4c22d096c4e563561b30ac4aed7 100644 (file)
@@ -60,7 +60,7 @@ gdcmHeader::gdcmHeader(const char *InFilename,
          NumPixel = 0x0010;
         
       TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
-      countGrPixel = GetEntry().count(key);       
+      countGrPixel = GetEntry().count(key);
 }
 
 /**
@@ -443,107 +443,58 @@ std::string gdcmHeader::GetPixelType(void) {
  * \brief   Recover the offset (from the beginning of the file) 
  * \        of *image* pixels (not *icone image* pixels, if any !)
  */
-size_t gdcmHeader::GetPixelOffset(void) { // TODO : move to gdcmFile
-
+size_t gdcmHeader::GetPixelOffset(void) { 
    //
    // If the element (0x0088,0x0200) 'icone image sequence' is found
    // (grPixel,numPixel) is stored twice : the first one for the icon
    // the second one for the image ...
    // pb : sometimes , (0x0088,0x0200) exists, but doesn't contain *anything*
    // see gdcmData/MxTwinLossLess.dcm ...
-   
-   
-   /*
-   guint16 grPixel = GrPixel;
-   guint16 numPixel= NumPixel;
-   std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
 
-   if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
-      grPixel = 0x7fe0;                   // default value
-   } else {
-      grPixel = (guint16) atoi( ImageLocation.c_str() );
-   }
-   
-   if (grPixel == 0xe07f) // sometimes Image Location value doesn't follow 
-      grPixel = 0x7fe0;   // the supposed processor endianity. 
-                          // see gdcmData/cr172241.dcm
-      
-   if (grPixel != 0x7fe0) 
-      // This is a kludge for old dirty Philips imager.
-      numPixel = 0x1010;
-   else
-      numPixel = 0x0010;
- */
+   //std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence
       
    IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);          
-   //std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence
    TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
    gdcmHeaderEntry* PixelElement;
-  
-   //if (tagHT.count(key) == 1)
    if (countGrPixel == 1)   
       PixelElement = (it.first)->second;
-   else
-      PixelElement = (++it.first)->second;
-   
+   else {
+      PixelElement = (++it.first)->second; // hope there are no more than 2 !
+   } 
    if (PixelElement) {
       return PixelElement->GetOffset();
-   }
-   else
+   } else {
       return 0;
+      std::cout << "Big trouble : Pixel Element ("
+                << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
+                << std::endl;  
+   }     
 }
 // TODO : unify those two (previous one and next one)
 /**
  * \ingroup gdcmHeader
  * \brief   Recover the pixel area length (in Bytes)
- *  @return 0 by default. NOT USABLE file. The caller has to check.
- */
-size_t gdcmHeader::GetPixelAreaLength(void) {
-
-/*
-   // If this file complies with the norm we should encounter the
-   // "Image Location" tag (0x0028,  0x0200). This tag contains the
-   // the group that contains the pixel data (hence the "Pixel Data"
-   // is found by indirection through the "Image Location").
-   // Inside the group pointed by "Image Location" the searched element
-   // is conventionally the element 0x0010 (when the norm is respected).
-   // When the "Image Location" is absent we default to group 0x7fe0.
-   
-
-   guint16 grPixel;
-   guint16 numPixel;   
-   std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
-   if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
-      grPixel = 0x7fe0;                   // default value
-   } else {
-      grPixel = (guint16) atoi( ImageLocation.c_str() );
-   }
-   if (grPixel == 0xe07f) // sometimes group doesn't follow 
-      grPixel = 0x7fe0;   // the supposed processor endianity. see cr172241.dcm
-      
-   if (grPixel != 0x7fe0)
-      // This is a kludge for old dirty Philips imager.
-      numPixel = 0x1010;
-   else
-      numPixel = 0x0010;
+ * @return Pixel Element Length, as stored in the header
+ *         (NOT the memory space necessary to hold the Pixels 
+ *          - in case of embeded compressed image-)
+ *         0 : NOT USABLE file. The caller has to check.
  */
-              
+size_t gdcmHeader::GetPixelAreaLength(void) { 
+          
    IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);          
-   //std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence
    TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
    gdcmHeaderEntry* PixelElement;
   
-  // if (tagHT.count(key) == 1) 
-  if (countGrPixel)  
+  if (countGrPixel==1)  
       PixelElement = (it.first)->second;
    else
       PixelElement = (++it.first)->second;
-   
-   if (PixelElement)
+
+   if (PixelElement) {
       return PixelElement->GetLength();
-   else {
+   else {
       std::cout << "Big trouble : Pixel Element ("
-                << std::hex << GrPixel<<","<< NumPixel<< ") NOT found" 
+                << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
                 << std::endl;
       return 0;
    }
index 0185b9157ce0844e180d81b6b669043a9b9d075b..3c2ffaf7601f9e34827341f62d141efd174348b2 100644 (file)
@@ -14,7 +14,7 @@
 #include <iomanip> // for std::ios::left, ...
 
 
-#define MAX_SIZE_PRINT_ELEMENT_VALUE 10000
+#define MAX_SIZE_PRINT_ELEMENT_VALUE 64
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
index 178a7534a3a8cb5668600dd82412d39b60346d28..7f6384f85edb59a4aa795a984ceface39f445775 100644 (file)
@@ -1769,7 +1769,7 @@ void gdcmParser::FixHeaderEntryFoundLength(gdcmHeaderEntry *Entry, guint32 Found
      
    if (FoundLength%2) {
       std::cout << "Warning : Tag with uneven length " << FoundLength 
-         <<  "in x(" << std::hex << gr << "," << el <<")" << std::endl;
+         <<  " in x(" << std::hex << gr << "," << el <<")" << std::endl;
    }
       
    // Sorry for the patch!