LDicomDS::SetVOILUT

#include "ltdic.h"

L_UINT16 LDicomDS::SetVOILUT(uVOILUTIndex, pVOILUTAttributes, pLUTData, uDataSize,uFlags)

L_UINT uVOILUTIndex;

index

pDICOMVOILUTATTRIBS pVOILUTAttributes;

pointer to a 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 VOI LUT.

Parameter

Description

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.

pVOILUTAttributes

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

pLUTData

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

uDataSize

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

uFlags

Reserved for future use. Pass 0.

Returns

0

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

LTDIC

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

Platforms

Win32, x64

See Also

Functions:

LDicomDS::GetWindowCount, LDicomDS::GetVOILUTCount, LDicomDS::GetWindow, LDicomDS::SetWindow, LDicomDS::DeleteWindow, LDicomDS::GetVOILUT, LDicomDS::GetVOILUTData, LDicomDS::DeleteVOILUT, Class Members

Topics:

LUT Encoding Overview

 

LUT Encoding: VOI LUT

 

How to Disable the Automatic Loading of the default DICOM IOD Table

Example

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

L_INT LDicomDS_SetVOILUTExample( LDicomDS &InDS, L_BOOL bAdd ) 
{ 
   L_INT                nRet; 
   DICOMVOILUTATTRIBS   VOILUTAttribs ={0}; 
   L_UINT               uVOILUTCount=0; 
   L_UINT16             *pVOILUTData = NULL; 
   L_UINT               uDataSize = 0; 
   L_INT                nLUTIndex; 
   L_UINT               uNewLUTIndex = 0; 
   // Remember  to set the size for each structure 
   VOILUTAttribs.uStructSize = sizeof(DICOMVOILUTATTRIBS); 
   VOILUTAttribs.LUTDescriptor.uStructSize = sizeof(DICOMLUTDESCRIPTOR); 
   // Get the number of VOI LUT(s) in the file 
   nRet = InDS.GetVOILUTCount (&uVOILUTCount); 
   if(nRet != DICOM_SUCCESS) 
   { 
      return nRet; 
   } 
   if(uVOILUTCount>0) 
   { 
      // Get he attributes of  the first VOI LUT 
      nRet = InDS.GetVOILUT (0,&VOILUTAttribs,sizeof(DICOMVOILUTATTRIBS),0); 
      if(nRet != DICOM_SUCCESS) 
      { 
         return nRet; 
      } 
      uDataSize = VOILUTAttribs.LUTDescriptor.uNumberOfEntries; 
      pVOILUTData = (L_UINT16*)malloc(uDataSize* sizeof(L_UINT16)); 
      if(!pVOILUTData) 
      { 
         return DICOM_ERROR_MEMORY; 
      } 
      // Get the LUT data 
      nRet = InDS.GetVOILUTData (0,pVOILUTData,uDataSize,0); 
      if(nRet != DICOM_SUCCESS) 
      { 
         free(pVOILUTData); 
         return nRet; 
      } 
      // Remap the data 
      for(nLUTIndex = 0; nLUTIndex <= (L_INT)(uDataSize-1); nLUTIndex++) 
      { 
         pVOILUTData[nLUTIndex] = pVOILUTData[nLUTIndex]/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(nLUTIndex = 0; nLUTIndex <= (L_INT)(uDataSize-1); nLUTIndex++) 
      { 
         pVOILUTData[nLUTIndex] = (L_UINT16)nLUTIndex; 
      } 
   } 
   uNewLUTIndex = uVOILUTCount; 
   if(!bAdd) 
   { 
      // Delete existing LUT 
      nRet = InDS.DeleteVOILUT (0); 
      if(nRet != DICOM_SUCCESS) 
      { 
         free(pVOILUTData); 
         return nRet; 
      } 
      uNewLUTIndex = 0 ; 
   } 
   // Set the new LUT 
   nRet = InDS.SetVOILUT(uNewLUTIndex,&VOILUTAttribs,pVOILUTData,uDataSize,0); 
   if(nRet != DICOM_SUCCESS) 
   { 
      free(pVOILUTData); 
      return nRet; 
   } 
   if(pVOILUTData) 
   { 
      free(pVOILUTData); 
   } 
   return DICOM_SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS DICOM C++ Class Library Help