- return 3;
- }
-
- // 0028 0100 US IMG Bits Allocated
- // (in order no to be messed up by old RGB images)
- if ( GetEntry(0x0028,0x0100) == "24" )
- {
- return 3;
- }
-
- std::string strPhotometricInterpretation = GetEntry(0x0028,0x0004);
-
- if ( ( strPhotometricInterpretation == "PALETTE COLOR ") )
- {
- if ( HasLUT() )// PALETTE COLOR is NOT enough
- {
- return 3;
- }
- else
- {
- return 1;
- }
- }
-
- // beware of trailing space at end of string
- // DICOM tags are never of odd length
- if ( strPhotometricInterpretation == GDCM_UNFOUND ||
- Util::DicomStringEqual(strPhotometricInterpretation, "MONOCHROME1") ||
- Util::DicomStringEqual(strPhotometricInterpretation, "MONOCHROME2") )
- {
- return 1;
- }
- else
- {
- // we assume that *all* kinds of YBR are dealt with
- return 3;
- }
-}
-
-/**
- * \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 File::GetNumberOfScalarComponentsRaw()
-{
- // 0028 0100 US IMG Bits Allocated
- // (in order no to be messed up by old RGB images)
- if ( File::GetEntry(0x0028,0x0100) == "24" )
- {
- return 3;
- }
-
- // we assume that *all* kinds of YBR are dealt with
- return GetSamplesPerPixel();
-}
-
-//
-// -------------- Remember ! ----------------------------------
-//
-// Image Position Patient (0020,0032):
-// If not found (ACR_NEMA) we try Image Position (0020,0030)
-// If not found (ACR-NEMA), we consider Slice Location (0020,1041)
-// or Location (0020,0050)
-// as the Z coordinate,
-// 0. for all the coordinates if nothing is found
-
-// \todo find a way to inform the caller nothing was found
-// \todo How to tell the caller a wrong number of values was found?
-//
-// ---------------------------------------------------------------
-//
-
-/**
- * \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 File::GetXOrigin()
-{
- float xImPos, yImPos, zImPos;
- std::string strImPos = GetEntry(0x0020,0x0032);
-
- if ( strImPos == GDCM_UNFOUND )
- {
- gdcmVerboseMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = GetEntry(0x0020,0x0030); // For ACR-NEMA images
- if ( strImPos == GDCM_UNFOUND )
- {
- gdcmVerboseMacro( "Unfound Image Position (RET) (0020,0030)");
- /// \todo How to tell the caller nothing was found ?
- return 0.;
- }
- }
-
- if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
- {
- 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
- */
-float File::GetYOrigin()
-{
- float xImPos, yImPos, zImPos;
- std::string strImPos = GetEntry(0x0020,0x0032);
-
- if ( strImPos == GDCM_UNFOUND)
- {
- gdcmVerboseMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = GetEntry(0x0020,0x0030); // For ACR-NEMA images
- if ( strImPos == GDCM_UNFOUND )
- {
- gdcmVerboseMacro( "Unfound Image Position (RET) (0020,0030)");
- /// \todo How to tell the caller nothing was found ?
- return 0.;
- }
- }
-
- if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
- {
- return 0.;
- }
-
- return yImPos;
-}
-
-/**
- * \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 File::GetZOrigin()
-{
- float xImPos, yImPos, zImPos;
- std::string strImPos = GetEntry(0x0020,0x0032);
-
- if ( strImPos != GDCM_UNFOUND )
- {
- if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3)
- {
- gdcmVerboseMacro( "Wrong Image Position Patient (0020,0032)");
- return 0.; // bug in the element 0x0020,0x0032
- }
- else