+
+void ShowLutData(gdcm::File *e1);
+
+void ShowLutData(gdcm::File *e1)
+{
+ // 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 = e1->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 = e1->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;
+
+ }
+