flood-fill

a working non-recursive floodfill algorithm written in C?

拈花ヽ惹草 提交于 2019-11-27 12:27:34
I've been 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 and they have all been exceptionally tempermental: either they leave gaps in strange places, or flood the whole area (when they should be enclosed). Anyone has a NON-recursive floodfill working sourcecode written in C (or c++ that isn't too heavily OOP and I can disentangle easily enough)? Here's some C++ code that does

How to optimally solve the flood fill puzzle?

落爺英雄遲暮 提交于 2019-11-27 09:32:37
问题 I like playing the puzzle game Flood-It, which can be played online at: https://www.lemoda.net/javascript/flood-it/game.html 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 problem? Ideally I want to use the A* algorithm, but I have no idea what should be the function estimating the number of steps left. I did

Preserve painting after resize or refresh

两盒软妹~` 提交于 2019-11-27 04:54:00
问题 How can I preserve the painting I drew on a picturebox? I draw a circle, and fill it via the ExtFloodFill API. This works fine. When I resize the form (or minimize it) and resize it back to its original size part of the painting is gone. When I refresh the picturebox the painting will be gone completely I tried to repaint it in the Paint event, but this caused it to be repainted continuously as the painting itself triggered the Paint event as well. See below for a test project. When you click

Flood Fill Algorithms

扶醉桌前 提交于 2019-11-27 04:34:18
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: Level Editor http://gfilter.net/junk/Editor.JPG 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 pointers on what technique would work good for me here? The level is just a 2d array, so it could be considered the same as a bitmap really. Thanks! The Wikipedia article is pretty good. As long as your grids are

OpenCV floodfill with mask

柔情痞子 提交于 2019-11-27 04:19:31
问题 The documentation for OpenCV's floodfill function states: The function uses and updates the mask, so you take responsibility of initializing the mask content. Flood-filling cannot go across non-zero pixels in the mask. For example, an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask in multiple calls to the function to make sure the filled area does not overlap. How does the function update the mask? Does it set all the pixels within the

Android flood-fill algorithm

心不动则不痛 提交于 2019-11-27 03:24:30
Does anyone know a iterative and efficient algorithm for flood-fill? Or is there any way to implement recursive floodfill algorithm without stack overflow error? Tried the one @ Flood fill using a stack but i cant find a way to work on white and black image. Somebody ported J. Dunlap's Queue-Linear Flood Fill Algorithm to android here . I've tried it and it's pretty fast. I've modified the copyImage() method which originally makes use of a class called Utilities which the author hasn't provided. public class QueueLinearFloodFiller { protected Bitmap image = null; protected int[] tolerance =

OpenCV Skin Detection

让人想犯罪 __ 提交于 2019-11-27 02:54:10
问题 I've been doing some skin detection but can't get a smooth one. The image below contains the input (left) and output (right) using the code also attached below. Now, the desired output should have been the bottom most image (the one that is smooth on the edges and doesn't have holes within). How do I achieve this output? A sample code on where to start would be of great help. Input (left) and Incorrect output (right): Desired output: Code to generate the Incorect output: #include <opencv2

How can I perform flood fill with HTML Canvas?

送分小仙女□ 提交于 2019-11-26 20:47:59
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, b2; // blue values var actualColorDelta = Math.sqrt((r1 - r2)*(r1 - r2) + (g1 - g2)*(g1 - g2) + (b1 - b2)*(b1 - b2)) function floodFill(canvas, x, y, fillColor, borderColorDelta) { ... } Update: I wrote my own implementation of flood fill, which follows. It is

Fill the holes in OpenCV [duplicate]

与世无争的帅哥 提交于 2019-11-26 18:37:40
This question already has an answer here: Filling holes inside a binary object 7 answers 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 fill all the interior holes without knowing the seeds.(similar to imfill() in MATLAB) Q1: how to find all the seeds, so that I could apply 'cvFloodFill()'? Q2: how to

a working non-recursive floodfill algorithm written in C?

强颜欢笑 提交于 2019-11-26 18:11:35
问题 I've been 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 and they have all been exceptionally tempermental: either they leave gaps in strange places, or flood the whole area (when they should be enclosed). Anyone has a NON-recursive floodfill working sourcecode written in C (or