Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Algorithms
  4. help regarding the flood fill algorithm

help regarding the flood fill algorithm

Scheduled Pinned Locked Moved Algorithms
algorithmshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    niconicx
    wrote on last edited by
    #1

    can anyone help me. i have a project that requires me to look for an algorithm,study it, simulate it, the look for the problems of the algorithm when applied to an application.. i chose the "flood fill algorithm" but too bad, i can't seem to find an problems with it i chose the linear flood fill,, thanks in advance

    C 1 Reply Last reply
    0
    • N niconicx

      can anyone help me. i have a project that requires me to look for an algorithm,study it, simulate it, the look for the problems of the algorithm when applied to an application.. i chose the "flood fill algorithm" but too bad, i can't seem to find an problems with it i chose the linear flood fill,, thanks in advance

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      here's the general algorithm, in pseudo-code:

      startpoint = start point of fill
      startcolor = color of pixel at startpoint

      fill(startpoint, fillcolor, startcolor);

      fill(point p, color fillcolor, color startcolor)
      {
      if (p.color != startcolor)
      {
      p.color = fillcolor;

       // fill the surrounding four pixels
       fill(point(p.x+1, p.y), fillcolor, startcolor);
       fill(point(p.x+1, p.y+1), fillcolor, startcolor);
       fill(point(p.x-1, p.y), fillcolor, startcolor);
       fill(point(p.x-1, p.y-1), fillcolor, startcolor);
      

      }
      }

      pro-tip: this is recursive, which can be a problem for large fills. but you can eliminate the recursion using a stack.

      image processing toolkits | batch image processing

      N 1 Reply Last reply
      0
      • C Chris Losinger

        here's the general algorithm, in pseudo-code:

        startpoint = start point of fill
        startcolor = color of pixel at startpoint

        fill(startpoint, fillcolor, startcolor);

        fill(point p, color fillcolor, color startcolor)
        {
        if (p.color != startcolor)
        {
        p.color = fillcolor;

         // fill the surrounding four pixels
         fill(point(p.x+1, p.y), fillcolor, startcolor);
         fill(point(p.x+1, p.y+1), fillcolor, startcolor);
         fill(point(p.x-1, p.y), fillcolor, startcolor);
         fill(point(p.x-1, p.y-1), fillcolor, startcolor);
        

        }
        }

        pro-tip: this is recursive, which can be a problem for large fills. but you can eliminate the recursion using a stack.

        image processing toolkits | batch image processing

        N Offline
        N Offline
        niconicx
        wrote on last edited by
        #3

        thank you for this

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups