If the channel setting for one of the images is the master channel (CombineCommandFlags.SourceMaster, CombineCommandFlags.DestinationMaster, or CombineCommandFlags.ResultMaster) the settings for all the images will be set to master.
In order to speed up widely used image processing filters in LEADTOOLS, the grayscale value (master channel) of a colored image is calculated using the following formulas:
#define CalcGrayValue(r, g, b) ((L_UCHAR)(((L_UCHAR) (((2 * (L_UINT) (r)) + (5 * (L_UINT) (g)) + (L_UINT) (b) + 4) / 8))))
#define CalcGrayValue16(r, g, b) ((L_UINT16) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
#define CalcGrayValue32(r, g, b) ((L_UINT32) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
For more information, refer to Detecting and Enhancing Edges and Lines. For more information, refer to Removing Noise.
Combine Function - Before
Combine Function - After
View additional platform support for this Combine function.
Run the CombineCommand on an image.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Effects;
public void CombineCommandExample()
{
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Image3.cmp"));
// Prepare the command
CombineCommand command = new CombineCommand();
command.SourceImage = image.Clone();
// the rectangle that represents the affected area of the destination image.
command.DestinationRectangle = new LeadRect(image.Width / 8, image.Height / 8, image.Width, image.Height);
// The source point, which represents the source point of the source image which is to be combined.
command.SourcePoint = new LeadPoint(0, 0);
// the operations that will be performed to produce the result, and the channel that will be used to achieve this result.
command.Flags = CombineCommandFlags.OperationAdd | CombineCommandFlags.Destination0 | CombineCommandFlags.SourceRed | CombineCommandFlags.DestinationGreen | CombineCommandFlags.ResultBlue;
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:\LEADTOOLS23\Resources\Images";
}