AddColorRgbRangeToRegion Method (original) (raw)
Summary
Creates or updates the image region by adding a region that consists of all the pixels that fall in the given RGB color range.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (BOOL)addColorRgbRangeToRegion:(LTRasterColor *)_lowerColor_
upperColor:(LTRasterColor *)_upperColor_
combineMode:(LTRasterRegionCombineMode)_combineMode_
error:(NSError **)error
Parameters
lowerColor
Specifies the minimum (inclusive) R, G and B values. A pixel must have R,G, and B all greater than or equal to lowerColor and less than or equal to upperColor to be included in the region.
upperColor
Specifies the maximum (inclusive) R, G and B values. A pixel must have R,G, and B all greater than or equal to lowerColor and less than or equal to upperColor to be included in the region.
combineMode
The action to take regarding the existing image region, if one is defined.
Example
This example will load an image, add a region corresponding to all colors that have an RGB that includes green but no red and no blue, and run the InvertCommand to show the affected area before saving the image back to disk.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using Leadtools.Svg;
public void AddColorRgbRangeToRegionExample()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_AddColorRgbRangeToRegion.bmp");
// Load the image
RasterImage image = codecs.Load(srcFileName);
// Add the region
RasterColor lowerColor = new RasterColor(0, 1, 0);
RasterColor upperColor = new RasterColor(0, 255, 0);
image.AddColorRgbRangeToRegion(lowerColor, upperColor, RasterRegionCombineMode.Set);
// Draw something on the image
InvertCommand command = new InvertCommand();
command.Run(image);
// Save the image
codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24);
image.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools Assembly