]> Creatis software - gdcm.git/blobdiff - src/gdcmHeader.cxx
ENH: Move the old setup.py to its new home
[gdcm.git] / src / gdcmHeader.cxx
index 383deaa5f36ebfcee1d341a5b09663cb1b94489d..a623626f2efae27c0645295f9543749ec735acb6 100644 (file)
@@ -3,12 +3,12 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/02 16:42:14 $
-  Version:   $Revision: 1.182 $
+  Date:      $Date: 2004/10/10 00:42:54 $
+  Version:   $Revision: 1.192 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
-  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
                                                                                 
      This software is distributed WITHOUT ANY WARRANTY; without even
      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
@@ -84,7 +84,6 @@ gdcmHeader::gdcmHeader()
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Canonical destructor.
  */
 gdcmHeader::~gdcmHeader ()
@@ -108,22 +107,20 @@ void gdcmHeader::Write(FILE* fp,FileType filetype)
       SetEntryByNumber("16", 0x0028,0x0100);
    }
 
-  // correct Pixel group Length if necessary
-
-   // TODO : create a gdcmHeader::Write method and move this part.
-   //        (only gdcmHeader knows GrPixel, NumPixel)
+  /// \todo correct 'Pixel group' Length if necessary
 
    int i_lgPix = GetEntryLengthByNumber(GrPixel, NumPixel);
    if (i_lgPix != -2)
    {
       // no (GrPixel, NumPixel) element
-      char* dumm = new char[20];
-      sprintf(dumm ,"%d", i_lgPix+12);
-      std::string s_lgPix = dumm;
-      delete[] dumm;
+      std::string s_lgPix;
+      s_lgPix = gdcmUtil::Format("%d", i_lgPix+12);
       ReplaceOrCreateByNumber(s_lgPix,GrPixel, 0x0000);
    }
-  
+
+   // FIXME : should be nice if we could move it to gdcmFile
+   //         (or in future gdcmPixelData class)
+
    // Drop Palette Color, if necessary
    
    if ( GetEntryByNumber(0x0028,0x0002).c_str()[0] == '3' )
@@ -135,32 +132,32 @@ void gdcmHeader::Write(FILE* fp,FileType filetype)
       gdcmDocEntry* e = GetDocEntryByNumber(0x0028,0x01101);
       if (e)
       {
-         RemoveEntry(e);
+         RemoveEntryNoDestroy(e);
       }
       e = GetDocEntryByNumber(0x0028,0x1102);
       if (e)
       {
-         RemoveEntry(e);
+         RemoveEntryNoDestroy(e);
       }
       e = GetDocEntryByNumber(0x0028,0x1103);
       if (e)
       {
-         RemoveEntry(e);
+         RemoveEntryNoDestroy(e);
       }
       e = GetDocEntryByNumber(0x0028,0x01201);
       if (e)
       {
-         RemoveEntry(e);
+         RemoveEntryNoDestroy(e);
       }
       e = GetDocEntryByNumber(0x0028,0x1202);
       if (e)
       {
-         RemoveEntry(e);
+         RemoveEntryNoDestroy(e);
       }
       e = GetDocEntryByNumber(0x0028,0x1203);
       if (e)
       {
-          RemoveEntry(e);
+          RemoveEntryNoDestroy(e);
       }
    }
    gdcmDocument::Write(fp,filetype);
@@ -231,7 +228,6 @@ int gdcmHeader::GetXSize()
 }
 
 /**
- * \ingroup gdcmHeader
  * \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 
@@ -255,7 +251,6 @@ int gdcmHeader::GetYSize()
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Retrieve the number of planes of volume or the number
  *          of frames of a multiframe.
  * \warning When present we consider the "Number of Frames" as the third
@@ -284,7 +279,6 @@ int gdcmHeader::GetZSize()
 }
 
 /**
-  * \ingroup gdcmHeader
   * \brief gets the info from 0028,0030 : Pixel Spacing
   *             else 1.0
   * @return X dimension of a pixel
@@ -321,7 +315,6 @@ float gdcmHeader::GetXSpacing()
 }
 
 /**
-  * \ingroup gdcmHeader
   * \brief gets the info from 0028,0030 : Pixel Spacing
   *             else 1.0
   * @return Y dimension of a pixel
@@ -344,12 +337,11 @@ float gdcmHeader::GetYSpacing()
 } 
 
 /**
-  *\ingroup gdcmHeader
-  *\brief gets the info from 0018,0088 : Space Between Slices
-  *                else from 0018,0050 : Slice Thickness
-   *                else 1.0
-  * @return Z dimension of a voxel-to be
-  */
+ * \brief gets the info from 0018,0088 : Space Between Slices
+ *                else from 0018,0050 : Slice Thickness
+ *                else 1.0
+ * @return Z dimension of a voxel-to be
+ */
 float gdcmHeader::GetZSpacing()
 {
    // Spacing Between Slices : distance entre le milieu de chaque coupe
@@ -388,20 +380,21 @@ float gdcmHeader::GetZSpacing()
 }
 
 /**
-  *\ingroup gdcmHeader
-  *\brief gets the info from 0028,1052 : Rescale Intercept
-  * @return Rescale Intercept
+ *\brief gets the info from 0028,1052 : Rescale Intercept
+ * @return Rescale Intercept
  */
 float gdcmHeader::GetRescaleIntercept()
 {
    float resInter = 0.;
-   std::string strRescInter = GetEntryByNumber(0x0028,0x1052); //0028 1052 DS IMG Rescale Intercept
+   /// 0028 1052 DS IMG Rescale Intercept
+   std::string strRescInter = GetEntryByNumber(0x0028,0x1052);
    if ( strRescInter != GDCM_UNFOUND )
    {
       if( sscanf( strRescInter.c_str(), "%f", &resInter) != 1 )
       {
          // bug in the element 0x0028,0x1052
-         dbg.Verbose(0, "gdcmHeader::GetRescaleIntercept: Rescale Slope is empty");
+         dbg.Verbose(0, "gdcmHeader::GetRescaleIntercept: Rescale Slope "
+                        "is empty");
       }
    }
 
@@ -409,14 +402,14 @@ float gdcmHeader::GetRescaleIntercept()
 }
 
 /**
-  *\ingroup gdcmHeader
-  *\brief gets the info from 0028,1053 : Rescale Slope
-  * @return Rescale Slope
+ *\brief   gets the info from 0028,1053 : Rescale Slope
+ * @return Rescale Slope
  */
 float gdcmHeader::GetRescaleSlope()
 {
    float resSlope = 1.;
-   std::string strRescSlope = GetEntryByNumber(0x0028,0x1053); //0028 1053 DS IMG Rescale Slope
+   //0028 1053 DS IMG Rescale Slope
+   std::string strRescSlope = GetEntryByNumber(0x0028,0x1053);
    if ( strRescSlope != GDCM_UNFOUND )
    {
       if( sscanf( strRescSlope.c_str(), "%f", &resSlope) != 1)
@@ -430,13 +423,12 @@ float gdcmHeader::GetRescaleSlope()
 }
 
 /**
-  * \ingroup gdcmHeader
-  * \brief This function is intended to user who doesn't want 
-  *   to have to manage a LUT and expects to get an RBG Pixel image
-  *   (or a monochrome one ...) 
-  * \warning to be used with GetImagePixels()
-  * @return 1 if Gray level, 3 if Color (RGB, YBR or PALETTE COLOR)
-  */
+ * \brief This function is intended to user who doesn't want 
+ *   to have to manage a LUT and expects to get an RBG Pixel image
+ *   (or a monochrome one ...) 
+ * \warning to be used with GetImagePixels()
+ * @return 1 if Gray level, 3 if Color (RGB, YBR or PALETTE COLOR)
+ */
 int gdcmHeader::GetNumberOfScalarComponents()
 {
    if ( GetSamplesPerPixel() == 3 )
@@ -481,13 +473,12 @@ int gdcmHeader::GetNumberOfScalarComponents()
 }
 
 /**
-  * \ingroup gdcmHeader
-  * \brief This function is intended to user that DOESN'T want 
-  *  to get RGB pixels image when it's stored as a PALETTE COLOR image
-  *   - the (vtk) user is supposed to know how deal with LUTs - 
-  * \warning to be used with GetImagePixelsRaw()
-  * @return 1 if Gray level, 3 if Color (RGB or YBR - NOT 'PALETTE COLOR' -)
-  */
+ * \brief This function is intended to user that DOESN'T want 
+ *  to get RGB pixels image when it's stored as a PALETTE COLOR image
+ *   - the (vtk) user is supposed to know how deal with LUTs - 
+ * \warning to be used with GetImagePixelsRaw()
+ * @return 1 if Gray level, 3 if Color (RGB or YBR - NOT 'PALETTE COLOR' -)
+ */
 int gdcmHeader::GetNumberOfScalarComponentsRaw()
 {
    // 0028 0100 US IMG Bits Allocated
@@ -518,12 +509,11 @@ int gdcmHeader::GetNumberOfScalarComponentsRaw()
 //
 
 /**
-  * \brief gets the info from 0020,0032 : Image Position Patient
-  *                 else from 0020,0030 : Image Position (RET)
-  *                 else 0.
-  * @return up-left image corner X position
-  */
-    
+ * \brief gets the info from 0020,0032 : Image Position Patient
+ *                 else from 0020,0030 : Image Position (RET)
+ *                 else 0.
+ * @return up-left image corner X position
+ */
 float gdcmHeader::GetXOrigin()
 {
    float xImPos, yImPos, zImPos;  
@@ -531,11 +521,13 @@ float gdcmHeader::GetXOrigin()
 
    if ( strImPos == GDCM_UNFOUND )
    {
-      dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position Patient (0020,0032)");
+      dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image "
+                     "Position Patient (0020,0032)");
       strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images
       if ( strImPos == GDCM_UNFOUND )
       {
-         dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position (RET) (0020,0030)");
+         dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image "
+                        "Position (RET) (0020,0030)");
          /// \todo How to tell the caller nothing was found ?
          return 0.;
       }
@@ -550,11 +542,11 @@ float gdcmHeader::GetXOrigin()
 }
 
 /**
 * \brief gets the info from 0020,0032 : Image Position Patient
 *                 else from 0020,0030 : Image Position (RET)
 *                 else 0.
 * @return up-left image corner Y position
 */
+ * \brief gets the info from 0020,0032 : Image Position Patient
+ *                 else from 0020,0030 : Image Position (RET)
+ *                 else 0.
+ * @return up-left image corner Y position
+ */
 float gdcmHeader::GetYOrigin()
 {
    float xImPos, yImPos, zImPos;
@@ -562,11 +554,13 @@ float gdcmHeader::GetYOrigin()
 
    if ( strImPos == GDCM_UNFOUND)
    {
-      dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position Patient (0020,0032)");
+      dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image "
+                     "Position Patient (0020,0032)");
       strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images
       if ( strImPos == GDCM_UNFOUND )
       {
-         dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position (RET) (0020,0030)");
+         dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image "
+                        "Position (RET) (0020,0030)");
          /// \todo How to tell the caller nothing was found ?
          return 0.;
       }  
@@ -581,13 +575,13 @@ float gdcmHeader::GetYOrigin()
 }
 
 /**
 * \brief gets the info from 0020,0032 : Image Position Patient
 * \               else from 0020,0030 : Image Position (RET)
 * \               else from 0020,1041 : Slice Location
 * \               else from 0020,0050 : Location
 * \               else 0.
 * @return up-left image corner Z position
 */
+ * \brief gets the info from 0020,0032 : Image Position Patient
*                 else from 0020,0030 : Image Position (RET)
*                 else from 0020,1041 : Slice Location
*                 else from 0020,0050 : Location
*                 else 0.
+ * @return up-left image corner Z position
+ */
 float gdcmHeader::GetZOrigin()
 {
    float xImPos, yImPos, zImPos; 
@@ -597,7 +591,8 @@ float gdcmHeader::GetZOrigin()
    {
       if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3)
       {
-         dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position Patient (0020,0032)");
+         dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image "
+                        "Position Patient (0020,0032)");
          return 0.;  // bug in the element 0x0020,0x0032
       }
       else
@@ -655,10 +650,9 @@ float gdcmHeader::GetZOrigin()
 }
 
 /**
-  * \brief gets the info from 0020,0013 : Image Number
-  * \               else 0.
-  * @return image number
-  */
+ * \brief gets the info from 0020,0013 : Image Number else 0.
+ * @return image number
+ */
 int gdcmHeader::GetImageNumber()
 {
    // The function i atoi() takes the address of an area of memory as
@@ -667,7 +661,8 @@ int gdcmHeader::GetImageNumber()
    // be preferable to sscanf() since atoi() is a much smaller, simpler and
    // faster function. sscanf() can do all possible conversions whereas
    // atoi() can only do single decimal integer conversions.
-   std::string strImNumber = GetEntryByNumber(0x0020,0x0013); //0020 0013 IS REL Image Number
+   //0020 0013 IS REL Image Number
+   std::string strImNumber = GetEntryByNumber(0x0020,0x0013);
    if ( strImNumber != GDCM_UNFOUND )
    {
       return atoi( strImNumber.c_str() );
@@ -676,9 +671,9 @@ int gdcmHeader::GetImageNumber()
 }
 
 /**
 * \brief gets the info from 0008,0060 : Modality
 * @return Modality Type
 */
+ * \brief gets the info from 0008,0060 : Modality
+ * @return Modality Type
+ */
 ModalityType gdcmHeader::GetModality()
 {
    // 0008 0060 CS ID Modality
@@ -738,7 +733,6 @@ ModalityType gdcmHeader::GetModality()
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Retrieve the number of Bits Stored (actually used)
  *          (as opposite to number of Bits Allocated)
  * @return  The encountered number of Bits Stored, 0 by default.
@@ -746,19 +740,59 @@ ModalityType gdcmHeader::GetModality()
  */
 int gdcmHeader::GetBitsStored()
 {
-   std::string strSize = GetEntryByNumber(0x0028,0x0101);
+   std::string strSize = GetEntryByNumber( 0x0028, 0x0101 );
    if ( strSize == GDCM_UNFOUND )
    {
-      dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to be mandatory");
+      dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to "
+                     "be mandatory");
       return 0;  // It's supposed to be mandatory
                  // the caller will have to check
    }
+   return atoi( strSize.c_str() );
+}
 
+/**
+ * \brief   Retrieve the high bit position.
+ * \warning The method defaults to 0 when information is absent.
+ *          The responsability of checking this value is left to the caller.
+ * @return  The high bit positin when present. 0 when absent.
+ */
+int gdcmHeader::GetHighBitPosition()
+{
+   std::string strSize = GetEntryByNumber( 0x0028, 0x0102 );
+   if ( strSize == GDCM_UNFOUND )
+   {
+      dbg.Verbose(0, "gdcmHeader::GetHighBitPosition: this is supposed "
+                     "to be mandatory");
+      return 0;
+   }
    return atoi( strSize.c_str() );
 }
 
 /**
- * \ingroup gdcmHeader
+ * \brief   Check wether the pixels are signed or UNsigned data.
+ * \warning The method defaults to false (UNsigned) when information is absent.
+ *          The responsability of checking this value is left to the caller.
+ * @return  True when signed, false when UNsigned
+ */
+bool gdcmHeader::IsSignedPixelData()
+{
+   std::string strSize = GetEntryByNumber( 0x0028, 0x0103 );
+   if ( strSize == GDCM_UNFOUND )
+   {
+      dbg.Verbose(0, "gdcmHeader::IsSignedPixelData: this is supposed "
+                     "to be mandatory");
+      return false;
+   }
+   int sign = atoi( strSize.c_str() );
+   if ( sign == 0 ) 
+   {
+      return false;
+   }
+   return true;
+}
+
+/**
  * \brief   Retrieve the number of Bits Allocated
  *          (8, 12 -compacted ACR-NEMA files, 16, ...)
  * @return  The encountered number of Bits Allocated, 0 by default.
@@ -769,16 +803,15 @@ int gdcmHeader::GetBitsAllocated()
    std::string strSize = GetEntryByNumber(0x0028,0x0100);
    if ( strSize == GDCM_UNFOUND )
    {
-      dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to be mandatory");
+      dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to "
+                     "be mandatory");
       return 0; // It's supposed to be mandatory
                 // the caller will have to check
    }
-
    return atoi( strSize.c_str() );
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Retrieve the number of Samples Per Pixel
  *          (1 : gray level, 3 : RGB -1 or 3 Planes-)
  * @return  The encountered number of Samples Per Pixel, 1 by default.
@@ -789,16 +822,76 @@ int gdcmHeader::GetSamplesPerPixel()
    std::string strSize = GetEntryByNumber(0x0028,0x0002);
    if ( strSize == GDCM_UNFOUND )
    {
-      dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to be mandatory");
+      dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to "
+                     "be mandatory");
       return 1; // Well, it's supposed to be mandatory ...
                 // but sometimes it's missing : *we* assume Gray pixels
    }
-
    return atoi( strSize.c_str() );
 }
 
 /**
- * \ingroup gdcmHeader
+ * \brief   Check wether this a monochrome picture or not by accessing
+ *          the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
+ * @return  true when "MONOCHROME1" or "MONOCHROME2". False otherwise.
+ */
+bool gdcmHeader::IsMonochrome()
+{
+   std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 );
+   if (   PhotometricInterp == "MONOCHROME1 "
+       || PhotometricInterp == "MONOCHROME2 " )
+   {
+      return true;
+   }
+   if ( PhotometricInterp == GDCM_UNFOUND )
+   {
+      dbg.Verbose(0, "gdcmHeader::IsMonochrome: absent Photometric "
+                     "Interpretation");
+   }
+   return false;
+}
+
+/**
+ * \brief   Check wether this a "PALETTE COLOR" picture or not by accessing
+ *          the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
+ * @return  true when "PALETTE COLOR". False otherwise.
+ */
+bool gdcmHeader::IsPaletteColor()
+{
+   std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 );
+   if (   PhotometricInterp == "PALETTE COLOR " )
+   {
+      return true;
+   }
+   if ( PhotometricInterp == GDCM_UNFOUND )
+   {
+      dbg.Verbose(0, "gdcmHeader::IsPaletteColor: absent Photometric "
+                     "Interpretation");
+   }
+   return false;
+}
+
+/**
+ * \brief   Check wether this a "YBR_FULL" color picture or not by accessing
+ *          the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
+ * @return  true when "YBR_FULL". False otherwise.
+ */
+bool gdcmHeader::IsYBRFull()
+{
+   std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 );
+   if (   PhotometricInterp == "YBR_FULL" )
+   {
+      return true;
+   }
+   if ( PhotometricInterp == GDCM_UNFOUND )
+   {
+      dbg.Verbose(0, "gdcmHeader::IsYBRFull: absent Photometric "
+                     "Interpretation");
+   }
+   return false;
+}
+
+/**
  * \brief   Retrieve the Planar Configuration for RGB images
  *          (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane)
  * @return  The encountered Planar Configuration, 0 by default.
@@ -810,15 +903,13 @@ int gdcmHeader::GetPlanarConfiguration()
    {
       return 0;
    }
-
    return atoi( strSize.c_str() );
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Return the size (in bytes) of a single pixel of data.
  * @return  The size in bytes of a single pixel of data; 0 by default
- *          0 means the file is NOT USABLE; the caller will have to check        
+ *          0 means the file is NOT USABLE; the caller will have to check
  */
 int gdcmHeader::GetPixelSize()
 {
@@ -844,13 +935,11 @@ int gdcmHeader::GetPixelSize()
    {
       return 8;
    }
-
    dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type");
    return 0;
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Build the Pixel Type of the image.
  *          Possible values are:
  *          - 8U  unsigned  8 bit,
@@ -888,7 +977,7 @@ std::string gdcmHeader::GetPixelType()
       bitsAlloc = "8";  // by old RGB images)
    }
 
-   std::string sign = GetEntryByNumber(0x0028, 0x0103); // "Pixel Representation"
+   std::string sign = GetEntryByNumber(0x0028, 0x0103);//"Pixel Representation"
 
    if (sign == GDCM_UNFOUND )
    {
@@ -903,13 +992,11 @@ std::string gdcmHeader::GetPixelType()
    {
       sign = "S";
    }
-
    return bitsAlloc + sign;
 }
 
 
 /**
- * \ingroup gdcmHeader
  * \brief   Recover the offset (from the beginning of the file) 
  *          of *image* pixels (not *icone image* pixels, if any !)
  * @return Pixel Offset
@@ -932,9 +1019,8 @@ size_t gdcmHeader::GetPixelOffset()
    }
 }
 
-// TODO : unify those two (previous one and next one)
+/// \todo TODO : unify those two (previous one and next one)
 /**
- * \ingroup gdcmHeader
  * \brief   Recover the pixel area length (in Bytes)
  * @return Pixel Element Length, as stored in the header
  *         (NOT the memory space necessary to hold the Pixels 
@@ -960,7 +1046,6 @@ size_t gdcmHeader::GetPixelAreaLength()
 }
 
 /**
-  * \ingroup gdcmHeader
   * \brief tells us if LUT are used
   * \warning Right now, 'Segmented xxx Palette Color Lookup Table Data'
   *          are NOT considered as LUT, since nobody knows
@@ -1008,7 +1093,6 @@ bool gdcmHeader::HasLUT()
 }
 
 /**
-  * \ingroup gdcmHeader
   * \brief gets the info from 0028,1101 : Lookup Table Desc-Red
   *             else 0
   * @return Lookup Table number of Bits , 0 by default
@@ -1020,7 +1104,8 @@ int gdcmHeader::GetLUTNbits()
    std::vector<std::string> tokens;
    int lutNbits;
 
-   //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red = Lookup Table Desc-Blue
+   //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red
+   //                                = Lookup Table Desc-Blue
    // Consistency already checked in GetLUTLength
    std::string lutDescription = GetEntryByNumber(0x0028,0x1101);
    if ( lutDescription == GDCM_UNFOUND )
@@ -1029,7 +1114,7 @@ int gdcmHeader::GetLUTNbits()
    }
 
    tokens.clear(); // clean any previous value
-   Tokenize ( lutDescription, tokens, "\\" );
+   gdcmUtil::Tokenize ( lutDescription, tokens, "\\" );
    //LutLength=atoi(tokens[0].c_str());
    //LutDepth=atoi(tokens[1].c_str());
 
@@ -1040,7 +1125,6 @@ int gdcmHeader::GetLUTNbits()
 }
 
 /**
-  * \ingroup gdcmHeader
   * \brief builts Red/Green/Blue/Alpha LUT from Header
   *         when (0028,0004),Photometric Interpretation = [PALETTE COLOR ]
   *          and (0028,1101),(0028,1102),(0028,1102)  
@@ -1121,9 +1205,9 @@ uint8_t* gdcmHeader::GetLUTRGBA()
    }
  
    // Load LUTs into memory, (as they were stored on disk)
-   uint8_t* lutR = (uint8_t*) GetEntryVoidAreaByNumber(0x0028,0x1201);
-   uint8_t* lutG = (uint8_t*) GetEntryVoidAreaByNumber(0x0028,0x1202);
-   uint8_t* lutB = (uint8_t*) GetEntryVoidAreaByNumber(0x0028,0x1203); 
+   uint8_t* lutR = (uint8_t*) GetEntryBinAreaByNumber(0x0028,0x1201);
+   uint8_t* lutG = (uint8_t*) GetEntryBinAreaByNumber(0x0028,0x1202);
+   uint8_t* lutB = (uint8_t*) GetEntryBinAreaByNumber(0x0028,0x1203); 
 
    if ( !lutR || !lutG || !lutB )
    {
@@ -1200,7 +1284,6 @@ uint8_t* gdcmHeader::GetLUTRGBA()
       *a = 1; // Alpha component
       a += 4;
    }
-
    return LUTRGBA;
 } 
 
@@ -1214,6 +1297,13 @@ std::string gdcmHeader::GetTransfertSyntaxName()
    // use the gdcmTS (TS : Transfert Syntax)
    std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010);
 
+   if ( transfertSyntax == GDCM_NOTLOADED )
+   {
+      std::cout << "Transfert Syntax not loaded. " << std::endl
+               << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+               << std::endl;
+      return "Uncompressed ACR-NEMA";
+   }
    if ( transfertSyntax == GDCM_UNFOUND )
    {
       dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:"
@@ -1241,17 +1331,16 @@ std::string gdcmHeader::GetTransfertSyntaxName()
  */
 void gdcmHeader::SetImageDataSize(size_t ImageDataSize)
 {
-   char car[20];
-   sprintf(car,"%d",ImageDataSize);
+   ///FIXME I don't understand this code wh ydo we set two times 'car' ?
+   std::string car = gdcmUtil::Format("%d", ImageDataSize);
  
    gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
    a->SetLength(ImageDataSize);
 
    ImageDataSize += 8;
-   sprintf(car,"%d",ImageDataSize);
+   car = gdcmUtil::Format("%d", ImageDataSize);
 
-   const std::string content1 = car;
-   SetEntryByNumber(content1, GrPixel, NumPixel);
+   SetEntryByNumber(car, GrPixel, NumPixel);
 }
 
 //-----------------------------------------------------------------------------
@@ -1263,13 +1352,14 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize)
  */
 bool gdcmHeader::AnonymizeHeader()
 {
-   gdcmDocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010);
+   // If exist, replace by spaces
+   SetEntryByNumber ("  ",0x0010, 0x2154); // Telephone   
+   SetEntryByNumber ("  ",0x0010, 0x1040); // Adress
+   SetEntryByNumber ("  ",0x0010, 0x0020); // Patient ID
 
-   ReplaceIfExistByNumber ("  ",0x0010, 0x2154); // Telephone   
-   ReplaceIfExistByNumber ("  ",0x0010, 0x1040); // Adress
-   ReplaceIfExistByNumber ("  ",0x0010, 0x0020); // Patient ID
+   gdcmDocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010);
   
-   if ( patientNameHE )
+   if ( patientNameHE ) // we replace it by Study Instance UID (why not)
    {
       std::string studyInstanceUID =  GetEntryByNumber (0x0020, 0x000d);
       if ( studyInstanceUID != GDCM_UNFOUND )
@@ -1354,8 +1444,8 @@ void gdcmHeader::GetImageOrientationPatient( float iop[6] )
       if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", 
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
       {
-         dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: wrong Image Orientation Patient (0020,0037)");
-         // bug in the element 0x0020,0x0037
+         dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: "
+                        "wrong Image Orientation Patient (0020,0037)");
       }
    }
    //For ACR-NEMA
@@ -1365,8 +1455,8 @@ void gdcmHeader::GetImageOrientationPatient( float iop[6] )
       if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", 
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
       {
-         dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: wrong Image Orientation Patient (0020,0035)");
-         // bug in the element 0x0020,0x0035
+         dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: "
+                        "wrong Image Orientation Patient (0020,0035)");
       }
    }
 }