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.
public class ColorizeGrayCommand : RasterCommand Public Class ColorizeGrayCommandInherits Leadtools.Imageprocessing.Leadtools.ImageProcessing.RasterCommandImplements Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand
public sealed class ColorizeGrayCommand : Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand @interface LTColorizeGrayCommand : LTRasterCommand public class ColorizeGrayCommand extends RasterCommand function Leadtools.ImageProcessing.Core.ColorizeGrayCommand() public ref class ColorizeGrayCommand : public Leadtools.Imageprocessing.Leadtools.ImageProcessing.RasterCommand, Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand This class is available in the Imaging Pro and above toolkits.
The colors from the input images will be colored as follows: Pixel intensities from 0 - 9999 will be Red. Pixel intensities from 10000 - 19999 will be Green. Pixel intensities from 20000 - 29999 will be Blue. Pixel intensities from 30000 - 39999 will be Cyan. Pixel intensities from 40000 - 49999 will be Magenta. Pixel intensities from 50000 - 65535 will be Yellow. (Note: the Threshold value is ignored for the last entry in the GrayColors array.)
For more information on filling the GrayColors array to obtain this result, refer to the example.
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.
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 imageRasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Beauty16.jpg"));// Prepare the commandColorizeGrayCommandData[] 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 commandcommand.Run(image);// Save the resulted imagecodecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "ColorizeGrayResult.Bmp"), RasterImageFormat.Bmp, 24);}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.CoreLeadtools.Examples.Support.SetLicense()Public Sub ColorizeGrayCommandExample()Dim codecs As New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = TrueDim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\Beauty16.jpg"))' Prepare the commandDim i As IntegerDim pGrayColors() As ColorizeGrayCommandDataReDim pGrayColors(5)For i = 0 To 5pGrayColors(i) = New ColorizeGrayCommandDataNextpGrayColors(0).Threshold = 9999pGrayColors(1).Threshold = 19999pGrayColors(2).Threshold = 29999pGrayColors(3).Threshold = 39999pGrayColors(4).Threshold = 49999pGrayColors(5).Threshold = 59999pGrayColors(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)Dim command As ColorizeGrayCommand = New ColorizeGrayCommandcommand.GrayColors = pGrayColors'Call the commandcommand.Run(leadImage)' Save the resulted Imagecodecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "ColorizeGrayResult.Bmp"), RasterImageFormat.Bmp, 24)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.Core;public void ColorizeGrayCommandExample(RasterImage image, Stream outStream){// Prepare the commandColorizeGrayCommandData[] 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 commandcommand.Run(image);// Save result imageRasterCodecs codecs = new RasterCodecs();codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);image.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.CorePublic Sub ColorizeGrayCommandExample(ByVal image As RasterImage, ByVal outStream As Stream)' Prepare the commandDim pGrayColors As ColorizeGrayCommandData() = New ColorizeGrayCommandData(5) {}For i As Integer = 0 To 5pGrayColors(i) = New ColorizeGrayCommandData()Next ipGrayColors(0).Threshold = 9999pGrayColors(1).Threshold = 19999pGrayColors(2).Threshold = 29999pGrayColors(3).Threshold = 39999pGrayColors(4).Threshold = 49999pGrayColors(5).Threshold = 59999pGrayColors(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)Dim command As ColorizeGrayCommand = New ColorizeGrayCommand()command.GrayColors = pGrayColors'Call the commandcommand.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
Leadtools.ImageProcessing.Color.GrayScaleToDuotoneCommand
Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand
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
