public DicomModalityLutAttributes getModalityLutAttributes(int frameIndex)
A zero-based index that identifies the frame number in the dataset. If the dataset does not support Multi-frames, this parameter is ignored.
Modality LUT attributes.
If the method does not find any of the attributes of the "Modality LUT Module" it will set both IsModalityLutSequence and IsRescaleSlopeIntercept to false. In this case, the rest of the members of the DicomModalityLutAttributes class are undefined. If the method finds the "Rescale Intercept" (0028,1052) and "Rescale Slope" (0028,1053) elements, it will set IsRescaleSlopeIntercept to true and populate RescaleIntercept, RescaleSlope, and RescaleType with the values retrieved from the DICOM Data Set.
If the method finds "Modality LUT Sequence" (0028,3000), it will set IsModalityLutSequence to true and populate FirstStoredPixelValueMapped, NumberOfEntries, EntryBits, LutExplanation, and LutType with the values retrieved from the DICOM Data Set.
It is prohibited by the DICOM standard for both "Rescale Intercept" and "Modality LUT Sequence" to exist in the same DICOM Data Set. However, if this method encounters such a Data Set, it will ignore "Modality LUT Sequence" and assume that only "Rescale Intercept" exists.
The Multi-frame Functional Groups module may have a Shared Functional Groups Sequence item, and/or a Per-frame Functional Groups Sequence item. Either of these items may have a Pixel Value Transformation Sequence (0028,9145) item. If the following elements are not found at the top level in the dataset, this method looks in the Shared Functional Groups Sequence item and the Per-frame Functional Groups Sequence
For a detailed discussion on Multi-frame Functional Groups see the topic Multi-frame Functional Groups.
public void TestSetModalityLut()
string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image3.dcm");
//Make sure to initialize the DICOM engine, this needs to be done only once
//In the whole application
using (DicomDataSet ds = new DicomDataSet())
//Load DICOM File
DicomModalityLutAttributes modalityLutAttributes = new DicomModalityLutAttributes();
//No Modality LUT Sequence (0028,3000)
modalityLutAttributes.IsModalityLutSequence = false;
//Yes there is a rescale slope and intercept
modalityLutAttributes.IsRescaleSlopeIntercept = true;
modalityLutAttributes.RescaleIntercept = -128.0;
modalityLutAttributes.RescaleSlope = 1.0;
modalityLutAttributes.RescaleType = "UNSPECIFIED";
// Delete the existing modality LUT,
// although we don't have to !
//Set rescale slope and intercept
ds.Save(Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "MLUT.dcm"), DicomDataSetSaveFlags.None);
static class LEAD_VARS
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";