public class WindowLevelExtCommand : RasterCommand
@interface LTWindowLevelExtCommand : LTRasterCommand
public class WindowLevelExtCommand
extends RasterCommand
public ref class WindowLevelExtCommand : public RasterCommand
class WindowLevelExtCommand(RasterCommand):
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 WindowLevelCommand for a version of this class using 8-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.
Run the WindowLevelExtCommand on an image.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
public void WindowLevelExtCommandExample()
{
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.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:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.IOException;
import org.junit.*;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.imageprocessing.core.*;
public void windowLevelExtCommandExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.setThrowExceptionsOnInvalidImages(true);
RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "beauty16.jpg"));
// 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.getMaximumBit() - minMaxBits.getMinimumBit() + 1));
lookupTable = new RasterColor16[size];
// fill the first half of the LookupTable with RED
for (x = 0; x < size / 2; x++) {
lookupTable[x] = new RasterColor16(RasterColor16.MAXIMUM_COMPONENT, 0, 0);
}
// fill the rest with gray values
for (x = size / 2; x < size; x++) {
y = (int) (x - minMaxValues.getMinimumValue()) * RasterColor16.MAXIMUM_COMPONENT
/ (minMaxValues.getMaximumValue() - minMaxValues.getMinimumValue());
lookupTable[x] = new RasterColor16(y, y, y);
}
command.setHighBit(minMaxBits.getMaximumBit());
command.setLowBit(minMaxBits.getMinimumBit());
command.setLookupTable(lookupTable);
command.setOrder(RasterByteOrder.BGR);
int change = command.run(image);
assertTrue(change != RasterImageChangedFlags.NONE);
codecs.save(image, combine(LEAD_VARS_IMAGES_DIR, "Result.jpg"), RasterImageFormat.JPEG, 24);
System.out.println("Command run and image saved to: " + combine(LEAD_VARS_IMAGES_DIR, "Result.jpg"));
}
Leadtools.ImageProcessing.Core Namespace
Introduction to Image Processing With LEADTOOLS
ApplyVoiLookupTableCommand Class
Leadtools.ImageProcessing.Color.GrayScaleToDuotoneCommand
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document