Sets a region based on the color found at point x, y in the image.
public void AddMagicWandToRegion(int left,int top,RasterColor lowerToleranceColor,RasterColor upperToleranceColor,RasterRegionCombineMode combineMode)
Public Sub AddMagicWandToRegion( _ByVal left As Integer, _ByVal top As Integer, _ByVal lowerToleranceColor As Leadtools.RasterColor, _ByVal upperToleranceColor As Leadtools.RasterColor, _ByVal combineMode As Leadtools.RasterRegionCombineMode _)
public void AddMagicWandToRegion(int left,int top,Leadtools.RasterColor lowerToleranceColor,Leadtools.RasterColor upperToleranceColor,Leadtools.RasterRegionCombineMode combineMode)
- (BOOL)addMagicWandToRegion:(NSInteger)lefttop:(NSInteger)toplowerToleranceColor:(LTRasterColor *)lowTolColorupperToleranceColor:(LTRasterColor *)upTolColorcombineMode:(LTRasterRegionCombineMode)combineModeerror:(NSError **)error
public void addMagicWandToRegion(int left,int top,RasterColor lowerToleranceColor,RasterColor upperToleranceColor,RasterRegionCombineMode combineMode)
function Leadtools.RasterImage.AddMagicWandToRegion(left ,top ,lowerToleranceColor ,upperToleranceColor ,combineMode)
public:void AddMagicWandToRegion(int left,int top,Leadtools.RasterColor lowerToleranceColor,Leadtools.RasterColor upperToleranceColor,Leadtools.RasterRegionCombineMode combineMode)
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.
For color bitmaps:
If the value of the pixel at (x, y) is (125, 125, 125) and lowerToleranceColor is (20,30,15), then the lower stopping point is (105, 95, 110). If upperToleranceColor is (20,30,15), then the upper stopping point is (145,155,140).
For gray scale bitmaps:
The minimum channel tolerance value of lowerToleranceColor will be used to set the lower stopping point, and the value of upperToleranceColor will be used to set the upper stopping point. For example, if the value of the pixel at (x, y) is (125, 125, 125) and lowerToleranceColor is (20,30,15), the smallest value of the triplet (15) will be used to create the lower stopping point of (110,110,110). If upperToleranceColor is (10,25,20), the smallest value of that triplet (10) will be used to create the upper stopping point of (135,135,135).
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in Document/Medical Imaging.
This method supports signed/unsigned data images.
To update an existing region, specify how the new region is to be combined with the existing one by using the combineMode parameter. For more information, refer to RasterRegionCombineMode.
The AddMagicWandToRegion function can use the Extended Grayscale mask. For more information, refer to Grayscale Images
For more information, refer to Creating a Region.
For more information, refer to Saving A Region.
For more information, refer to Working with the Existing Region.
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 LeadtoolsExamples.Common;using Leadtools.Svg;public void AddMagicWandToRegionExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");string destFileName = Path.Combine(ImagesPath.Path, "Image1_AddMagicWandToRegion.bmp");// Load the imageRasterImage image = codecs.Load(srcFileName);// Posterize the image to decrease the number of colorsPosterizeCommand posterize = new PosterizeCommand(16);posterize.Run(image);// Specify a pixel in the upper left of the displayed imageLeadPoint pt = new LeadPoint(image.ImageWidth / 8, image.ImageHeight / 8);// Adjust the point in case the view perspective is not TopLeftpt = image.PointToImage(RasterViewPerspective.TopLeft, pt);// Create a magic wand region at this pointRasterColor 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 blueFillCommand fill = new FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Blue));fill.Run(image);// Save the imagecodecs.Save(image, destFileName, RasterImageFormat.Bmp, 24);image.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.SvgPublic Sub AddMagicWandToRegionExample()Dim codecs As RasterCodecs = New RasterCodecs()Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_AddMagicWandToRegion.bmp")' Load the imageDim image As RasterImage = codecs.Load(srcFileName)' Posterize the image to decrease the number of colorsDim posterize As PosterizeCommand = New PosterizeCommand(16)posterize.Run(image)' Specify a pixel in the upper left of the displayed imageDim pt As LeadPoint = New LeadPoint(image.ImageWidth \ 8, image.ImageHeight \ 8)' Adjust the point in case the view perspective is not TopLeftpt = image.PointToImage(RasterViewPerspective.TopLeft, pt)' Create a magic wand region at this pointDim lowerColor As RasterColor = New RasterColor(20, 30, 150)Dim upperColor As RasterColor = New RasterColor(15, 30, 10)image.AddMagicWandToRegion(pt.X, pt.Y, lowerColor, upperColor, RasterRegionCombineMode.Set)' Fill the region with blueDim fill As FillCommand = New FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Blue))fill.Run(image)' Save the imagecodecs.Save(image, destFileName, RasterImageFormat.Bmp, 24)image.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
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
