RSS/Atom feed Twitter
Site is read-only, email is disabled

Polymorphic floodfill boundary test

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

Polymorphic floodfill boundary test Torbjörn Rathsman 22 Mar 16:54
  Polymorphic floodfill boundary test Mikael Magnusson 23 Mar 18:42
Torbjörn Rathsman
2012-03-22 16:54:57 UTC (over 12 years ago)

Polymorphic floodfill boundary test

I do not know how the floodfill decide if it comes to a boundary or not, but I guess that it always sampels information from the point where I clicked. However, sometimes another test would be more useful. This piece of code is polymorphic in boundary check:

class Graymap {
public:
Graymap(unsigned int width,unsigned int height) {
data=new unsigned char[width*height]; memset(data,0,width*height);
p_matrix=new unsigned char*[height]; for(unsigned int i=0;i Q;

FloodfillNode node={x,y}; // 2. Add node to Q.
Q.push_back(node);
// 3. For each element n in Q:
while(!Q.empty())
{
FloodfillNode n=Q.front();
Q.pop_front();

// 3a Set w and e equal to n. FloodfillNode w=n;
FloodfillNode e=n;
assert(!w.x
{
// 3c2 If we have not been at the pixel one line above before // And this pixel does not lie on the boundary if(!dirty(e.x,e.y+1) && !boundaryAt(e.x,e.y+1)) {Q.push_back((FloodfillNode){e.x,e.y+1});} }
e.x++;
}
}
}

One way to implement FloodfillConditionBoundary besides the traditional one is to check the magnitude of the gradient vector at current pixel. This would be useful if one has a picture with a smooth gradient surrounded by a sharp edge and want to replace the smooth gradient with one solid color. If I want to add the feature myself, where do I start?

Mikael Magnusson
2012-03-23 18:42:13 UTC (over 12 years ago)

Polymorphic floodfill boundary test

On 22 March 2012 17:54, Torbjörn Rathsman wrote:

I do not know how the floodfill decide if it comes to a boundary or not, but I guess that it always sampels information from the point where I clicked. However, sometimes another test would be more useful. This piece of code is polymorphic in boundary check:

One way to implement FloodfillConditionBoundary besides the traditional one is to check the magnitude of the gradient vector at current pixel. This would be useful if one has a picture with a smooth gradient surrounded by a sharp edge and want to replace the smooth gradient with one solid color. If I want to add the feature myself, where do I start?

Clone the gimp git repo, find the code that does flood filling, modify it to add your method and figure out how to add the option to the gui and pass it down to that layer. Files that would be interesting include,
app/tools/gimpbucketfilltool.c
app/core/gimpimage-contiguous-region.c app/core/gimpdrawable-bucket-fill.c

It's funny, I thought about this exact thing today.