flood-fill

Flood Fill Algorithms

Its the weekend again, and that means I get to play with my hobby project. I've gotten tired of creating test levels by hand, so I thought I'd take a break from engine development and work on a level editor: I'd like to implement a flood fill algorithm in the editor, which would work just like in a paint program. Does anyone have any...

Blob ...how to write non-recursively

I have written the following program, using recursion, but I can't figure out how to write it non-recursively. Every time I run my non-recursive version the numbers are way off. Any suggestions on how to write the following method without recursion? int countCells(color grid[ROWS][COLS], int r, int c) { if (r < 0 || r >= ROWS || c < 0 ...

Algorithm to create hex flood puzzle

I'm creating a puzzle game that, while playable by hand for easy levels, is meant to be solved by computer programs for harder ones. The puzzle is a flood fill on a hexagonal board. You can try a prototype here. Here is how the puzzle works: by choosing a color from the top, you perform a flood fill starting from the upper-left tile. ...

does anyone have a working non-recursive floodfill algorithm written in C?

over the last few days I've been desperately trying to find a working floodfill algorithm. Of the many algorithms i've tried only the 'recursive line fill' one behaves exactly as it should with the major caveat that it occasionally blows the stack. :( I have tried many non-recursive implementations I've found on various websites and the...

argh! what is wrong with this floodfill algorithm?!

I have been using a floodfill algorithm of the stack-based non-recursive variety and it seems to work perfectly except for one annoying situation: if use a line to cut an image in half and then floodfill one half, it floods the whole image! This only happens, however, when I do not put 'borders' around the image. If i draw a rectangle th...

Fill a touch drawn path of CGPoints using OpenGL or CoreGraphics

I have a NSArray of points that make up a path. I can detect when it self-intersects. When this happens, I try to fill the path. First I used CoreGraphics, now I'm using openGl to draw a triangle array. Doesn't work well as you can see in the image. How do I fill only the circular area while leaving the "tail" alone? I was thinking of...

Most efficient way to draw individual pixels in OpenGL ES (Cocos2d-iphone)

I'm writing a flood-fill algorithm...it needs to paint individual pixels. What's the fastest way to do this? At first I thought of using cocos2d's drawpoint, but having 320 * 480 vertices doesn't sound too good. Is there a faster way using memset or something? ...

How to optimally solve the flood fill puzzle?

I like playing the puzzle game Flood-It, which can be played online at: http://floodit.appspot.com/ It's also available as an iGoogle gadget. The aim is to fill the whole board with the least number of successive flood-fills. I'm trying to write a program which can solve this puzzle optimally. What's the best way to approach this pr...

Fill the holes in OpenCV

I have an edge map extracted from edge detection module in OpenCV (canny edge detection). What I want to do is to fill the holes in the edge map. I am using C++, and OpenCV libraries. In OpenCV there is a cvFloodFill() function, and it will fill the holes with a seed (with one of the location to start flooding). However, I am trying to...

Flood fill algorithm

Hi, im working in a simple graphical library in C with turbo C++ because im developing a very primitive version of a paint style program, everyting works well but i can´t get the flood fill algorithm to work. Im using the 4 way flood fill algorithm, first i tried with the recursive version but it only work with small areas, filling large...

How can I perform flood fill with HTML Canvas?

Has anyone implemented a flood fill algorithm in javascript for use with HTML Canvas? My requirements are simple: flood with a single color starting from a single point, where the boundary color is any color greater than a certain delta of the color at the specified point. var r1, r2; // red values var g1, g2; // green values var b1, ...

Fast way to get the bounding rectangle of a flood fill

I need to perform a flood fill on a region of an image. However I do not actually need the resulting image, I only need to know the smallest rectangle containing all pixels that would be changed by the flood fill. Is there a variant of a flood fill algorithm that can compute this rectangle more cheaply than doing a full flood fill? Ex...

Change FloodFill-Algorithm to get Voronoi Territory for two data points?

Hi, I got a grid with two points. I want to calculate the amount squares each point can reach before the other. Currently I implement a FloodFill-Algoritm, which can calculate the amount of squares one point can reach. How can I change that algorithm to do the "flooding" for both points simaltaneuosly or at least one after another? ...

Floodfill in ActionScript 3

Hi guys, I'm trying to write my own floodfill function in ActionScript3, because the one provided by Adobe isn't flexible enough (you can only give one target color, I would like to give a range of target colours.) So, the terrible code I came up with so far is this: private function beginAlgortime(xx:int,yy:int):void { if (bmp.bi...

Floodfill with "layers"

What I want is to create a vector drawing program with layers, but to avoid using transparency / opacity, I want to draw each shape from lowest layer to highest layer onto a single bitmap. For the filling, I want to floodfill the shape. My issue is that, if I have a shape that is drawn then floodfilled, then the next shape overlaps it a ...

[Java] Flood fill using a stack

Hello to everyone :), I am using the recursive Flood fill algorithm in Java to fill some areas of a image. With very small images it works fine, but when de image becomes larger the JVM gives me a Stack Over Flow Error. That's the reason why I have to reimplement the method using a Flood Fill with my own stack. (I read that's the best...

What is a good quick pathfinding algorithm?

What is a good path finding algorithm when you care the amount of time it takes but not how long the path is. Also is there a faster algorithm if you don't care about the path at all but just want to check reachability. (Is Flood Fill a good algorithm for this sort of stuff?) ...

Linked-list representation of disjoint sets - omission in Intro to Algorithms text?

Having had success with my last CLRS question, here's another: In Introduction to Algorithms, Second Edition, p. 501-502, a linked-list representation of disjoint sets is described, wherein each list member the following three fields are maintained: set member pointer to next object pointer back to first object (the set representative...

How to change the background of an image in iPhone app?

Hi, I'm in the process of creating an app and I want to include a color palette where the user can pick a color and apply the color to the background of an image (i.e. change the color of the walls of a furnished room). I've tried google for viable solutions to this but am stumped. Any ideas of how I can go about implementing this? I ran...

iphone - Filling color in closed image

I'm trying to create an app for children. It will have different images. And those images will have different closed shapes like stars, balls or any other similar images. I am aware of how to draw on iphone. I know how to select a color, how to change the brush size etc. What I want to know is to select a color and on touch of image, i...