ColorizeGrayCommand Class (original) (raw)

Summary

Colors an 8, 12 or 16-bit grayscale image. The class changes the color bits/pixel of the image from the specified formats into 24-bit RGB format.

Syntax

C#

Objective-C

C++/CLI

Java

Python

@interface LTColorizeGrayCommand : LTRasterCommand 

public class ColorizeGrayCommand extends RasterCommand

class ColorizeGrayCommand(RasterCommand): 

Example

This example loads a 16-bit grayscale image and then colors it.

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing.Core; public void ColorizeGrayCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Beauty16.jpg")); // Prepare the command ColorizeGrayCommandData[] pGrayColors = new ColorizeGrayCommandData[6]; for (int i = 0; i < 6; i++) pGrayColors[i] = new ColorizeGrayCommandData(); pGrayColors[0].Threshold = 9999; pGrayColors[1].Threshold = 19999; pGrayColors[2].Threshold = 29999; pGrayColors[3].Threshold = 39999; pGrayColors[4].Threshold = 49999; pGrayColors[5].Threshold = 59999; pGrayColors[0].Color = new RasterColor(255, 0, 0); pGrayColors[1].Color = new RasterColor(0, 255, 0); pGrayColors[2].Color = new RasterColor(0, 0, 255); pGrayColors[3].Color = new RasterColor(0, 255, 255); pGrayColors[4].Color = new RasterColor(255, 0, 255); pGrayColors[5].Color = new RasterColor(255, 255, 0); ColorizeGrayCommand command = new ColorizeGrayCommand(); command.GrayColors = pGrayColors; //Call the command command.Run(image); // Save the resulted image codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "ColorizeGrayResult.Bmp"), RasterImageFormat.Bmp, 24); } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }

Leadtools.ImageProcessing.Core Assembly