Converts a grayscale image into a colored one by mixing or replacing the original values of the pixels with one or more new colors. This class is available in the Imaging Pro and above toolkits.
public class GrayScaleToMultitoneCommand : RasterCommand Public Class GrayScaleToMultitoneCommandInherits Leadtools.Imageprocessing.Leadtools.ImageProcessing.RasterCommandImplements Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand
@interface LTGrayscaleToMultitoneCommand : LTRasterCommand public class GrayScaleToMultitoneCommand extends RasterCommand public ref class GrayScaleToMultitoneCommand : public Leadtools.Imageprocessing.Leadtools.ImageProcessing.RasterCommand, Leadtools.Imageprocessing.Leadtools.ImageProcessing.IRasterCommand To have the toolkit generate the array of colors:
If the image is grayscale (not binary) call the GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.Linear. The GrayScaleToMultitoneCommand will take the color(s) set in the Color property and generate a 256 color gradient for each color.
If the image is not grayscale (it is color) call the GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.Linear. The GrayScaleToMultitoneCommand will take the color(s) set in the Color property and generate a 256 color gradient for each color. These colors will be used to change only those pixels in the color image for which Red = Green = Blue.
To use a user-defined array of colors:
If the image is grayscale (not binary) call GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.UserDefined.
If the image is not grayscale (it is color) call GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.UserDefined. (See the expanded explanation in i, ii and iii of (b) above.) These colors will be used to change only those pixels in the color image for which Red = Green = Blue.
For more information, refer to Introduction to Image Processing With LEADTOOLS. For more information, refer to Grayscale Images.
Run the GrayScaleToMultitoneCommand on an image.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing.Color;public void GrayScaleToMultitoneCommandExample(){// Load an imageRasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Beauty16.jpg"));// Prepare the commandGrayScaleToMultitoneCommand command = new GrayScaleToMultitoneCommand();command.Colors = new RasterColor[2];command.Colors[0].R = 255;command.Colors[0].G = 255;command.Colors[0].B = 0;command.Colors[1].R = 255;command.Colors[1].G = 0;command.Colors[1].B = 0;command.Gradient = null;command.Distribution = GrayScaleToMultitoneCommandDistributionType.Linear;command.Tone = GrayScaleToMultitoneCommandToneType.Duotone;command.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNew;command.Run(image);codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24);}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.ColorLeadtools.Examples.Support.SetLicense()Public Sub GrayScaleToMultitoneCommandExample()Dim codecs As New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = TrueDim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\\Beauty16.jpg"))' Prepare the commandDim Colors() As RasterColorReDim Colors(1)Dim command As GrayScaleToMultitoneCommand = New GrayScaleToMultitoneCommandcommand.Colors = Colorscommand.Colors(0).R = 255command.Colors(0).G = 255command.Colors(0).B = 0command.Colors(1).R = 255command.Colors(1).G = 0command.Colors(1).B = 0command.Gradient = Nothingcommand.Distribution = GrayScaleToMultitoneCommandDistributionType.Linearcommand.Tone = GrayScaleToMultitoneCommandToneType.Duotonecommand.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNewcommand.Run(leadImage)codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24)End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing.Color;using Leadtools.Examples;public void GrayScaleToMultitoneCommandExample(RasterImage image, Stream outStream){// Prepare the commandGrayScaleToMultitoneCommand command = new GrayScaleToMultitoneCommand();command.Colors = new RasterColor[2];command.Colors[0].R = 255;command.Colors[0].G = 255;command.Colors[0].B = 0;command.Colors[1].R = 255;command.Colors[1].G = 0;command.Colors[1].B = 0;command.Gradient = null;command.Distribution = GrayScaleToMultitoneCommandDistributionType.Linear;command.Tone = GrayScaleToMultitoneCommandToneType.Duotone;command.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNew;command.Run(image);// Save result imageRasterCodecs codecs = new RasterCodecs();codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);image.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.ColorPublic Sub GrayScaleToMultitoneCommandExample(ByVal image As RasterImage, ByVal outStream As Stream)' Prepare the commandDim command As GrayScaleToMultitoneCommand = New GrayScaleToMultitoneCommand()command.Colors = New RasterColor(1) {}command.Colors(0).R = 255command.Colors(0).G = 255command.Colors(0).B = 0command.Colors(1).R = 255command.Colors(1).G = 0command.Colors(1).B = 0command.Gradient = Nothingcommand.Distribution = GrayScaleToMultitoneCommandDistributionType.Linearcommand.Tone = GrayScaleToMultitoneCommandToneType.Duotonecommand.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNewcommand.Run(image)' Save result imageDim codecs As RasterCodecs = New RasterCodecs()codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)image.Dispose()End Sub
GrayScaleToMultitoneCommand Members
Leadtools.ImageProcessing.Color Namespace
Introduction to Image Processing With LEADTOOLS
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
