Understanding Boundary Fill and Flood Fill Algorithms in Graphical Applications
110 likes | 261 Vues
This resource explores the boundary fill and flood fill algorithms used in graphical applications, with a focus on pixel-based methods. The boundary fill starts at an interior point and fills outwards until it encounters a boundary pixel color. In contrast, flood fill replaces a consistent color throughout a designated area. The tutorial also discusses variations like 4-connected and 8-connected fill, recursive algorithms, and potential issues such as stack space problems. This guide is beneficial for students and professionals interested in computer graphics and image processing.
Understanding Boundary Fill and Flood Fill Algorithms in Graphical Applications
E N D
Presentation Transcript
Boundary Fill • MS Paint CS-321Dr. Mark L. Hornick
Boundary Fill • Start at interior point • “Paint” interior outward toward boundary • How? • Note: Boundary encounter determined by boundary pixel color CS-321Dr. Mark L. Hornick
Boundary fill Interior point CS-321Dr. Mark L. Hornick
Boundary Fill Algorithm • Don’t fill if current position is: • Boundary color • Current fill color • Otherwise • Set fill color • Recursively try neighbors • North, East, South, West • Could also be NSEW, NEWS, etc. • Each neighbor recursively performs algorithm until “stop” CS-321Dr. Mark L. Hornick
Boundary Fill Patterns 4-connected 8-connected CS-321Dr. Mark L. Hornick
4-connected EWNS boundary fill CS-321Dr. Mark L. Hornick
Boundary Fill Algorithm • Demo CS-321Dr. Mark L. Hornick
Boundary Fill Problems • Recursive algorithm • Stack space issue • Recursion stops only on • Boundary color • Current fill color • What if some other fill color is already present? • i.e. pixels already in area to be filled CS-321Dr. Mark L. Hornick
Flood Fill • Similar to boundary fill • But replaces “interior” color (i.e. not boundary) • Floods through an area • Fill area must be - initially – a consistent color • Only one significant color is filled over • Paint bucket tool • MS Paint actually uses flood fill CS-321Dr. Mark L. Hornick
Fill Algorithm Summary • Vector edge model • Scan line fill • Even-odd or non-zero winding • Pixel model • 4- or 8- connected recursion • Boundary fill: overwrites all but boundary or current fill color • Flood fill: overwrites only initially selected color CS-321Dr. Mark L. Hornick