]> Creatis software - gdcm.git/blobdiff - src/gdcmHeader.cxx
ENH: Move the old setup.py to its new home
[gdcm.git] / src / gdcmHeader.cxx
index 799627476e3ce92a790bd8469e01cc3bed649fdc..a623626f2efae27c0645295f9543749ec735acb6 100644 (file)
@@ -3,12 +3,12 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/07/17 22:45:40 $
-  Version:   $Revision: 1.177 $
+  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
 /**
  * \brief  Constructor 
  * @param  filename name of the file whose header we want to analyze
- * @param  exception_on_error whether we want to throw an exception or not
- * @param  enable_sequences = true to allow the header 
- *         to be parsed *inside* the SeQuences, when they have an actual length 
- * @param  ignore_shadow = true if user wants to skip shadow groups 
- *         during parsing, to save memory space
  */
-gdcmHeader::gdcmHeader( std::string const & filename, 
-                        bool exception_on_error,
-                        bool enable_sequences, 
-                        bool ignore_shadow ):
-            gdcmDocument( filename,
-                          exception_on_error,
-                          enable_sequences,
-                          ignore_shadow )
+gdcmHeader::gdcmHeader( std::string const & filename ):
+            gdcmDocument( filename )
 {    
    // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010
    // We may encounter the 'RETired' (0x0028, 0x0200) tag
@@ -53,8 +42,7 @@ gdcmHeader::gdcmHeader( std::string const & filename,
    // 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.
-   
-   // This IS the right place for the code
+   // Note: this IS the right place for the code
  
    // Image Location
    std::string imgLocation = GetEntryByNumber(0x0028, 0x0200);
@@ -89,15 +77,13 @@ gdcmHeader::gdcmHeader( std::string const & filename,
 
 /**
  * \brief Constructor  
- * @param exception_on_error whether we want to throw an exception or not
  */
-gdcmHeader::gdcmHeader(bool exception_on_error) :
-            gdcmDocument( exception_on_error )
+gdcmHeader::gdcmHeader()
+           :gdcmDocument()
 {
 }
 
 /**
- * \ingroup gdcmHeader
  * \brief   Canonical destructor.
  */
 gdcmHeader::~gdcmHeader ()
@@ -113,56 +99,67 @@ gdcmHeader::~gdcmHeader ()
  * @param filetype Type of the File to be written 
  *          (ACR-NEMA, ExplicitVR, ImplicitVR)
  */
-void gdcmHeader::Write(FILE* fp,FileType filetype) {
-   
+void gdcmHeader::Write(FILE* fp,FileType filetype)
+{
    // Bits Allocated
-   if ( GetEntryByNumber(0x0028,0x0100) ==  "12") {
+   if ( GetEntryByNumber(0x0028,0x0100) ==  "12")
+   {
       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;
+   if (i_lgPix != -2)
+   {
+      // no (GrPixel, NumPixel) element
+      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' ) {
-    // if SamplesPerPixel = 3, sure we don't need any LUT !   
-    // Drop 0028|1101, 0028|1102, 0028|1103
-    // Drop 0028|1201, 0028|1202, 0028|1203
-
-     gdcmDocEntry *e;
-     e=GetDocEntryByNumber(0x0028,0x01101);
-     if (e) 
-        RemoveEntry(e);
-     e=GetDocEntryByNumber(0x0028,0x1102);
-     if (e) 
-        RemoveEntry(e);
-     e=GetDocEntryByNumber(0x0028,0x1103);
-
-     if (e) 
-        RemoveEntry(e);
-     e=GetDocEntryByNumber(0x0028,0x01201);
-     if (e) 
-        RemoveEntry(e);
-     e=GetDocEntryByNumber(0x0028,0x1202);
-     if (e) 
-        RemoveEntry(e);
-     e=GetDocEntryByNumber(0x0028,0x1203);
-     if (e) 
-       RemoveEntry(e);
-   }
+   if ( GetEntryByNumber(0x0028,0x0002).c_str()[0] == '3' )
+   {
+      // if SamplesPerPixel = 3, sure we don't need any LUT !   
+      // Drop 0028|1101, 0028|1102, 0028|1103
+      // Drop 0028|1201, 0028|1202, 0028|1203
 
+      gdcmDocEntry* e = GetDocEntryByNumber(0x0028,0x01101);
+      if (e)
+      {
+         RemoveEntryNoDestroy(e);
+      }
+      e = GetDocEntryByNumber(0x0028,0x1102);
+      if (e)
+      {
+         RemoveEntryNoDestroy(e);
+      }
+      e = GetDocEntryByNumber(0x0028,0x1103);
+      if (e)
+      {
+         RemoveEntryNoDestroy(e);
+      }
+      e = GetDocEntryByNumber(0x0028,0x01201);
+      if (e)
+      {
+         RemoveEntryNoDestroy(e);
+      }
+      e = GetDocEntryByNumber(0x0028,0x1202);
+      if (e)
+      {
+         RemoveEntryNoDestroy(e);
+      }
+      e = GetDocEntryByNumber(0x0028,0x1203);
+      if (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,35 +380,36 @@ 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");
       }
    }
 
-  return resInter;
+   return resInter;
 }
 
 /**
-  *\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.;
       }
@@ -543,18 +535,18 @@ float gdcmHeader::GetXOrigin()
 
    if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
    {
-     return 0.;
+      return 0.;
    }
 
    return xImPos;
 }
 
 /**
 * \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;
 } 
 
@@ -1213,6 +1296,14 @@ 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:"
@@ -1220,6 +1311,10 @@ std::string gdcmHeader::GetTransfertSyntaxName()
       return "Uncompressed ACR-NEMA";
    }
 
+   while ( ! isdigit(transfertSyntax[transfertSyntax.length()-1]) )
+   {
+      transfertSyntax.erase(transfertSyntax.length()-1, 1);
+   }
    // we do it only when we need it
    gdcmTS* ts         = gdcmGlobal::GetTS();
    std::string tsName = ts->GetValue( transfertSyntax );
@@ -1236,18 +1331,16 @@ std::string gdcmHeader::GetTransfertSyntaxName()
  */
 void gdcmHeader::SetImageDataSize(size_t ImageDataSize)
 {
-   std::string content1;
-   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);
-   content1=car;
-   SetEntryByNumber(content1, GrPixel, NumPixel);
+   ImageDataSize += 8;
+   car = gdcmUtil::Format("%d", ImageDataSize);
+
+   SetEntryByNumber(car, GrPixel, NumPixel);
 }
 
 //-----------------------------------------------------------------------------
@@ -1259,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 )
@@ -1338,43 +1432,33 @@ bool gdcmHeader::AnonymizeHeader()
   * @param iop adress of the (6)float aray to receive values
   * @return cosines of image orientation patient
   */
-void gdcmHeader::GetImageOrientationPatient( float* iop )
+void gdcmHeader::GetImageOrientationPatient( float iop[6] )
 {
+   std::string strImOriPat;
    //iop is supposed to be float[6]
-   iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0;
+   iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0.;
 
    // 0020 0037 DS REL Image Orientation (Patient)
-   std::string strImOriPat = GetEntryByNumber(0x0020,0x0037);
-   if ( strImOriPat != GDCM_UNFOUND )
+   if ( (strImOriPat = GetEntryByNumber(0x0020,0x0037)) != GDCM_UNFOUND )
    {
       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)");
-         return ;  // bug in the element 0x0020,0x0037
-      }
-      else
-      {
-         return ;
+         dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: "
+                        "wrong Image Orientation Patient (0020,0037)");
       }
    }
-
    //For ACR-NEMA
    // 0020 0035 DS REL Image Orientation (RET)
-   strImOriPat = GetEntryByNumber(0x0020,0x0035);
-   if ( strImOriPat != GDCM_UNFOUND )
+   else if ( (strImOriPat = GetEntryByNumber(0x0020,0x0035)) != GDCM_UNFOUND )
    {
       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)");
-         return ;  // bug in the element 0x0020,0x0035
+         dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: "
+                        "wrong Image Orientation Patient (0020,0035)");
       }
    }
-   else
-   {
-      return;
-   }
 }
 
 //-----------------------------------------------------------------------------