1 / 11

Filling Graphical Shapes Pixel-based methods

Filling Graphical Shapes Pixel-based methods. Boundary Fill. MS Paint. Boundary Fill. Start at interior point “Paint” interior outward toward boundary How? Note: Boundary encounter determined by boundary pixel color. Boundary fill. Interior point. Boundary Fill Algorithm.

armen
Download Presentation

Filling Graphical Shapes Pixel-based methods

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Filling Graphical ShapesPixel-based methods

  2. Boundary Fill • MS Paint CS-321Dr. Mark L. Hornick

  3. 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

  4. Boundary fill Interior point CS-321Dr. Mark L. Hornick

  5. 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

  6. Boundary Fill Patterns 4-connected 8-connected CS-321Dr. Mark L. Hornick

  7. 4-connected EWNS boundary fill CS-321Dr. Mark L. Hornick

  8. Boundary Fill Algorithm • Demo CS-321Dr. Mark L. Hornick

  9. 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

  10. 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

  11. 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

More Related