Re: analysing a bitmap
- From: "Peter Bauer" <PeterBauer@xxxxxxxx>
- Date: Wed, 25 May 2005 20:29:26 +0200
damn i can't get it to work
"Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:4294b754$0$141$e4fe514c@xxxxxxxxxxxxxxxxx
> "Peter Bauer" <PeterBauer@xxxxxxxx> wrote in message
> news:4294781b$0$26386$9b622d9e@xxxxxxxxxxxxxxxxxx
> [...]
>> now i'm trying to modify this for bitmaps, but i allways get a
>> stack-overflow in the fill() methode.
>> i have no clue whats the problem :(
>
> Well, I'm pretty sure I figured it out. Nothing like a good bicycle
> ride home to clear your head and give you time to mull it over.
>
> The algorithm fails, spectacularly, when you try to fill in an area
> with its existing colour. It should really be wrapped in a function
> that checks whether the first pixel is not already the fill colour.
>
> Otherwise, it simply never stops. It has no reason to. As written,
> it fills an area defined by the original colour of the starting
> pixel, by colouring it the new colour pixel by pixel. It stops when
> the current colour of a neighbouring pixel is different from the
> *old* colour. If the new colour is the same as the old colour, it
> keeps painting and painting but never makes any progress.
>
> I devised several schemes to make the algorithm smarter but they all
> turned out to be unnecessary. If you go to the pixel on your left,
> that function call does not need to look to the pixel on its right
> at all - but this is interesting only if checking its colour is more
> expensive than remembering where you came from last time, and I'm
> not sure that is the case. An earlier scheme remembered _all_
> directions that had been explored, but I proved to myself rather
> quickly that that was flawed to begin with. The proof is left as an
> exercise to the reader.
>
> But no checking is _necessary_ beyond the first pixel. If that has
> the same colour, no painting is necessary at all; it it has a
> different colour, there is a region in that different colour that
> can be filled with the existing algorithm.
>
> Groetjes,
> Maarten Wiltink
>
>
.
- Follow-Ups:
- Re: analysing a bitmap
- From: Maarten Wiltink
- Re: analysing a bitmap
- References:
- analysing a bitmap
- From: Peter Bauer
- Re: analysing a bitmap
- From: Maarten Wiltink
- analysing a bitmap
- Prev by Date: Re: analysing a bitmap
- Next by Date: Using the registry
- Previous by thread: Re: analysing a bitmap
- Next by thread: Re: analysing a bitmap
- Index(es):
Relevant Pages
|
|