0% found this document useful (0 votes)
105 views7 pages

PR - 5 - Computer Graphics

The document outlines a practical exercise for implementing the Flood Fill Algorithm in C for polygon filling in computer graphics. It details the significance of the algorithm, expected outcomes for students, required resources, and a step-by-step procedure for coding. Additionally, it includes assessment criteria, references for further reading, and practical-related questions to reinforce learning.

Uploaded by

Atharva Mahajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views7 pages

PR - 5 - Computer Graphics

The document outlines a practical exercise for implementing the Flood Fill Algorithm in C for polygon filling in computer graphics. It details the significance of the algorithm, expected outcomes for students, required resources, and a step-by-step procedure for coding. Additionally, it includes assessment criteria, references for further reading, and practical-related questions to reinforce learning.

Uploaded by

Atharva Mahajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Graphics(313014)

Practical No:05 - Write a C program for Flood Fill Algorithm of Polygon Filling.

I. Practical Significance:
A polygon consists of a series of connected line segments forming a closed shape. To fill
polygons with specific colors, you need to identify which pixels lie on the border of the
polygon and which pixels fall inside it.
The Flood Fill algorithm is a fundamental technique in computer graphics used for filling
bounded areas with a specific color. This algorithm is widely used in various applications
such as paint programs, games, and image processing to color enclosed areas efficiently.

II. Industry, Employer Expected outcomes:


This practical aims to develop the following skills:
Develop C programs to draw basic graphics objects.
1. Write syntax for graphics functions.
2. Set up graphics driver, mode, and directory to run graphics programs.
3. Compile C programs using Turbo C.
4. Debug and execute programs effectively.

III. Course Level Learning Outcomes:


Develop programs in C applying standard graphics algorithms.
1. Develop and implement C programs using standard graphics algorithms.
2. Apply flood fill algorithm for polygon filling in graphical applications.
3. Understand the principles of area filling algorithms in computer graphics.

IV. Laboratory Learning outcomes:


LLO 5.1: Implement a C program for the Flood Fill algorithm.

V. Relevant Affective Domain Related Outcomes:


- Demonstrate patience and attention to detail when debugging graphics code.
- Show creativity in designing visual representations.

VI. Relevant Theoretical Domain Related outcomes(with Diagram if required):


The Flood Fill algorithm begins at a specified seed point and examines neighboring pixels.
Instead of checking for a boundary color, it checks for a specified interior color and replaces
it with a new color. The algorithm can be implemented using a stack-based approach
(depth-first search) or a queue-based approach (breadth-first search). It can be applied using
either the 4-connected or 8-connected region method.

Maharashtra State Board Of Technical Education 30


Computer Graphics(313014)

VII. Required Resources/apparatus/equipment with specification:

Sr. Name of
Specification Qty. Remarks
Resource
Hardware: Computer(i3-i5preferable),
Computer RAM minimum 2 Gb and
1. System onwards but not limited
As per batch For All
Operating Windows XP/ Windows Experiment
2. Size
System 7/LINUX version 5.0 or later s
Turbo C/C++ Version 3.0 or later
3. Software with DOSBOX
VIII. Precautions to be followed :
- Ensure the graphics library is properly installed and configured.
- Check for compatibility of the graphics library with the compiler.
- Handle errors and exceptions to avoid crashes.

IX. Procedure :
Flood-fill(node,target-color,replacement-color):
1. If target-color is equal to replacement-color, return
2. If the color of node is not equal to target-color,return.
3. Set color of node to replacement-color.
4. Perform flood-fill(one step to south node, target-color,replacement-color).
5. Perform flood-fill(one step to north node, target-color,replacement-color).
6. Perform flood-fill(one step to west node, target-color,replacement-color).
7. Perform flood-fill(one step to east node, target-color,replacement-color).
8. Return
X. Resources used
Sr.
Name of Resource Specification
No.
Computer System
1.
with broad specifications
2. Software
3. Any other resource used

Algorithm:

Maharashtra State Board Of Technical Education 31


Computer Graphics(313014)

Flowchart:

‘C’ program code

Maharashtra State Board Of Technical Education 32


Computer Graphics(313014)

XI. Result :

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XII.Conclusions and recommendation:

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XIII. Practical Related Questions:
Note: Below given are few sample questions for reference. Teachers must
design more such questions so as to ensure the achievement of identified CO.
1. Define Polygon.
2. Explain types of polygon.
3. List coordinates of neighboring pixel in 8-connected method for seed pixel with
coordinates(x,y).
4. List coordinates of neighboring pixel in 4-connected method for seed pixel with
coordinates(x,y)
5. Explain inside-outside test of polygon.

(Space for Answer)


………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 33
Computer Graphics(313014)

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………

XIV. Exercise:
i. WAP to draw hexagon and fill hexagon with pink color using flood fill algorithm with 8-
connected method.
ii. WAP to draw triangle(USING LINE FUNCTION) and fill hexagon with red color using
flood fill algorithm with 4-connected method.

(Space for Answer)


………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………

Maharashtra State Board Of Technical Education 34


Computer Graphics(313014)

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 35
Computer Graphics(313014)

XV. References/Suggestions for further reading: include Website. Link:


1. https://books.google.co.in/books?isbn=8184317379
2. https://math.hws.edu/eck/cs424/downloads/graphicsbook-linked.pdf
3. https://books.google.com/books/about/Computer_Graphics.html?id=XgAeEAAAQBAJ
4. https://www.freebookcentre.net/CompuScience/Free-Computer-Graphics-Books-
Download.html#google_vignette

XVI. Assessment Scheme


Performance indicators Weightage
Process related: 15 Marks 60%
1. Debugging ability 20%

2. Correctness of Program codes 30%

3. Quality of output achieved(LLO mapped) 10%

Product related: 10 Marks 40%

1. Completion and submission of practical in time 20%


2. Answer to sample questions 20%
Total 25 Marks 100%

List of Student /Team Members

1. ………..………..………..

2. ………..………..………..

3. ………..………..………..

4. ………..………..………..

Marks obtained Dated Sign of Teacher

Process Product
Related(15) Related(10) Total(25)

Maharashtra State Board Of Technical Education 36

You might also like