#include "ltdic.h"

L_LTDIC_API L_UINT16 L_DicomSetModalityLUT(hDS, uFrameIndex, pModalityLUTAttributes, pLUTData, uDataSize, uFlags)


a DICOM handle

L_UINT32 uFrameIndex;

index value


pointer to a Modality LUT attributes structure

L_UINT16 *pLUTData;

pointer to the input buffer

L_UINT uDataSize;

size of the input buffer

L_UINT uFlags;

reserved for future use

Sets the attributes that describe the Modality LUT.




A DICOM handle.


A zero-based index that identifies the frame number in the dataset.  If the dataset does not support Multi-frames, this parameter is ignored.


Pointer to a structure containing the Modality LUT attributes to set.


Pointer to the buffer that holds the "LUT Data". Pass NULL if you are not trying to set the "LUT Data" (0028,3006) under the "Modality LUT Sequence" (0028,3000).


Size of the buffer pointed to by pLUTData. Pass 0 if pLUTData is set to NULL.


0 -- Default


DICOM_SETIMAGE_MFG_OVERWRITE_SHARED If set, existing Pixel Value Transformation Sequence items under the Shared Functional Groups Sequence will be overwritten.. If this flag is not included, Shared Functional Groups Sequence elements are unchanged.



If the Pixel Value Transformation Sequence does not already exist, it is added under the Per-frame Functional Groups Sequence.

If the Pixel Value Transformation Sequencealready exists under the Shared Functional Groups Sequence, this flag is ignored.  



If the Pixel Value Transformation Sequence does not already exist, it is added under the Shared Functional Groups Sequence.

If the Pixel Value Transformation Sequencealready exists under the Per-frame Functional Groups Sequence, this flag is ignored.



The function was successful.


An error occurred. Refer to Return Codes.


This function will set the attributes of the "Modality LUT Module". Before calling this function, initialize pModalityLUTAttributes->uStructSize to be sizeof(DICOMMLUTATTRIBS) and initialize all the attributes which you are changing.

If you are trying to set the "Rescale Intercept" (0028,1052) and "Rescale Slope" (0028,1053), set pModalityLUTAttributes->bIsRescaleSlopeIntercept to TRUE and populate pModalityLUTAttributes->RescaleIntercept, pModalityLUTAttributes->RescaleSlope with the new values. You can also populate pModalityLUTAttributes->szRescaleType if you want to set "Rescale Type" (0028,1054).

If you are trying to set the elements under "Modality LUT Sequence", set pModalityLUTAttributes->bIsModalityLUTSequence to TRUE and populate.

pModalityLUTAttributes->LUTDescriptor and pModalityLUTAttributes->szModalityLUTType .In this case pLUTData should point to the "LUT Data" (0028,3006) buffer.

This function will return an error if both pModalityLUTAttributes->bIsRescaleSlopeIntercept and pModalityLUTAttributes->bIsModalityLUTSequence are set to TRUE. It will also return an error if pModalityLUTAttributes->bIsModalityLUTSequence is set to TRUE and you pass NULL for pLUTData or 0 for uDataSize.

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. The uFlags parameter can be used to add or modify existing information in the Pixel Value Transformation Sequence.

The following flags are used only if the Pixel Value Transformation Sequence does not already exist.

In this case, the sequence is placed in the sequence indicated by the flag (Per-frame Functional Groups Sequence or Shared Functional Groups Sequence).

If a Pixel Value Transformation Sequence already exists in a DICOM dataset, uFlags is ignored and the sequence is placed in the location where sequences already exist.

The specific elements that are read or updated when using these flags are shown below:

(0028,9145) Pixel Value Transformation Sequence child elements

Tag Name


Rescale Intercept


Rescale Slope


Rescale Type

For a detailed discussion on Multi-frame Functional Groups and how the DICOM_SET_IMAGE_MFG flags are used, see the topic Multi-frame Functional Groups.

Required DLLs and Libraries


For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application


Win32, x64, Linux.

See Also


L_DicomGetModalityLUTAttributes, L_DicomGetModalityLUTData, L_DicomDeleteModalityLUT


LUT Encoding Overview


LUT Encoding: Modality LUT


This example will set Rescale Intercept (0028,1052) element to -128.0 and Rescale Slope (0028,1053) element to 1.0

L_INT DicomSetModalityLUTExample(HDICOMDS hDicomDS) 
   L_UINT16 nRet; 
   // Structure that will hold the new modality LUT attributes 
   DICOMMLUTATTRIBS  ModalityLUTAttributes = {0}; 
   //Remember to set the structure size 
   ModalityLUTAttributes.uStructSize= sizeof(DICOMMLUTATTRIBS); 
   //No Modality LUT Sequence (0028,3000) 
   ModalityLUTAttributes.bIsModalityLUTSequence    = FALSE; 
   //Yes there is a rescale slope and intercept 
   ModalityLUTAttributes.bIsRescaleSlopeIntercept  = TRUE; 
   ModalityLUTAttributes.fRescaleIntercept         = -128.0; 
   ModalityLUTAttributes.fRescaleSlope             = 1.0; 
   // Delete the existing modality LUT, 
   // although we don't have to ! 
   nRet = L_DicomDeleteModalityLUT(hDicomDS,0, 0); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
   //Set rescale slope and intercept 
   return L_DicomSetModalityLUT(hDicomDS, 0, &ModalityLUTAttributes, NULL, 0, 0); 

Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.