+ // Nothing is written yet to get LUT Data user friendly
+ // The following is to be moved into a PixelReadConvert method
+ // Let here, waiting for a clever idea on the way to do it.
+
+ gdcm::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
+ if ( modLutSeq !=0 )
+ {
+ gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
+ if ( sqi != 0 )
+ {
+ std::string lutDescriptor = sqi->GetEntryValue(0x0028,0x3002);
+ if ( /*lutDescriptor == GDCM_UNFOUND*/ 0 )
+ {
+ //gdcmWarningMacro( "LUT Descriptor is missing" );
+ std::cout << "LUT Descriptor is missing" << std::endl;
+ return;
+ }
+ int length; // LUT length in Bytes
+ int deb; // Subscript of the first Lut Value
+ int nbits; // Lut item size (in Bits)
+
+ int nbRead; // nb of items in LUT descriptor (must be = 3)
+
+ nbRead = sscanf( lutDescriptor.c_str(),
+ "%d\\%d\\%d",
+ &length, &deb, &nbits );
+ std::cout << "length " << length
+ << " deb " << deb
+ << " nbits " << nbits
+ << std::endl;
+ if ( nbRead != 3 )
+ {
+ //gdcmWarningMacro( "Wrong LUT descriptor" );
+ std::cout << "Wrong LUT descriptor" << std::endl;
+ }
+ //LUT Data (CTX dependent)
+ gdcm::BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
+ if ( b != 0 )
+ {
+ int BitsAllocated = f->GetBitsAllocated();
+ if ( BitsAllocated <= 8 )
+ {
+ int mult;
+ if ( ( nbits == 16 ) && ( BitsAllocated == 8 ) )
+ {
+ // when LUT item size is different than pixel size
+ mult = 2; // high byte must be = low byte
+ }
+ else
+ {
+ // See PS 3.3-2003 C.11.1.1.2 p 619
+ mult = 1;
+ }
+ uint8_t *lut = b->GetBinArea();
+ for( int i=0; i < length; ++i )
+ {
+ std::cout << i+deb << " : \t"
+ << (int) (lut[i*mult + 1]) << std::endl;
+ }
+ }
+ else
+ {
+ uint16_t *lut = (uint16_t *)(b->GetBinArea());
+ for( int i=0; i < length; ++i )
+ {
+ std::cout << i+deb << " : \t"
+ << (int) (((uint16_t *)lut)[i])
+ << std::endl;
+ }
+ }
+ }
+ else
+ std::cout << "No LUT Data BinEntry (0x0028,0x3006) found?!? "
+ << std::endl;
+ }
+ else
+ std::cout << "No First SQ Item within (0x0028,0x3000) ?!? "
+ << std::endl;
+ }
+ else
+ std::cout << "No LUT Data SeqEntry (0x0028,0x3000) found "
+ << std::endl;
+ }
+
+int main(int argc, char *argv[])
+{
+
+ START_USAGE(usage)
+ " \n PrintFile : \n ",
+ " Display the header of a ACR-NEMA/PAPYRUS/DICOM File ",
+ " usage: PrintFile {filein=inputFileName|dirin=inputDirectoryName}[level=n]",
+ " [forceload=listOfElementsToForceLoad] ",
+ " [dict= privateDirectory] ",
+ " [ { [noshadowseq] | [noshadow][noseq] } ] [debug] ",
+ " level = 0,1,2 : depending on the amount of details user wants to see",
+ " listOfElementsToForceLoad : group-elem,g2-e2,... (in hexa, no space)",
+ " of Elements to load whatever their length ",
+ " privateDirectory : source file full path name of Shadow Group elems ",
+ " noshadowseq: user doesn't want to load Private Sequences ",
+ " noshadow : user doesn't want to load Private groups (odd number) ",
+ " noseq : user doesn't want to load Sequences ",
+ " debug : user wants to run the program in 'debug mode' ",
+ " showlut :user wants to display the Palette Color (as an int array) ",
+ FINISH_USAGE
+
+ // Initialize Arguments Manager
+ gdcm::ArgMgr *am= new gdcm::ArgMgr(argc, argv);
+
+ if (argc == 1 || am->ArgMgrDefined("usage") )