Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, June 24, 2015 5:35:49 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

Flood fill, also known as seed fill, bucket fill or boundary fill, is the process of setting the color of a pixel (the start pixel) and all pixels connected to it with a new color. Connected pixels are those adjacent to the start pixel and all the pixels adjacent to them, ad infinitum, provided they are sufficiently close to the start pixel in intensity or color value.
Any surrounding pixels that are not sufficiently close are considered the boundary and are not filled.

An easy way to implement flood fill using LEADTOOLS is to use the Magic Wand function to define a region, then use the Fill command to change the color. When a region is defined in the image, the Fill command will only act on the region. Here's sample code:

void FloodFill(RasterImage LeadImage, int x, int y, int tolerance, RasterColor newColor)
{
   RasterColor toleranceColor = new RasterColor(tolerance, tolerance, tolerance);
   LeadImage.AddMagicWandToRegion(x, y, toleranceColor, toleranceColor, RasterRegionCombineMode.Set);
   if (LeadImage.HasRegion)
   {
      Leadtools.ImageProcessing.FillCommand _fill = new Leadtools.ImageProcessing.FillCommand(newColor);
      _fill.Run(LeadImage);
      LeadImage.MakeRegionEmpty();
   }
}

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.047 seconds.