L_DicomSetVOILUT

#include "ltdic.h"

L_LTDIC_API L_UINT16 L_DicomSetVOILUT(hDS, uVOILUTIndex, pVOILUTAttributes, pLUTData, uDataSize, uFlags)

Sets the attributes that describe the VOI LUT.

Parameters

HDICOMDS hDS

A DICOM handle.

L_UINT uVOILUTIndex

Index to the VOI LUT to be set. According to the DICOM standard one or more items could exist under one VOI LUT Sequence (0028,3010), use this index to specify which item to update. This index is zero-based.

pDICOMVOILUTATTRIBS pVOILUTAttributes

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

L_UINT16 *pLUTData

Pointer to the buffer that holds the "LUT Data" (0028,3006), this pointer cant be NULL.

L_UINT uDataSize

Size of the buffer pointed to by pLUTData , cant be 0.This value should at least equal pVOILUTAttributes->LUTDescriptor.uNumberOfEntries.

L_UINT uFlags

Reserved for future use. Pass 0.

Returns

Value Meaning
DICOM_SUCCESS The function was successful.
>0 An error occurred. Refer to Return Codes.

Comments

This function will set the attributes of the VOI LUT. Before calling this function, initialize pVOILUTAttributes->uStructSize to be sizeof(DICOMVOILUTATTRIBS) and initialize all the members of the structure.

The size of the input buffer should at least equal the number of entries in the lookup table.

According to the DICOM standard pVOILUTAttributes->LUTDescriptor. uNumberOfEntries should be set to 0 if the number of entries in the lookup table is 2^16, however you should NOT do that when calling this function. This function will handle correctly setting the value inside the dataset.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example will add a new VOI LUT to the dataset or replace the existing one(s)

#define SET_SIZE(p) (p)->uStructSize = sizeof(*(p)); 
 
L_INT DicomSetVOILUTExample(HDICOMDS hDicomDS, L_BOOL bAdd) 
{ 
   DICOMVOILUTATTRIBS   VOILUTAttribs ={0}; 
   L_UINT16             uRet; 
   L_UINT               uVOILUTCount=0; 
   L_UINT16             *pVOILUTData = NULL; 
   L_UINT               uDataSize = 0; 
   L_UINT               uLUTIndex; 
   L_UINT               uNewLUTIndex = 0; 
 
   // Remember  to set the size for each structure 
   SET_SIZE(&VOILUTAttribs); 
   SET_SIZE(&VOILUTAttribs.LUTDescriptor); 
 
   // Get the number of VOI LUT(s) in the file 
   uRet = L_DicomGetVOILUTCount(hDicomDS,&uVOILUTCount); 
   if(uRet != DICOM_SUCCESS) 
      return uRet; 
 
   if(uVOILUTCount>0) 
   { 
      // Get he attributes of  the first VOI LUT 
      uRet = L_DicomGetVOILUT(hDicomDS,0,&VOILUTAttribs,sizeof(DICOMVOILUTATTRIBS),0); 
      if(uRet != DICOM_SUCCESS) 
         return uRet; 
 
      uDataSize = VOILUTAttribs.LUTDescriptor.uNumberOfEntries; 
      pVOILUTData = (L_UINT16*)malloc(uDataSize* sizeof(L_UINT16)); 
      if(!pVOILUTData) 
         return DICOM_ERROR_MEMORY; 
 
      // Get the LUT data 
      uRet = L_DicomGetVOILUTData(hDicomDS,0,pVOILUTData,uDataSize,0); 
      if(uRet != DICOM_SUCCESS) 
      { 
         free(pVOILUTData); 
         return uRet; 
      } 
 
      // Remap the data 
      for(uLUTIndex = 0; uLUTIndex <= (uDataSize-1); uLUTIndex++) 
         pVOILUTData[uLUTIndex] = pVOILUTData[uLUTIndex]/2; 
   } 
   else 
   { 
      // Define our own LUT 
      VOILUTAttribs.LUTDescriptor.nFirstStoredPixelValueMapped = 0; 
      VOILUTAttribs.LUTDescriptor.uEntryBits                   = 16; 
      VOILUTAttribs.LUTDescriptor.uNumberOfEntries             = 0x10000; 
      uDataSize = VOILUTAttribs.LUTDescriptor.uNumberOfEntries; 
      pVOILUTData = (L_UINT16*)malloc(uDataSize* sizeof(L_UINT16)); 
      if(!pVOILUTData) 
         return DICOM_ERROR_MEMORY; 
 
      memset(pVOILUTData,0,uDataSize* sizeof(L_UINT16)); 
      for(uLUTIndex = 0; uLUTIndex<= (uDataSize-1); uLUTIndex++) 
         pVOILUTData[uLUTIndex] = (L_UINT16)uLUTIndex; 
   } 
   uNewLUTIndex = uVOILUTCount; 
   if(!bAdd) 
   { 
      // Delete existing LUT 
      uRet = L_DicomDeleteVOILUT(hDicomDS,0); 
      if(uRet != DICOM_SUCCESS) 
      {   
         free(pVOILUTData); 
         return uRet; 
      } 
      uNewLUTIndex = 0 ; 
   } 
 
   // Set the new LUT 
   uRet = L_DicomSetVOILUT(hDicomDS,uNewLUTIndex,&VOILUTAttribs,pVOILUTData,uDataSize,0); 
 
   if(pVOILUTData) 
      free(pVOILUTData); 
   return uRet; 
} 

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

LEADTOOLS DICOM C API Help