Flood filling

Another very important algorithm for segmentation is flood fill, also known as region growing. Most of you who have already worked with popular computer graphic programs, such as Microsoft Paint or GIMP will have probably used the bucket fill or paint bucket tool, which fills an area with a color. Although it might look like a very simple algorithm at first sight, it has a very interesting implementation and has several parameters that can make it work well to segment images.

The idea behind the algorithm is to check for connected components, which are the areas with similar color or brightness, starting from a given point—the so-called seed point—and then examining this particular point's neighbors. These can include either 4 (north, ...

Get OpenCV 3.0 Computer Vision with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.