Sets the 8-bit lookup table (LUT) of this
RasterImage.
Syntax
Visual Basic (Declaration) | |
---|
Public Sub SetLookupTable( _
ByVal value() As RasterColor _
) |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterImage
Dim value() As RasterColor
instance.SetLookupTable(value)
|
Parameters
- value
- An array of RasterColor structures which represent the lookup table (LUT) of this
RasterImage.
Example
Visual Basic | Copy Code |
---|
Private Sub SetLookupTable()
RasterSupport.Unlock(RasterSupportType.Medical, "Use a valid key here")
DicomEngine.Startup()
RasterCodecs.Startup()
Dim strImagesDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "//LEADTOOLS Images//"
Dim codecs As RasterCodecs = New RasterCodecs()
Dim ds As DicomDataSet = New DicomDataSet()
ds.Load(strImagesDirectory & "IMAGE3.dcm", DicomDataSetLoadFlags.None)
Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PixelData, True)
Dim image As RasterImage = ds.GetImage(element, 0, 16, RasterByteOrder.Gray, DicomGetImageFlags.None)
image.UseLookupTable = True
codecs.Save(image, strImagesDirectory & "BeforeSetLookupTable.bmp", RasterImageFormat.Bmp, 8)
Dim lut As RasterColor() = New RasterColor(CInt(Math.Pow(2, 16)) - 1) {}
Dim cmdMinMax As MinMaxValuesCommand = New MinMaxValuesCommand()
cmdMinMax.Run(image)
Dim maxVal As Integer = cmdMinMax.MaximumValue
Dim minVal As Integer = cmdMinMax.MinimumValue
Dim i As Integer = 0
Do While i < lut.Length
lut(i).R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal))))
lut(i).G = lut(i).R
lut(i).B = lut(i).R
i += 1
Loop
image.SetLookupTable(lut)
codecs.Save(image, strImagesDirectory & "AfterSetLookupTable.bmp", RasterImageFormat.Bmp, 8)
DicomEngine.Shutdown()
End Sub |
C# | Copy Code |
---|
public void SetLookupTable() { RasterSupport.Unlock(RasterSupportType.Medical, "Use a valid key here"); DicomEngine.Startup(); RasterCodecs.Startup(); // Get the path of the LEADTOOLS images directory string strImagesDirectory = LeadtoolsExamples.Common.ImagesPath.Path; // Create a RasterCodecs class for saving out images RasterCodecs codecs = new RasterCodecs(); // Load a dataset DicomDataSet ds = new DicomDataSet(); ds.Load(strImagesDirectory + "IMAGE3.dcm", DicomDataSetLoadFlags.None); // Get the image but do NOT auto-apply any of the LUTs DicomElement element = ds.FindFirstElement(null, DicomTag.PixelData, true); RasterImage image = ds.GetImage(element, 0, 16, RasterByteOrder.Gray, DicomGetImageFlags.None); image.UseLookupTable = true; // Save out the image without any LUTs applied. It should be black codecs.Save(image, strImagesDirectory + "BeforeSetLookupTable.bmp", RasterImageFormat.Bmp, 8); // Create a LUT RasterColor[] lut = new RasterColor[(int)Math.Pow(2, 16)]; // Get the Minimum and Maximum values so we can calculate appropriate LUT values. MinMaxValuesCommand cmdMinMax = new MinMaxValuesCommand(); cmdMinMax.Run(image); int maxVal = cmdMinMax.MaximumValue; int minVal = cmdMinMax.MinimumValue; for (int i = 0; i < lut.Length; i++) { lut[i].R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal)))); lut[i].G = lut[i].R; lut[i].B = lut[i].R; } // Set the new lookup table image.SetLookupTable(lut); // Save out the image with the LUT applied. It should look normal codecs.Save(image, strImagesDirectory + "AfterSetLookupTable.bmp", RasterImageFormat.Bmp, 8); DicomEngine.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also