Converts a 12 or 16-bit grayscale image to an 8-bit grayscale or a 24-bit RGB image. This class is available in Medical toolkits only.
public class WindowLevelCommand : RasterCommand Public Class WindowLevelCommandInherits Leadtools.Imageprocessing.Leadtools.ImageProcessing.RasterCommandImplements Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand
public sealed class WindowLevelCommand : Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand @interface LTWindowLevelCommand : LTRasterCommand public class WindowLevelCommand extends RasterCommand function Leadtools.ImageProcessing.Core.WindowLevelCommand() public ref class WindowLevelCommand : public Leadtools.Imageprocessing.Leadtools.ImageProcessing.RasterCommand, Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by calling WindowLevel and specifying RasterWindowLevelMode.PaintAndProcessing for the flags parameter, by using the WindowLevelCommand or by loading an image from a file format that supports Window Leveling. If a window-leveled image is saved as any other file format, the image data will be converted before being saved. For more information, refer to Saving Window-Leveled Images. See WindowLevelExtCommand for a version of this class using 16-bit lookup tables. LEADTOOLS supports two types of LUTs for 10-16-bit grayscale images (8-bit LUT and 16-bit LUT). Typical grayscale image display and processing is done using an 8-bit LUT. But, you can also use a 16-bit LUT, which offers more precision. Some special video cards and monitors also support display of grayscale images using a 16-bit LUT. For more information, refer to Introduction to Image Processing With LEADTOOLS. For more information, refer to Grayscale Images. In Silverlight versions of LEADTOOLS, this image processing command will fail if the image data for the RasterImage object is stored internally using a Silverlight WriteableBitmap object. For more information, refer to Image Processing Command Limitations in Silverlight.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;public void WindowLevelCommandExample(){// Load an imageRasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"));// Prepare the commandint x;byte y;int Size;RasterColor[] LookupTable;//Change the image to 16-bit grayscaleGrayscaleCommand graycommand = new GrayscaleCommand(16);MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand();MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand();WindowLevelCommand command = new WindowLevelCommand();graycommand.Run(image);MinMaxBits.Run(image);MinMaxValues.Run(image);Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1));LookupTable = new Leadtools.RasterColor[Size];// fill the first half of the LookupTable with RED.for (x = 0; x < Size / 2; x++)LookupTable[x] = new Leadtools.RasterColor(255, 0, 0);// fill the rest with gray values.for (x = Size / 2; x < Size; x++){y = (byte)((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue));LookupTable[x] = new Leadtools.RasterColor(y, y, y);}command.HighBit = MinMaxBits.MaximumBit;command.LowBit = MinMaxBits.MinimumBit;command.LookupTable = LookupTable;command.Order = Leadtools.RasterByteOrder.Bgr;command.Run(image);}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreLeadtools.Examples.Support.SetLicense()Public Sub WindowLevelCommandExample()Dim codecs As New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = TrueDim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"))' Prepare the command'Change the image to 16-bit grayscaleDim graycommand As GrayscaleCommand = New GrayscaleCommand(16)Dim command As WindowLevelCommand = New WindowLevelCommandgraycommand.Run(leadImage)Dim minValue As Integer = leadImage.MinValueDim maxValue As Integer = leadImage.MaxValueDim minBit As Integer = leadImage.LowBitDim maxBit As Integer = leadImage.HighBitDim Size As Integer = (1 << (maxBit - minBit + 1))Dim LookupTable() As RasterColorReDim LookupTable(Size - 1)' fill the first half of the LookupTable with RED.Dim x As IntegerFor x = 0 To Size \ 2 - 1LookupTable(x) = New RasterColor(255, 0, 0)Next' fill the rest with gray values.For x = Size \ 2 To Size - 1Dim y As Byte = Convert.ToByte((x - minValue) * 255 / (maxValue - minValue))LookupTable(x) = New RasterColor(y, y, y)Nextcommand.HighBit = maxBitcommand.LowBit = minBitcommand.LookupTable = LookupTablecommand.Order = RasterByteOrder.Bgrcommand.Run(leadImage)End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Examples;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;public void WindowLevelCommandExample(RasterImage image, Stream outStream){// Prepare the commandint x;byte y;int Size;RasterColor[] LookupTable;//Change the image to 16-bit grayscaleGrayscaleCommand graycommand = new GrayscaleCommand(16);MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand();MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand();WindowLevelCommand command = new WindowLevelCommand();graycommand.Run(image);MinMaxBits.Run(image);MinMaxValues.Run(image);Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1));LookupTable = new Leadtools.RasterColor[Size];// fill the first half of the LookupTable with RED.for (x = 0; x < Size / 2; x++)LookupTable[x] = new Leadtools.RasterColor(255, 0, 0);// fill the rest with gray values.for (x = Size / 2; x < Size; x++){y = (byte)((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue));LookupTable[x] = new Leadtools.RasterColor(y, y, y);}command.HighBit = MinMaxBits.MaximumBit;command.LowBit = MinMaxBits.MinimumBit;command.LookupTable = LookupTable;command.Order = Leadtools.RasterByteOrder.Bgr;command.Run(image);// Save result imageRasterCodecs codecs = new RasterCodecs();codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);image.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CorePublic Sub WindowLevelCommandExample(ByVal image As RasterImage, ByVal outStream As Stream)' Prepare the commandDim x As IntegerDim y As ByteDim Size As IntegerDim LookupTable As RasterColor()'Change the image to 16-bit grayscaleDim graycommand As GrayscaleCommand = New GrayscaleCommand(16)Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand()Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand()Dim command As WindowLevelCommand = New WindowLevelCommand()graycommand.Run(image)MinMaxBits.Run(image)MinMaxValues.Run(image)Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1))LookupTable = New RasterColor(Size - 1) {}' fill the first half of the LookupTable with RED.x = 0Do While x < Size / 2LookupTable(x) = New RasterColor(255, 0, 0)x += 1Loop' fill the rest with gray values.x = Size / 2Do While x < Sizey = CByte((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue))LookupTable(x) = New RasterColor(y, y, y)x += 1Loopcommand.HighBit = MinMaxBits.MaximumBitcommand.LowBit = MinMaxBits.MinimumBitcommand.LookupTable = LookupTablecommand.Order = RasterByteOrder.Bgrcommand.Run(image)' Save result imageDim codecs As RasterCodecs = New RasterCodecs()codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)image.Dispose()End Sub
Leadtools.ImageProcessing.Core Namespace
Introduction to Image Processing With LEADTOOLS
ApplyVoiLookupTableCommand Class
Leadtools.ImageProcessing.Color.ChannelMixerCommand
Leadtools.ImageProcessing.Effects.DeinterlaceCommand
Leadtools.ImageProcessing.Color.DesaturateCommand
Leadtools.ImageProcessing.Effects.EdgeDetectStatisticalCommand
Leadtools.ImageProcessing.Color.LightControlCommand
Leadtools.ImageProcessing.Effects.SmoothEdgesCommand
Leadtools.ImageProcessing.Color.LocalHistogramEqualizeCommand
Leadtools.ImageProcessing.Color.AddWeightedCommand
Leadtools.ImageProcessing.Color.ColorMergeCommand
Leadtools.ImageProcessing.Color.ColorSeparateCommand
Leadtools.ImageProcessing.Color.MultiplyCommand
Leadtools.ImageProcessing.Color.AutoColorLevelCommand
Leadtools.ImageProcessing.Color.ColorLevelCommand
Leadtools.ImageProcessing.Color.GrayScaleToDuotoneCommand
Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand
Leadtools.ImageProcessing.Effects.RegionHolesRemovalCommand
Leadtools.ImageProcessing.Color.SelectiveColorCommand
Leadtools.ImageProcessing.Effects.SkeletonCommand
Leadtools.ImageProcessing.Color.ChangeHueSaturationIntensityCommand
Leadtools.ImageProcessing.Color.ColorReplaceCommand
Leadtools.ImageProcessing.Color.ColorThresholdCommand
Leadtools.ImageProcessing.Color.MathematicalFunctionCommand
Leadtools.ImageProcessing.Color.SegmentCommand
Leadtools.ImageProcessing.Color.AdaptiveContrastCommand
Leadtools.ImageProcessing.Color.ApplyMathematicalLogicCommand
Leadtools.ImageProcessing.Color.ColorIntensityBalanceCommand
Leadtools.ImageProcessing.Color.ContrastBrightnessIntensityCommand
Leadtools.ImageProcessing.Color.DynamicBinaryCommand
Leadtools.ImageProcessing.Effects.EdgeDetectEffectCommand
Leadtools.ImageProcessing.SpecialEffects.FunctionalLightCommand
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
