Getting and setting a non-linear VOI LUT Example for Visual Basic
' This example will add a new VOI LUT to the dataset or
' replace the existing one(s)
Dim VOILUTAttributes As LVOILUTAttributes
Dim iRet As Integer
Dim lVOILUTCount As Long
Dim lLUTIndex As Long
Dim lNewLUTIndex As Long
Dim lDataSize As Long
Dim LUTData As Variant
Dim bAddVOILUT As Boolean
bAddVOILUT = True
lVOILUTCount = 0
lNewLUTIndex = 0
' Get the number of VOI LUT(s) in the file
lVOILUTCount = LEADDICOM1.VOILUTCount
If (lVOILUTCount > 0) Then
' Get he attributes of the first VOI LUT
iRet = LEADDICOM1.GetVOILUTAttributes (0, 0)
If (iRet <> 0) Then
MsgBox ("error")
Exit Sub
End If
Set VOILUTAttributes = LEADDICOM1.VOILUTAttributes
lDataSize = VOILUTAttributes.LUTDescriptorNumberOfEntries
' Get the LUT data
'ReDim LUTData(lDataSize)
iRet = LEADDICOM1.GetVOILUTData(0, LUTData, 0)
If (iRet <> 0) Then
MsgBox ("error")
Exit Sub
End If
' Remap the data
For lLUTIndex = 0 To (lDataSize - 1)
LUTData(lLUTIndex) = LUTData(lLUTIndex) / 2
Next
Else
Set VOILUTAttributes = LEADDICOM1.VOILUTAttributes
' Define our own LUT
VOILUTAttributes.LUTDescriptorFirstMapped = 0
VOILUTAttributes.LUTDescriptorEntryBits = 16
VOILUTAttributes.LUTDescriptorNumberOfEntries = &H10000
lDataSize = VOILUTAttributes.LUTDescriptorNumberOfEntries
ReDim LUTData(lDataSize)
For lLUTIndex = 0 To (lDataSize - 1)
LUTData(lLUTIndex) = lLUTIndex
Next
End If
lNewLUTIndex = lVOILUTCount
If (bAddVOILUT = False) Then
' Delete existing LUT
iRet = LEADDICOM1.DeleteVOILUT(0)
If (iRet <> 0) Then
MsgBox ("error")
Exit Sub
End If
lNewLUTIndex = 0
End If
' Set the new LUT
iRet = LEADDICOM1.SetVOILUT (lNewLUTIndex, LUTData, 0)
If (iRet <> 0) Then
MsgBox ("error")
Exit Sub
End If