AddMagicWandToRegion Method (original) (raw)

Summary

Sets a region based on the color found at point (x,y) in the image.

Syntax

C#

Objective-C

C++/CLI

Java

Python

- (BOOL)addMagicWandToRegion:(NSInteger)_left_ top:(NSInteger)_top_ lowerToleranceColor:(LTRasterColor *)lowTolColor upperToleranceColor:(LTRasterColor *)upTolColor combineMode:(LTRasterRegionCombineMode)_combineMode_ error:(NSError **)error

Parameters

left
X coordinate of a point. The color of the specified point will be used to set the region.

top
Y coordinate of a point. The color of the specified point will be used to set the region.

lowerToleranceColor
Lower tolerance values that set the lower stopping point for the region.

upperToleranceColor
Upper tolerance values that set the upper stopping point for the region.

combineMode
The action to take regarding the existing image region, if one is defined.

Example

This example will load an image, set a magic wand region to it, and fill the region with blue 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 AddMagicWandToRegionExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_AddMagicWandToRegion.bmp"); // Load the image RasterImage image = codecs.Load(srcFileName); // Posterize the image to decrease the number of colors PosterizeCommand posterize = new PosterizeCommand(16); posterize.Run(image); // Specify a pixel in the upper left of the displayed image LeadPoint pt = new LeadPoint(image.ImageWidth / 8, image.ImageHeight / 8); // Adjust the point in case the view perspective is not TopLeft pt = image.PointToImage(RasterViewPerspective.TopLeft, pt); // Create a magic wand region at this point RasterColor lowerColor = new RasterColor(20, 30, 150); RasterColor upperColor = new RasterColor(15, 30, 10); image.AddMagicWandToRegion(pt.X, pt.Y, lowerColor, upperColor, RasterRegionCombineMode.Set); // Fill the region with blue FillCommand fill = new FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Blue)); fill.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

Convert(byte[],int,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],int,int,int,RasterConvertBufferFlags) Method

Convert(byte[],int,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],RasterColor16[],RasterColor16[],int,int,int,RasterConvertBufferFlags) Method

Convert(IntPtr,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],int,int,int,RasterConvertBufferFlags) Method

Convert(IntPtr,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],RasterColor16[],RasterColor16[],int,int,int,RasterConvertBufferFlags) Method