Floodfill: segment stack overflow

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Floodfill: segment stack overflow

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Floodfill: segment stack overflow

Post by fmw42 »

try quoting your rgb colors and see if that helps.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Floodfill: segment stack overflow

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Floodfill: segment stack overflow

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Floodfill: segment stack overflow

Post by snibgo »

Many thanks.
snibgo's IM pages: im.snibgo.com
Post Reply