The ColorizeGrayCommandData class contains information about gray color intensities (Threshold) and the associated colors (Color) used in the coloration methods of the ColorizeGrayCommand class.
public class ColorizeGrayCommandData
Public Class ColorizeGrayCommandData
public sealed class ColorizeGrayCommandData
@interface LTColorizeGrayCommandData : NSObject
public class ColorizeGrayCommandData
function Leadtools.ImageProcessing.Core.ColorizeGrayCommandData()
public ref class ColorizeGrayCommandData
Intensity Range | Color |
0 ~ Threshold[0] | Color[0] |
Threshold[0] ~ Threshold[1] | Color[1] |
Threshold[1] ~ Threshold[2] | Color[2] |
... | ... |
Threshold[N - 3] ~ Threshold[N - 2] | Color[N - 2] |
Threshold[N - 2] ~ Threshold[N - 1] | Color[N - 1] |
Threshold[0] = 1000 | Color[0] is Red |
Threshold[1] = 3000 | Color[1] is Green |
Threshold[2] = 2000 // Notice the threshold here. | Color[2] is Blue |
Threshold[3] = 4000 | Color[3] is Yellow |
For more information, refer to Correcting Colors.
This example loads a 16-bit grayscale image and then colors it.
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core
Public Sub ColorizeGrayCommandDataExample()
Dim codecs As New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\Beauty16.jpg"))
' Prepare the command
Dim i As Integer
Dim pGrayColors() As ColorizeGrayCommandData
ReDim pGrayColors(5)
For i = 0 To 5
pGrayColors(i) = New ColorizeGrayCommandData
Next
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)
Dim command As ColorizeGrayCommand = New ColorizeGrayCommand
command.GrayColors = pGrayColors
'Call the command
command.Run(leadImage)
' Save the resulted Image
codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "ColorizeGrayResult.Bmp"), RasterImageFormat.Bmp, 24)
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
public void ColorizeGrayCommandDataExample()
{
// 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:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
public async Task ColorizeGrayCommandDataExample()
{
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
// Load the image
string srcFileName = @"Assets\Beauty16.jpg";
StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
// 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 = RasterColorHelper.Create(255, 0, 0);
pGrayColors[1].Color = RasterColorHelper.Create(0, 255, 0);
pGrayColors[2].Color = RasterColorHelper.Create(0, 0, 255);
pGrayColors[3].Color = RasterColorHelper.Create(0, 255, 255);
pGrayColors[4].Color = RasterColorHelper.Create(255, 0, 255);
pGrayColors[5].Color = RasterColorHelper.Create(255, 255, 0);
ColorizeGrayCommand command = new ColorizeGrayCommand();
command.GrayColors = pGrayColors;
//Call the command
command.Run(image);
// Save the resulted image
string destFileName = @"ColorizeGrayResult.bmp";
StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
await codecs.SaveAsync(command.DestinationImage, LeadStreamFactory.Create(saveFile), RasterImageFormat.Bmp, 24);
}
using Leadtools;
using Leadtools.Examples;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
public void ColorizeGrayCommandDataExample(RasterImage image, Stream outStream)
{
// 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 result image
RasterCodecs codecs = new RasterCodecs();
codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);
image.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core
Public Sub ColorizeGrayCommandDataExample(ByVal image As RasterImage, ByVal outStream As Stream)
' Prepare the command
Dim pGrayColors As ColorizeGrayCommandData() = New ColorizeGrayCommandData(5){}
For i As Integer = 0 To 5
pGrayColors(i) = New ColorizeGrayCommandData()
Next i
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)
Dim command As ColorizeGrayCommand = New ColorizeGrayCommand()
command.GrayColors = pGrayColors
'Call the command
command.Run(image)
' Save result image
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)
image.Dispose()
End Sub
Products |
Support |
Feedback: ColorizeGrayCommandData Class - Leadtools.ImageProcessing.Core |
Introduction |
Help Version 19.0.2017.3.21
|
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.