0% found this document useful (0 votes)
34 views8 pages

Pr_6 - Computer Graphics

The document outlines a practical exercise for implementing the Boundary Fill Algorithm in C for polygon filling, emphasizing skills such as graphics programming, debugging, and understanding area filling algorithms. It includes details on the algorithm's functionality, required resources, precautions, and a structured procedure for implementation. Additionally, it provides assessment criteria and references for further reading on computer graphics.

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)
34 views8 pages

Pr_6 - Computer Graphics

The document outlines a practical exercise for implementing the Boundary Fill Algorithm in C for polygon filling, emphasizing skills such as graphics programming, debugging, and understanding area filling algorithms. It includes details on the algorithm's functionality, required resources, precautions, and a structured procedure for implementation. Additionally, it provides assessment criteria and references for further reading on computer graphics.

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
You are on page 1/ 8

Computer Graphics(313014)

Practical No:06 - Write a C program for Boundary fill algorithm of polygon filling.

I. Practical Significance:

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 Boundary fill algorithm for polygon filling in graphical applications.
3. Understand the principles of area filling algorithms in computer graphics.

IV. Laboratory Learning outcomes:


LLO 6.1 Implement a C program forBoundary 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):

Boundary fill algorithm information


Boundary fill algorithm picks a point inside that is a seed point of an object and starts to
fill until it hits the boundary of the object. If boundary pixels are not reached, pixels are
highlighted and the process is continued until boundary pixel are reached.
The color of the boundary and the color that we fill should be different for this algorithm
work.
In this algorithm, we assume that color of the boundary is the same for the entire object.
The Boundary Fill Algorithm can be executed using two different connectivity methods:
4 - Connected boundary fill, 8 - Connected boundary fill

Seed Poitnt
Seed Poitnt

Maharashtra State Board Of Technical Education 37


Computer Graphics(313014)

4- Connected boundary fill


This method fills pixels that are directly above, below, left, and right of the current pixel.

void boundary_fill_4(int x, int y, int boundary_color, int fill_color)


{
int current = getpixel(x, y);
if(current != boundary_color && current != fill_color)
{
putpixel(x, y, fill_color);
boundary_fill_4(x + 1, y, boundary_color, fill_color);
boundary_fill_4(x, y + 1, boundary_color, fill_color);
boundary_fill_4(x - 1, y, boundary_color, fill_color);
boundary_fill_4(x, y - 1, boundary_color, fill_color);
}
}

8- Connected boundary fill


This method fills pixels that are directly above, below, left, right, and the four diagonal
pixels around the current pixel.

void boundary_fill_4(int x, int y, int boundary_color, int fill_color)


{
int current = getpixel(x, y);
if(current != boundary_color && current != fill_color)
{
putpixel(x, y, fill_color);
boundary_fill_4(x + 1, y, boundary_color, fill_color);
boundary_fill_4(x - 1, y, boundary_color, fill_color);
boundary_fill_4(x, y + 1, boundary_color, fill_color);
boundary_fill_4(x, y - 1, boundary_color, fill_color);
boundary_fill_4(x + 1, y + 1, boundary_color, fill_color);
boundary_fill_4(x - 1, y - 1, boundary_color, fill_color);
boundary_fill_4(x +1, y - 1, boundary_color, fill_color);
boundary_fill_4(x - 1, y + 1, boundary_color, fill_color);
}
}

VII.Required Resources/apparatus/equipment with specification:

Sr. Name of
Specification Qty. Remarks
Resource
Hardware: Computer(i3-i5preferable),
Computer RAM minimum 2Gb 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

Maharashtra State Board Of Technical Education 38


Computer Graphics(313014)

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 :
Step 1- Initialize the value of seed point seedx, seedy, fcolor, bcolor.
Step 2- Define the boundary values of polygon.
Step 3- check if the current seed point is of default color, then repeat the step3 and 5 til
boundary pixels reached.
Step 4- Change the default color with fill color at the seed point
Step 5 - Recursively follow the procedure with four neighborhood points.
Step 6- Exit.

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 39


Computer Graphics(313014)

Flowchart:

‘C’ program code

Maharashtra State Board Of Technical Education 40


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. Compare 4 - connected and 8 - connected method to fill polygon.
2. Give Difference between flood fill and boundary fill.
3. Identify type of polygon in following diagram.

(Space for Answer)


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

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XIV. Exercise:
iii. WAP to draw Pentagon and fill it with red color using boundary fill algorithm with 8-
connected method.
iv. WAP to draw trapezoid and fill it with blue color using boundary fill algorithm with 4
connected method

(Space for Answer)


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

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 43
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 44

You might also like