- return resSlope;
-}
-
-/**
- * \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 File::GetNumberOfScalarComponents()
-{
- if ( GetSamplesPerPixel() == 3 )
- {
- return 3;
- }
-
- // 0028 0100 US IMG Bits Allocated
- // (in order no to be messed up by old RGB images)
- if ( GetEntryValue(0x0028,0x0100) == "24" )
- {
- return 3;
- }
-
- std::string strPhotometricInterpretation = GetEntryValue(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::GetEntryValue(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
-//
-// ---------------------------------------------------------------
-//
-
-/**
- * \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 = GetEntryValue(0x0020,0x0032);
-
- if ( strImPos == GDCM_UNFOUND )
- {
- gdcmVerboseMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
- if ( strImPos == GDCM_UNFOUND )
- {
- gdcmVerboseMacro( "Unfound Image Position (RET) (0020,0030)");
- 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 = GetEntryValue(0x0020,0x0032);
-
- if ( strImPos == GDCM_UNFOUND)
- {
- gdcmVerboseMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
- if ( strImPos == GDCM_UNFOUND )
- {
- gdcmVerboseMacro( "Unfound Image Position (RET) (0020,0030)");
- return 0.;
- }
- }
-
- if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
- {
- return 0.;
- }