←Select platform

UseLookupTable Property

Summary
Enables or disables using the lookup table (LUT) of this RasterImage.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool UseLookupTable { get; set; } 
@property (nonatomic, assign, getter=usesLookupTable) BOOL useLookupTable 
public boolean getUseLookupTable(); 
public void setUseLookupTable( 
   boolean booleanValue 
); 
public: 
property bool UseLookupTable { 
   bool get(); 
   void set (    bool ); 
} 
UseLookupTable # get and set (RasterImage) 

Property Value

true to enable using the lookup table (LUT), false to disable it.

Remarks

You can access the lookup table (LUT) with the GetLookupTable and SetLookupTable methods. LUT is only used for 10-16 bit extended grayscale image or 10-16 bit palette color image. To update the palette in 1-8 bit image use SetPalette. For more information, refer to Grayscale Images.

If the value is true, the LUT will be used in all image processing commands and save. If the value is false, the LUT will be used only when painting and the LUT will be ignored when an image processing command is applied or when a file is saved.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
public void SetLookupTable() 
{ 
	DicomEngine.Startup(); 
 
	// Create a RasterCodecs class for saving out images 
	RasterCodecs codecs = new RasterCodecs(); 
 
	// Load a dataset 
	DicomDataSet ds = new DicomDataSet(); 
	ds.Load(Path.Combine(LEAD_VARS.ImagesDir, "DICOM","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, Path.Combine(LEAD_VARS.ImagesDir, "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, Path.Combine(LEAD_VARS.ImagesDir,"DICOM", "AfterSetLookupTable.bmp"), RasterImageFormat.Bmp, 8); 
 
	DicomEngine.Shutdown(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.