Sets the attributes that describe the Modality LUT.
#include "ltdic.h"
L_UINT16 LDicomDS::SetModalityLUT(uFrameIndex, pModalityLUTAttributes, pLUTData, uDataSize, uFlags)
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" to set. 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.
Value | Meaning |
---|---|
0 | Default |
[0x008] 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. |
[0x0040] DICOM_SETIMAGE_MFG_MODALITY_LUT_PER_FRAME | 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 Sequence already exists under the Shared Functional Groups Sequence, this flag is ignored. |
[0x0080] DICOM_SETIMAGE_MFG_MODALITY_LUT_SHARED | If the Pixel Value Transformation Sequence does not already exist, it is added under the Shared Functional Groups Sequence. If the Pixel Value Transformation Sequence already exists under the Per-frame Functional Groups Sequence, this flag is ignored. |
Value | Meaning |
---|---|
0 | The function was successful. |
> 0 | 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.
DICOM_SETIMAGE_MFG_MODALITY_LUT_PER_FRAME
DICOM_SETIMAGE_MFG_MODALITY_LUT_SHARED
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 |
---|---|
(0028,1052) | Rescale Intercept |
(0028,1053) | Rescale Slope |
(0028,1054) | 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.
Win32, x64
This example will set Rescale Intercept (0028,1052)
element to -128.0 and Rescale Slope (0028,1053)
element to 1.0
L_INT LDicomDS_SetModalityLUTExample
(
LDicomDS &DS//Input dataset
)
{
L_INT 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;
lstrcpy(ModalityLUTAttributes.szRescaleType,TEXT("UNSPECIFIED"));
// Delete the existing modality LUT,
// although we don't have to !
nRet = DS.DeleteModalityLUT (0, 0);
if(nRet != DICOM_SUCCESS)
return nRet;
//Set rescale slope and intercept
return DS.SetModalityLUT ( 0,
&ModalityLUTAttributes ,// new attributes
NULL ,// no LUT Data
0,0);
}