Page 1 of 1

Floodfill: segment stack overflow

Posted: 2013-01-26T13:15:52-07:00
by snibgo
Input image file: https://www.dropbox.com/s/fq1wj6ahwfk3nxc/stackOv.png

The image is mostly gray, with a number of green (78,211,51) pixels, and a 1 pixel gray border. Windows 7 command:

Code: Select all

"%IMG681%convert" ^
    stackOv.png ^
    -fill rgb(1,2,3) ^
    -bordercolor "rgb(78,211,51)" ^
    -draw "color 0,0 filltoborder" ^
    x.png
On 6.8.1-10 and various older versions, the command gives:

Code: Select all

convert.exe: Segment stack overflow `stackOv.png' @ error/paint.c/FloodfillPaintImage/295.
The alternative floodfill gives the same error:

Code: Select all

"%IMG681%convert" ^
    stackOv.png ^
    -fill rgb(1,2,3) ^
    -floodfill 0x0 rgb(78,211,51) ^
    y.png
I suppose the required stacksize for a floodfill can only be estimated in advance. I have a vague memory that it is set as three times the maximum dimension. Can it be automatically resized as required? Failing that, can we have a "define" that we can use for awkward images such as this one?

I am using this to identify grey pixels that are entirely surrounded by green pixels, as part of a chain for image segmentation and simplification. It generally works fine, but not on this image.

Re: Floodfill: segment stack overflow

Posted: 2013-01-26T13:59:11-07:00
by fmw42
try quoting your rgb colors and see if that helps.

Re: Floodfill: segment stack overflow

Posted: 2013-01-26T14:09:58-07:00
by snibgo
Quoteing colors makes no difference. It isn't usually required in Windows, unless the command is part of an "if" or "for" (because Windows than gets confused about brackets).

For most images, the command works fine. But this one needs a deeper stack.

Re: Floodfill: segment stack overflow

Posted: 2013-01-26T15:08:21-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.2-0 Beta available by sometime tomorrow. Thanks.

Re: Floodfill: segment stack overflow

Posted: 2013-01-26T17:28:29-07:00
by snibgo
Many thanks.