Hello!
I am tring to get ModalityLUT sequence from the DICOM file and apply the table data to rendered data using getOutputData().
Referring to dcmmklut.cxx, I implemented the source code, as follows;
//ModalityLUT 1
DcmItem *ditem = new DcmItem();
DcmSequenceOfItems *dseq = NULL;
DcmLongString modalityLUTType(DCM_ModalityLUTType);
modalityLUTType.putString("US"); // unspecified Modality LUT
DcmElement *delem = new DcmLongString(modalityLUTType);
ditem->insert(delem, OFTrue);
dseq = new DcmSequenceOfItems(DCM_ModalityLUTSequence);
dataset->insert(dseq, OFTrue);
dseq->insert(ditem);
Compiling error and running error has never occued.
But I didn't get the modalityLUT table and could not render the lut table.
I would appliciate it if you tell me the mistakes I made, and the correct code to get lut table and apply it to rendering.
Thanks,
ModalityLUT
Moderator: Moderator Team
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Are you really trying to get the modality LUT from an existing DICOM file? Your code seems to create a LUT instead.I am tring to get ModalityLUT sequence from the DICOM file and apply the table data to rendered data using getOutputData().
In addition, there is no need to apply a Modality LUT on the result of getOutputData() because the modality trannsformation is already applied to the internal representation of the DicomImage class.
I think you are mixing things up ...
-
- Posts: 40
- Joined: Thu, 2008-09-18, 09:20
- Location: Japan
Hello Jörg,
Thank you very much for your reply.
I understand that I was so comfused that the source code I created didn't meet our requirement.
BTW, it seems that the default DCMTK doesn't apply the modality lut table in the DICOM file to the rendered data.
Then, I tried using DcmPresentationState class to apparently apply the modality lut table to the rendered data.
In the class there is the read Modality LUT Sequence, as follows;
/* read Modality LUT Sequence */
if (result==EC_Normal)
{
stack.clear();
if (EC_Normal == dset.search(DCM_ModalityLUTSequence, stack, ESM_fromHere, OFFalse))
{
seq=(DcmSequenceOfItems *)stack.top();
if (seq->card() ==1)
{
item = seq->getItem(0);
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTDescriptor.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTDescriptor = *((DcmUnsignedShort *)(stack.top()));
}
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTExplanation.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTExplanation = *((DcmLongString *)(stack.top()));
}
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTData.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTData = *((DcmUnsignedShort *)(stack.top()));
}
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTType.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTType = *((DcmLongString *)(stack.top()));
}
} else {
result=EC_TagNotFound;
if (verboseMode)
{
logstream->lockCerr() << "Error: Modality LUT SQ does not have exactly one item in presentation state" << endl;
logstream->unlockCerr();
}
}
}
}
I think most of the code above works well, but just modalityLUTData is wrong. The debugger indicates that there is no data in modalityLUTData.
If the thing I wrote is true, please let me know what is worng and how I fix this bad context.
Thanks.
Thank you very much for your reply.
I understand that I was so comfused that the source code I created didn't meet our requirement.
BTW, it seems that the default DCMTK doesn't apply the modality lut table in the DICOM file to the rendered data.
Then, I tried using DcmPresentationState class to apparently apply the modality lut table to the rendered data.
In the class there is the read Modality LUT Sequence, as follows;
/* read Modality LUT Sequence */
if (result==EC_Normal)
{
stack.clear();
if (EC_Normal == dset.search(DCM_ModalityLUTSequence, stack, ESM_fromHere, OFFalse))
{
seq=(DcmSequenceOfItems *)stack.top();
if (seq->card() ==1)
{
item = seq->getItem(0);
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTDescriptor.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTDescriptor = *((DcmUnsignedShort *)(stack.top()));
}
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTExplanation.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTExplanation = *((DcmLongString *)(stack.top()));
}
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTData.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTData = *((DcmUnsignedShort *)(stack.top()));
}
stack.clear();
if (EC_Normal == item->search((DcmTagKey &)modalityLUTType.getTag(),
stack, ESM_fromHere, OFFalse))
{
modalityLUTType = *((DcmLongString *)(stack.top()));
}
} else {
result=EC_TagNotFound;
if (verboseMode)
{
logstream->lockCerr() << "Error: Modality LUT SQ does not have exactly one item in presentation state" << endl;
logstream->unlockCerr();
}
}
}
}
I think most of the code above works well, but just modalityLUTData is wrong. The debugger indicates that there is no data in modalityLUTData.
If the thing I wrote is true, please let me know what is worng and how I fix this bad context.
Thanks.
Maty
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
This is not correct. The DicomImage class always applies the modality LUT to the pixel data if present and not disabled or forbidden by the standard. Please read the documentation of this class!BTW, it seems that the default DCMTK doesn't apply the modality lut table in the DICOM file to the rendered data.
-
- Posts: 40
- Joined: Thu, 2008-09-18, 09:20
- Location: Japan
Who is online
Users browsing this forum: No registered users and 1 guest