Supported in Silverlight, Windows Phone 7
Visual Basic (Declaration) | |
---|---|
Public Class WindowLevelExtCommand Inherits Leadtools.ImageProcessing.RasterCommand Implements IRasterCommand |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As WindowLevelExtCommand |
C# | |
---|---|
public class WindowLevelExtCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
C++/CLI | |
---|---|
public ref class WindowLevelExtCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
Run the WindowLevelExtCommand on an image.
Visual Basic | Copy Code |
---|---|
Public Sub WindowLevelExtCommandExample() Dim codecs As New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")) ' Prepare the command 'Change the image to 16-bit grayscale Dim graycommand As GrayscaleCommand = New GrayscaleCommand(16) Dim command As WindowLevelExtCommand = New WindowLevelExtCommand graycommand.Run(leadImage) Dim minValue As Integer = leadImage.MinValue Dim maxValue As Integer = leadImage.MaxValue Dim minBit As Integer = leadImage.LowBit Dim maxBit As Integer = leadImage.HighBit Dim Size As Integer = (1 << (maxBit - minBit + 1)) Dim LookupTable() As RasterColor16 ReDim LookupTable(Size - 1) ' fill the first half of the LookupTable with RED. Dim x As Integer For x = 0 To Size \ 2 - 1 LookupTable(x) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) Next ' fill the rest with gray values. For x = Size \ 2 To Size - 1 Dim y As Integer = Convert.ToInt32((x - minValue) * RasterColor16.MaximumComponent / (maxValue - minValue)) LookupTable(x) = New RasterColor16(y, y, y) Next command.HighBit = maxBit command.LowBit = minBit command.LookupTable = LookupTable command.Order = RasterByteOrder.Bgr command.Run(leadImage) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
public void WindowLevelExtCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image2.dcm")); // Prepare the command int x; int y; int Size; RasterColor16 [] LookupTable; MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); WindowLevelExtCommand command = new WindowLevelExtCommand(); MinMaxBits.Run(image); MinMaxValues.Run(image); Size = (1 <<(MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); LookupTable = new Leadtools.RasterColor16[Size]; // fill the first half of the LookupTable with RED. for(x = 0; x < Size / 2; x++) LookupTable[x] = new Leadtools.RasterColor16(Leadtools.RasterColor16.MaximumComponent, 0, 0); // fill the rest with gray values. for(x = Size / 2; x < Size; x++) { y = (int)((x - MinMaxValues.MinimumValue) * Leadtools.RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); LookupTable[x] = new Leadtools.RasterColor16(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"; } |
SilverlightCSharp | Copy Code |
---|---|
public void WindowLevelExtCommandExample(RasterImage image, Stream outStream) { // Prepare the command int x; int y; int Size; RasterColor16[] LookupTable; MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); WindowLevelExtCommand command = new WindowLevelExtCommand(); MinMaxBits.Run(image); MinMaxValues.Run(image); Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); LookupTable = new Leadtools.RasterColor16[Size]; // fill the first half of the LookupTable with RED. for (x = 0; x < Size / 2; x++) LookupTable[x] = new Leadtools.RasterColor16(Leadtools.RasterColor16.MaximumComponent, 0, 0); // fill the rest with gray values. for (x = Size / 2; x < Size; x++) { y = (int)((x - MinMaxValues.MinimumValue) * Leadtools.RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); LookupTable[x] = new Leadtools.RasterColor16(y, y, y); } command.HighBit = MinMaxBits.MaximumBit; command.LowBit = MinMaxBits.MinimumBit; command.LookupTable = LookupTable; command.Order = Leadtools.RasterByteOrder.Bgr; command.Run(image); // Save result image RasterCodecs codecs = new RasterCodecs(); codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24); image.Dispose(); } |
SilverlightVB | Copy Code |
---|---|
Public Sub WindowLevelExtCommandExample(ByVal image As RasterImage, ByVal outStream As Stream) ' Prepare the command Dim x As Integer Dim y As Integer Dim Size As Integer Dim LookupTable As RasterColor16() Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand() Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand() Dim command As WindowLevelExtCommand = New WindowLevelExtCommand() MinMaxBits.Run(image) MinMaxValues.Run(image) Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)) LookupTable = New RasterColor16(Size - 1) {} ' fill the first half of the LookupTable with RED. x = 0 Do While x < Size / 2 LookupTable(x) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) x += 1 Loop ' fill the rest with gray values. x = Size / 2 Do While x < Size y = CInt((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)) LookupTable(x) = New RasterColor16(y, y, y) x += 1 Loop command.HighBit = MinMaxBits.MaximumBit command.LowBit = MinMaxBits.MinimumBit command.LookupTable = LookupTable command.Order = RasterByteOrder.Bgr command.Run(image) ' Save result image Dim codecs As RasterCodecs = New RasterCodecs() codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24) image.Dispose() End Sub |
- This command supports 12 and 16-bit grayscale. Support for 12 and 16-bit grayscale images is available only in the Document/Medical toolkits.
- This command does not support 32-bit grayscale images.
- Leadtools.RasterByteOrder.Gray is not supported by this command.
Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by calling WindowLevelExtCommand and specifying RasterWindowLevelMode.PaintAndProcessing for the flags parameter, by using the WindowLevelExtCommand 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 Leadtools.ImageProcessing.Core.WindowLevelCommand for a version of this class using 8-bit lookup tables.
For more information, refer to Introduction to Image Processing With LEADTOOLS.
For more information, refer to Grayscale Images.
System.Object
Leadtools.ImageProcessing.RasterCommand
Leadtools.ImageProcessing.Core.WindowLevelExtCommand
Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)
Reference
WindowLevelExtCommand MembersLeadtools.ImageProcessing.Core Namespace
Introduction to Image Processing With LEADTOOLS
Grayscale Images
WindowLevelCommand Class
ApplyVoiLookupTableCommand Class
Leadtools.RasterPalette.WindowLevelFillLookupTable(Leadtools.RasterColor[],Leadtools.RasterColor,Leadtools.RasterColor,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,Leadtools.RasterPaletteWindowLevelFlags)
Leadtools.ImageProcessing.Color.GrayScaleToDuotoneCommand
Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand
SelectDataCommand Class
ShiftDataCommand Class