Thread: FloodFill stack overflow

  1. #16
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    >except that the floodfill quality suffers

    how's that? the idea of segmenting the target image, checking adjacency, and running through your call with a maximum reiterative depth should work as well as if you didn't have the problem of the stack. and i might do this before dealing with the stack manually, but as i'm aware you are more handy with the stack than i am so it's at your discretion...
    hasafraggin shizigishin oppashigger...

  2. #17
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yes the quality does suffer. Since the algorithm is recursive, any small adjustment to the main algo, or the way in which it is called can cause catastrophic effects. Remember, that one mistake or incosistency will be multiplied literally thousands of times resulting in poor floodfill.

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656

  4. #19
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    well it doesn't have be completely reiterative... for example call a setup function which does call the filling function with adjacently connected solid colorstate... if your maximum possibly filled coordinate plane is 640 by 480, call every hmm... 10 pixels [2d isometricallly tho, since those are the nature of the rate of spreading in your function...]... hmm we'll have to talk about this in live bubba, get online if you can... asap... it'd be easier to describe... oh, or you could use salem's references btw, but that wouldn't be as fun would it! DOS- ON!
    hasafraggin shizigishin oppashigger...

  5. #20
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Salem you are talking about the parity algo. You check on the line that was clicked and go left and right from origin. If the value is 1, you have left the figure, if the number is 2, you are back in the figure, if the number is 3, draw a line on current scanline between 2 and 3, and so on, and so on.

    That would work. And it should fill arbitrary shapes. I saw that algo in my research, I just was not sure whether to use it or not.

    Similar to the polygon fill algo which is used to get a solid fill of polygons at an arbitrary angle.


    There is one problem, that I can see. What if there is another figure left/right of the current figure and the same color as the current one, but not attached to the current figure. It would still fill that shape since it met the requirements.

  6. #21
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    The second link looks more promising than the first. I need to fill an area that does not have defined points - like drawing a shape in a drawing program and then filling it.

    I already know how to fill/texture vertex based polies.

    Thanks Salem for the links. I looked through several pages of searches, but did not find the second link. I did find the first on my own, however.

  7. #22
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    oh i see the behaivior now... if you do unwinding with a switch on the reiterative statement, [setting a static unwinding flag, which if set takes the case of an empty function, thus returning until the depth of recursion is to a lower level], you'd have to save the coordinates where to redo the loop, as well as save those coordinates where the path diverged [first began to reiterate, to fill the left holes after each unwinding which are lost when you lose the recursion from manual unwinding]. Hmm that's a mouthful...
    hasafraggin shizigishin oppashigger...

  8. #23

    Question

    Hey. I am new to C++ but from what i have read of this thread, the stack is receiving every single parameter you pass, and thus making it stack up very quickly. (f i am wrong in my thinking anywhere, feel free to let me know)

    In order to lessen your parameters, you could use a static variable or a global variable to get the parameters through without using them as parameters, or you could group parameters together with a class or struct and just pass that (or a ref to that if speed is a concern).

    I may be wrong!

    thanx for taking the time to read.

    ~Inquirer

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack overflow errors in 3 areas
    By ulillillia in forum C Programming
    Replies: 13
    Last Post: 04-29-2007, 03:20 PM
  2. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM