-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.10 2003/10/03 14:26:11 jpr Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.14 2003/10/27 14:01:12 jpr Exp $
#include "gdcmHeaderHelper.h"
std::string PhotometricInterpretation =
gdcmHeader::GetPubElValByNumber(0x0028,0x0004);
+
// The compiler will optimze, if it feels like !
- if (PhotometricInterpretation == GDCM_UNFOUND) return 1;
- if (PhotometricInterpretation == "MONOCHROME1") return 1;
- if (PhotometricInterpretation == "MONOCHROME2") return 1;
+ //beware of trailing space at end of string
+ if (PhotometricInterpretation.find(GDCM_UNFOUND) < PhotometricInterpretation.length() ||
+ PhotometricInterpretation.find("MONOCHROME1") < PhotometricInterpretation.length() ||
+ PhotometricInterpretation.find("MONOCHROME2") < PhotometricInterpretation.length() ) return 1;
+
+ // WARNING : quick and dirty trick to produce a single plane Grey image
+ // See also gdcmFile::GetImageDataIntoVector()
+ // if(GetPubElValVoidAreaByNumber(0x0028,0x1201)==NULL) return 1; // Lut Red
+ // end of dirty trick
return 3;
}
float gdcmHeaderHelper::GetXSpacing() {
float xspacing, yspacing;
std::string StrSpacing = GetPubElValByNumber(0x0028,0x0030);
-
- if (StrSpacing == GDCM_UNFOUND) {
- dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)");
- return 1.;
- }
- if( sscanf( StrSpacing.c_str(), "%f\\%f", &xspacing, &yspacing) != 2)
- return 0.;
- //else
- return xspacing;
+
+ if (StrSpacing == GDCM_UNFOUND) {
+ dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)");
+ return 1.;
+ }
+ if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2)
+ return 0.;
+ if (xspacing == 0.) {
+ dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
+ // seems to be a bug in the header ...
+ sscanf( StrSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
+ }
+ return xspacing;
}
//----------------------------------------------------------------------------
/**
dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)");
return 1.;
}
- if( sscanf( StrSpacing.c_str(), "%f\\%f", &xspacing, &yspacing) != 2)
+ if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2)
return 0.;
- if (yspacing == 0.) {
+ if (xspacing == 0.) {
dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
// seems to be a bug in the header ...
- sscanf( StrSpacing.c_str(), "%f\\0\\%f", &xspacing, &yspacing);
+ sscanf( StrSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
}
return yspacing;
}