SlideShare a Scribd company logo
2
Most read
6
Most read
Polygon  surfaces A polygon is an important  graphics primitive.  A polygon is a  closed area  of image bounded by straight or curved lines and filled with one solid color.  Since images are two dimensional, a polygon is a closed planar figure.
Polygon  surfaces A polygon can be defined as an image which consists of a finite ordered set of straight boundaries called  edges .  The polygon can also be defined by an ordered sequence of  vertices , i.e, the corners of the polygon.  The edges of the polygon are then obtained by traversing the vertices in the given order;  Two consecutive vertices define one edge.  The polygon can be closed  by connecting the last vertex to the first.  Face list or polygon surface table is required in order to fill the polygon.
 
Area Filling Algorithms Scan line polygon fill algorithm Boundary fill algorithm Flood fill algorithm
Scan-Line Polygon Fill Algorithm Odd-parity rule Calculate span intersections on each scan line using parity rule to determine whether or not a point is inside a region  Parity is initially even     each intersection encountered thus inverts the parity bit  parity is odd     interior point (draw) parity is even    exterior point (do not draw) o o e e o e/o e
Scan-Line Polygon Fill Algorithm Case 1 Check the endpoint y values of two intersected edges    if their change is monotonically, we should count the intersection only once    Otherwise, we should count the intersection twice. Case 2   At the shared vertex: shorten the lower edge one grid below the shared point, such that the two edges are disconnected;    Alternative way:  we only count the y[min] vertex of an edge but not the y[max] vertex for the adjacent edge. For horizontal line    do not count their vertices o o e e o e/o e Case 1: Case 2:
Scan-Line Polygon Fill Algorithm Finding intersection pairs : Scan-line conversion method (for non-horizontal edges):    Edge  coherence  property:  Incremental calculation between successive scan lines    Or using Bresenham’s scan line conversion algorithm on each edge and keep a table of span extrema for each scan line
Scan-Line Polygon Fill Algorithm Incremental scan line method : m = (y[k+1] – y[k])  /  (x[k+1] – x[k]) y[k+1] – y[k] = 1 x[k+1] = x[k] + 1/m    x[k] = x[0] + k/m Scan line y[k] + 1 Scan line y[k] (x[k+1],  y[k+1])  (x[k],  y[k])
Scan-Line Polygon Fill Algorithm Incremental scan line method : Bucket sorted edge table: containing all edges sorted by their smaller y coordinate.  Each bucket: edges are recorded in order of increasing x coordinate of the  lower endpoint. Each entry of a bucket:  y[max] of the edge, x[min] of lower endpoint and 1/m  (x increment) Active-edge table (or list): keep track of the set of edges that the scan line intersects  and the intersection points in a data structure
Scan-Line Polygon Fill Algorithm Example: 5 1 4 3 2 y5 x1 1/m[1,5] y2 x1 1/m[1,2] y5 x4 1/m[4,5] y3 x4 1/m[4,3] y3 x2 1/m[2,3] y4 : : y1 y2 : : : : 0 Sorted edge table (ET)
Scan-Line Polygon  Fill Algorithm Example: 5 1 4 3 2 y5 xa 1/m[1,5] y2 xb 1/m[1,2] y5 x5 1/m[1,5] y5 x5 1/m[4,5] y[5] : : y[a] : : : : : 0 Active edge table (AET) b a y3 xc 1/m[3,4] y2 xd 1/m[1,2] c d
Inside-outside tests  Odd-even rule (odd parity rule or even-odd rule) Counting the number of edge crossing along the line from point P to infinity Odd number    interior point P Even number    exterior point P Non-zero winding number rule (vector method)    winding number: no of times that the polygon edges wind around a point in the counterclockwise direction    if the winding number = 0    exterior point    if the winding number != 0     interior point
Boundary Fill Suppose that the edges of the polygon has already been colored. Suppose that the interior of the polygon is to be colored a different color from the edge. Suppose we start with a pixel inside the polygon, then we color that pixel and all surrounding pixels until we meet a pixel that is already colored.
void boundaryFill(int x, int y, int fillColor, int borderColor) { int interiorColor; getPixel(x,y,interiorColor); if ((interiorColor!=borderColor)&&(interiorColor!=fillColor)) { setPixel(x,y,fillColor); boundaryFill(x+1,y,fillColor,borderColor);  boundaryFill(x-1,y,fillColor,borderColor); boundaryFill(x,y+1,fillColor,borderColor); boundaryFill(x,y-1,fillColor,borderColor); } } Boundary Fill
Flood Fill Suppose we want to color the entire area whose original color is interiorColor, and replace it with fillColor. Then, we start with a point in this area, and then color all surrounding points until we see a pixel that is not interiorColor.
void floodFill(int x, int y, int fillColor, int interiorColor) { int color; getPixel(x,y,color) if (color==interiorColor) { setPixel(x,y,fillColor); floodFill(x+1,y,fillColor,interiorColor);  floodFill(x-1,y,fillColor,interiorColor); floodFill(x,y+1,fillColor,interiorColor); floodFill(x,y-1,fillColor,interiorColor); } } Flood Fill

More Related Content

PPTX
Mid point circle algorithm
PPTX
Fundamental Steps Of Image Processing
PPT
Frequency Domain Image Enhancement Techniques
PDF
DIGITAL IMAGE PROCESSING - LECTURE NOTES
PPTX
Smoothing in Digital Image Processing
PPTX
Dda line algorithm presentatiion
PPTX
discrete wavelet transform
PDF
Intermediate code generation
Mid point circle algorithm
Fundamental Steps Of Image Processing
Frequency Domain Image Enhancement Techniques
DIGITAL IMAGE PROCESSING - LECTURE NOTES
Smoothing in Digital Image Processing
Dda line algorithm presentatiion
discrete wavelet transform
Intermediate code generation

What's hot (20)

PDF
03 image transform
PPTX
Line Drawing Algorithms - Computer Graphics - Notes
PPTX
Dda algorithm
PPTX
Anti- aliasing computer graphics
PPTX
First order predicate logic(fopl)
PPTX
BRESENHAM’S LINE DRAWING ALGORITHM
PDF
Dictionary Based Compression
PPTX
Attributes of Output Primitives
PDF
Lecture 16 KL Transform in Image Processing
PPT
Arithmetic coding
PPTX
Huffman coding
PPTX
Circle generation algorithm
PPTX
digital image processing
PPT
Illumination model
PPT
Data Redundacy
PPTX
Threads & Concurrency
PPTX
Frame buffer
PPTX
Breadth First Search & Depth First Search
PDF
Digital Image Fundamentals
PPTX
Region based segmentation
03 image transform
Line Drawing Algorithms - Computer Graphics - Notes
Dda algorithm
Anti- aliasing computer graphics
First order predicate logic(fopl)
BRESENHAM’S LINE DRAWING ALGORITHM
Dictionary Based Compression
Attributes of Output Primitives
Lecture 16 KL Transform in Image Processing
Arithmetic coding
Huffman coding
Circle generation algorithm
digital image processing
Illumination model
Data Redundacy
Threads & Concurrency
Frame buffer
Breadth First Search & Depth First Search
Digital Image Fundamentals
Region based segmentation
Ad

Viewers also liked (20)

PPTX
Computer graphics
PPT
Polygon Fill
PPTX
Area filling algo
PDF
Euler and hamilton paths
PPTX
Hamiltonian path
PPTX
Backtracking
PPTX
Backtracking
PPT
Fill area algorithms
PPTX
Cohen-Sutherland Line Clipping Algorithm
PPTX
CAD - Unit-1 (Fundamentals of Computer Graphics)
PPT
Clipping in Computer Graphics
PDF
Computer Graphics Programes
PPT
Lecture 2d point,curve,text,line clipping
PDF
backtracking algorithms of ada
PPT
Lecture applications of cg
PDF
Clipping
PPT
Lecture+ +raster+&+random+scan+systems
PPTX
8 queens problem using back tracking
PPT
Cohen-sutherland & liang-basky line clipping algorithm
Computer graphics
Polygon Fill
Area filling algo
Euler and hamilton paths
Hamiltonian path
Backtracking
Backtracking
Fill area algorithms
Cohen-Sutherland Line Clipping Algorithm
CAD - Unit-1 (Fundamentals of Computer Graphics)
Clipping in Computer Graphics
Computer Graphics Programes
Lecture 2d point,curve,text,line clipping
backtracking algorithms of ada
Lecture applications of cg
Clipping
Lecture+ +raster+&+random+scan+systems
8 queens problem using back tracking
Cohen-sutherland & liang-basky line clipping algorithm
Ad

Similar to Lecture filling algorithms (20)

PPT
Polygon filling
PPTX
UNIT2.pptx
PPT
Boundary fill algm
PPTX
Computer Graphics2 for engineering students.pptx
PDF
Computer graphics unit 4th
PPTX
Clipping computer graphics
PPTX
Clipping
PDF
Computer Graphics Pollygon filling Techniques.pdf
PPTX
L-5 (Line Drawing Algorithms Computer graphics).pptx
PPTX
Unit2- line clipping.pptx
PPTX
Unit-5 BSR-1-02-2024 advanced algorithms .pptx
PDF
Comparison of Various Line Clipping Algorithm for Improvement
PPTX
MATLABgraphPlotting.pptx
DOCX
Computer graphics question for exam solved
PPT
Unit-2 PPT.ppt
PPTX
clippiNG COMPUTER GRAPHICS A NEW ERA.pptx
DOCX
Bt9301, computer graphics
PDF
Module 3 polynomial functions
DOC
Unit 4 notes
PPTX
Fill area algorithm on computer graphics course
Polygon filling
UNIT2.pptx
Boundary fill algm
Computer Graphics2 for engineering students.pptx
Computer graphics unit 4th
Clipping computer graphics
Clipping
Computer Graphics Pollygon filling Techniques.pdf
L-5 (Line Drawing Algorithms Computer graphics).pptx
Unit2- line clipping.pptx
Unit-5 BSR-1-02-2024 advanced algorithms .pptx
Comparison of Various Line Clipping Algorithm for Improvement
MATLABgraphPlotting.pptx
Computer graphics question for exam solved
Unit-2 PPT.ppt
clippiNG COMPUTER GRAPHICS A NEW ERA.pptx
Bt9301, computer graphics
Module 3 polynomial functions
Unit 4 notes
Fill area algorithm on computer graphics course

Recently uploaded (20)

PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced IT Governance
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced IT Governance
Advanced methodologies resolving dimensionality complications for autism neur...
Advanced Soft Computing BINUS July 2025.pdf
Chapter 3 Spatial Domain Image Processing.pdf
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
GamePlan Trading System Review: Professional Trader's Honest Take
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.

Lecture filling algorithms

  • 1. Polygon surfaces A polygon is an important graphics primitive. A polygon is a closed area of image bounded by straight or curved lines and filled with one solid color. Since images are two dimensional, a polygon is a closed planar figure.
  • 2. Polygon surfaces A polygon can be defined as an image which consists of a finite ordered set of straight boundaries called edges . The polygon can also be defined by an ordered sequence of vertices , i.e, the corners of the polygon. The edges of the polygon are then obtained by traversing the vertices in the given order; Two consecutive vertices define one edge. The polygon can be closed by connecting the last vertex to the first. Face list or polygon surface table is required in order to fill the polygon.
  • 3.  
  • 4. Area Filling Algorithms Scan line polygon fill algorithm Boundary fill algorithm Flood fill algorithm
  • 5. Scan-Line Polygon Fill Algorithm Odd-parity rule Calculate span intersections on each scan line using parity rule to determine whether or not a point is inside a region Parity is initially even  each intersection encountered thus inverts the parity bit parity is odd  interior point (draw) parity is even  exterior point (do not draw) o o e e o e/o e
  • 6. Scan-Line Polygon Fill Algorithm Case 1 Check the endpoint y values of two intersected edges  if their change is monotonically, we should count the intersection only once  Otherwise, we should count the intersection twice. Case 2 At the shared vertex: shorten the lower edge one grid below the shared point, such that the two edges are disconnected;  Alternative way: we only count the y[min] vertex of an edge but not the y[max] vertex for the adjacent edge. For horizontal line  do not count their vertices o o e e o e/o e Case 1: Case 2:
  • 7. Scan-Line Polygon Fill Algorithm Finding intersection pairs : Scan-line conversion method (for non-horizontal edges):  Edge coherence property: Incremental calculation between successive scan lines  Or using Bresenham’s scan line conversion algorithm on each edge and keep a table of span extrema for each scan line
  • 8. Scan-Line Polygon Fill Algorithm Incremental scan line method : m = (y[k+1] – y[k]) / (x[k+1] – x[k]) y[k+1] – y[k] = 1 x[k+1] = x[k] + 1/m  x[k] = x[0] + k/m Scan line y[k] + 1 Scan line y[k] (x[k+1], y[k+1]) (x[k], y[k])
  • 9. Scan-Line Polygon Fill Algorithm Incremental scan line method : Bucket sorted edge table: containing all edges sorted by their smaller y coordinate. Each bucket: edges are recorded in order of increasing x coordinate of the lower endpoint. Each entry of a bucket: y[max] of the edge, x[min] of lower endpoint and 1/m (x increment) Active-edge table (or list): keep track of the set of edges that the scan line intersects and the intersection points in a data structure
  • 10. Scan-Line Polygon Fill Algorithm Example: 5 1 4 3 2 y5 x1 1/m[1,5] y2 x1 1/m[1,2] y5 x4 1/m[4,5] y3 x4 1/m[4,3] y3 x2 1/m[2,3] y4 : : y1 y2 : : : : 0 Sorted edge table (ET)
  • 11. Scan-Line Polygon Fill Algorithm Example: 5 1 4 3 2 y5 xa 1/m[1,5] y2 xb 1/m[1,2] y5 x5 1/m[1,5] y5 x5 1/m[4,5] y[5] : : y[a] : : : : : 0 Active edge table (AET) b a y3 xc 1/m[3,4] y2 xd 1/m[1,2] c d
  • 12. Inside-outside tests Odd-even rule (odd parity rule or even-odd rule) Counting the number of edge crossing along the line from point P to infinity Odd number  interior point P Even number  exterior point P Non-zero winding number rule (vector method)  winding number: no of times that the polygon edges wind around a point in the counterclockwise direction  if the winding number = 0  exterior point  if the winding number != 0  interior point
  • 13. Boundary Fill Suppose that the edges of the polygon has already been colored. Suppose that the interior of the polygon is to be colored a different color from the edge. Suppose we start with a pixel inside the polygon, then we color that pixel and all surrounding pixels until we meet a pixel that is already colored.
  • 14. void boundaryFill(int x, int y, int fillColor, int borderColor) { int interiorColor; getPixel(x,y,interiorColor); if ((interiorColor!=borderColor)&&(interiorColor!=fillColor)) { setPixel(x,y,fillColor); boundaryFill(x+1,y,fillColor,borderColor); boundaryFill(x-1,y,fillColor,borderColor); boundaryFill(x,y+1,fillColor,borderColor); boundaryFill(x,y-1,fillColor,borderColor); } } Boundary Fill
  • 15. Flood Fill Suppose we want to color the entire area whose original color is interiorColor, and replace it with fillColor. Then, we start with a point in this area, and then color all surrounding points until we see a pixel that is not interiorColor.
  • 16. void floodFill(int x, int y, int fillColor, int interiorColor) { int color; getPixel(x,y,color) if (color==interiorColor) { setPixel(x,y,fillColor); floodFill(x+1,y,fillColor,interiorColor); floodFill(x-1,y,fillColor,interiorColor); floodFill(x,y+1,fillColor,interiorColor); floodFill(x,y-1,fillColor,interiorColor); } } Flood Fill