public int[] Mask { get; set; }
@property (nonatomic, assign, nullable) const unsigned int *mask;
public int[ getMask();
public void setMask(
int[] int[Value
);
Mask # get and set (RemapHueCommand)
Lookup table that identifies which values in the HueTable, SaturationTable and ValueTable properties are valid. If Mask[i] is non-zero, then the HueTable, SaturationTable and ValueTable properties are to be used. If Mask[i] is 0 then the HueTable, SaturationTable and ValueTable properties are ignored. If Mask is null, all entries in the HueTable, SaturationTable and ValueTable properties are used.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Color;
public int INCREMENT_S1(int x, int Length)
{
return ((x + 1) % Length);
}
public int DECREMENT_S1(int x, int Length)
{
return ((x + (Length - 1)) % Length);
}
public int ADD_S1(int x, int y, int Length)
{
return ((x + y) % Length);
}
public void RemapHueCommandCommandExample()
{
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"));
// Prepare the command
int[] MaskTable;
int[] HueTable;
RasterHsvColor hsvRef;
int HueGreen, HueChange;
int Change;
int i, Count;
int Length;
if (image.BitsPerPixel >= 48)
Length = 0x10000;
else if (!(image.BitsPerPixel == 16 || image.BitsPerPixel == 12))
Length = 256;
else if (image.GetLookupTable() != null && image.UseLookupTable)
Length = 256;
else
Length = (1 << image.BitsPerPixel);
//Allocate tables
MaskTable = new int[Length];
HueTable = new int[Length];
//Initialize tables
for (i = 0; i < Length; i++)
{
MaskTable[i] = 0;
HueTable[i] = i;
}
//Get the hue for green
hsvRef = RasterHsvColor.FromRasterColor(new RasterColor(0, 255, 0));
HueGreen = hsvRef.H;
//Obtain new hue
hsvRef = RasterHsvColor.FromRasterColor(new RasterColor(255, 128, 0));
Change = (int)hsvRef.H - (int)HueGreen;
HueChange = (Change > 0) ? (int)Change : (int)(Change + Length - 1);
HueGreen *= (Length - 1) / 255;
HueChange *= (Length - 1) / 255;
//Set values in HueTable, MaskTable
HueTable[HueGreen] = (HueTable[HueGreen] + HueChange);
MaskTable[HueGreen] = 1;
//set the hues near green (+/- 15)
Count = (15 * (Length - 1)) / 255;
for (i = INCREMENT_S1(HueGreen, Length); Count > 0; i = INCREMENT_S1(i, Length), Count--)
{
HueTable[i] = ADD_S1(HueTable[i], HueChange, Length);
MaskTable[i] = 1;
}
Count = (15 * (Length - 1)) / 255;
for (i = DECREMENT_S1(HueGreen, Length); Count > 0; i = DECREMENT_S1(i, Length), Count--)
{
HueTable[i] = ADD_S1(HueTable[i], HueChange, Length);
MaskTable[i] = 1;
}
RemapHueCommand command = new RemapHueCommand(MaskTable, HueTable, null, null, Length);
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:\LEADTOOLS22\Resources\Images";
}
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
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.