0% found this document useful (0 votes)
63 views

CGR Practical No 5

This document discusses the flood fill algorithm in computer graphics. It explains that the flood fill algorithm starts with a seed pixel and examines neighboring pixels, replacing those with the specified interior color. It can use either 4-connected or 8-connected region methods to determine neighboring pixels. The document provides pseudocode for the flood fill algorithm and examples of its use. It also lists some requirements, precautions, and sample questions related to the flood fill algorithm and computer graphics concepts.

Uploaded by

Siddhi Mulik
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)
63 views

CGR Practical No 5

This document discusses the flood fill algorithm in computer graphics. It explains that the flood fill algorithm starts with a seed pixel and examines neighboring pixels, replacing those with the specified interior color. It can use either 4-connected or 8-connected region methods to determine neighboring pixels. The document provides pseudocode for the flood fill algorithm and examples of its use. It also lists some requirements, precautions, and sample questions related to the flood fill algorithm and computer graphics concepts.

Uploaded by

Siddhi Mulik
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/ 6

Computer Graphics (22318)

VI. Relevant Affective domain related Outcome(s)


a. Experiment with graphics environment.
b. Follow safety/ethical practices.
c. Maintain tools and equipment.
VIl. Minimum Theoretical Background
Flood Fill Algorithm

In Flood Fill
algorithm we start with some seed and examine the neighboring pxcls
however pixels are checked for a
and is replaced
specified interior color instead of boundary color
by a new color. It can be done using 4 connected or 8 connected
region method.

Procedure:
Flood-fill (node, target-color, replacement-color):
1. If target-color is equal to replacement-color, return.
If the color of node is not equal to
target-color, return.
Set the color of node to replacement-color.
4. Perform Flood-fill (one step to the south of
node, target-color,
Perform Flood-fill (one step to the north of node, target-color, replacement-color).
Perform Flood-fill (one step to the west of node, target-color,
replacement-color).
Perform Flood-fill (one step to the east of node, target-color,
replacement-color).
5. Return.
replacement-color).
Example:
circle(100,100,50);
floodfill(100,100,RED);
Fills the circle with red colour.

VIII. Algorithm

Alood Fi) (x,y, new - colou , odd - colouwn )


old LolouT)
tiF Cqet pixel
putpixe) Cx ,y, ned-colour),
flood FiU (7+1,y, ne- colouY, old-Colour),
fluod fill CX ,y + new-Colour, old.colo uT),
flood Fi C-l, u,new (olou, old - colour),
Flood-F C y-!'ed colour, olo- Colour),

34
Maharashtra State Board
of Technical Education
Date.
Page

Output
nteY X and poSiton fu Ccle_

bnte YadwSo ccle


2S
Computer Graphics (22318)

Flow Chart
IX.
Start
Flood. Fil (X,y,neu-colouy,old.calon

qet pixe
old
ColouY

TYUe

tolour
/put pixe , y n e

(x+y,nes.tolour,old-colouY)
wdeFlocdFile
CProgram Code Colouy)
lood. File (t, ytl,neocolouY,old-
old-colour)
(x-1, , new-colouY,
Flood file
old- colouY
Flooo-File ( ,y-1,newacolur,

Stpp
Computer Graphics (22318)

XT Resources requlred
Remarks
Quantity
Sr. | Name Specification
No. Resource Computer (i3-i5 preferable),
1Hardware: RAM minimum 2 GB and
Computer
System
onwards but not limited to As per batch For all
Windows XP/Windows size Experiments
Operating 7/LINUX version 5.0 or later
system
3 Software Turbo C /C++ Version 3.0 or
later with DOSBODX
XI. Precautions
1. Ensure that all C statements must end with a semicolon (;).
2. Use white spaces in c to describe blanks and tabs.
3. Ensure use ofproper graphics function for relevant object.
4. Follow safety practices.

XII. Resources used

S. No Name of Resource Specification


Computer System
ations
with broad specifications ntel 13 ,RAM 2G8, 5o0 GB, HDD
2 Software
Turbo C
Any other resource used

XII. Result (Output of the Program)


**o..
*°*°** °°°*°*°***°*****. °°°*

°**°**

*********.***
.

XIV. Conclusion(s)
***********" °°°°°***.

Adexshoo.d. lood.il.algorithm....Col9vain... . ******* *****

XV. Practical Related uestion


Note: Below
giyén few sample questions for
are
more such
quéstions so as to ensure the reference. Teacher must design
(Note: Use Point VIII to X and XII to XV achievement of identified CO.
blank pages for all relevant programming exercise
provided or attach more pages if needed.)use
1.Define polygon.
2.Explain types of polygon.

aharashtra State Board of Technical Education


36
Computer Graphics (22318)
with
method for seed pixel
8-connected

of neighboring pixels in
Coordinates ith
3. List method for seed pixel
4-connected
coordinates(x,y) in
Coordinates of neighboring pixels
4. List
coordinates(x,y)
inside-outside test of polygon.
5. Explain
****************************°*°************°***********°°*°**°°*******°*****°*************°****°°°***°"*********°°'°*****'°*' (Space for Answers) ****°**

***
Polaom..can... ekimed..S. .osed.p.lae...

.kiqu..mad.up...a&MRYC ime.Semernts...hai..

******************°*°******°*********°°******°**°°****°°**°° °**********°***°° *° ° *****:°*° **°°*****°**°*° *°********


* ° * * * ° ° * * ° *

*****"**
* ° ° * * * * *

***********

.cark.inRA..gehk..

*******

*°°***°°***°°°*°****"****

hex.**************

ewo..ypes. pol490n..
**************
***
**********°******°***°°*

**********°******

.Concave. .l4q.0... *****************************°***°°° ***°*°


*********.

** *°°****

***°****°*****°*****°****°**°***°°****** *°°***°°***°****°°**°°********* °***°***°°*°*°°********°***

**°********

********

************
********°°°*°***°°*********
. * * * * * * * * * * * * * * * * *

* * * * * * " * * * * * * * * * * * * * * * * * *

* * * * * * *

***
***
***°°********
* *

°***
* * * * * * * * ° * * * * * ° * *
** °*********°*********
* * * * * * * * * * *

* * * * ° * * * * * * * *

* * * * * * * * * * *

********°°******°***

* * * * * * * * *
***°***°°**********°*

*****°°***************

****************.
.. . ***
***°***°***"**

*****°******** ****
****************
o o s o * o . * * * * .

**
* * * * ° * * * * * * * * * * *

*******°**°*********

**°**°**°*****************

*********** ****°*********°***°*°°*°***************°*********.
*****

*****°°°******

. . *********°***
***********

****°****°°***°**°*°************°°*°*°**°*°***°*****°**°****°*******°******* *********

***
********** ****** ****************°* * * * * * * * * * *

***************
° ° * * ° * *

*°**°***°********
.... ..T..
* * * * ***********.

**°***°**°******'****************°******°*****************************************************************" **********

** ************** *******************************°***°°***°°** ******** ********

.conneckd..method..
°*****°*°°°*****°***°**°**°***°°****°** ****°************************************************

****
* * * * ° ° * ° ° ° * * * * *

**°°*°°***°°*°**°*****°°**
°**
* * * * ° * * ° * * ° ° ° ° * ° * ° ° * ° * * * °

* * * * * * * * ° *

°°°°°°*°°°°°°*°°°* *°°***°**°***********°°°*°**°°°°*

**°**°*****°**°*'**°°*** *****°***'**** ***

°°*°**********°**°*°°°*°*°*°°°°°°°°**°°*°°°°°*°*°*°*°°***°***°**°°°°*°**°*°°°*°°*°**°**°°°*°**°
**'**°°*°*°°°°***°°*.
*°°***°***** *°*******°******°******°****°*°*°°*°°**°**°°°***°°°*°°***°°*°**°°°°°**°**°*°**°°*°**°°°°°*°**°°°****°*******°**** *

erM.
t.Sn..Compwhe phi.c.
S ..A.
. oy.991..
iMt...S.nSieke...OUISI.

i. ********°°°**°°*
*****°°*.
*****°°°****°°*******°*******

* * * * * * * * .

37
Technical Education
Maharashra State Board of
Computer Graphies (22318)

XVI. Exercise
Atempt Q1. and teacher shall allot Q. 2/Q.3 from the following:
(Note: Use Point VIIl to X and XIII to XV for all relevant
blank pages programming exercise use
providcd or attach more pages if needed.)
1.WAP to draw hcxagon and fill
hexagon with pink color using flood fill algorithm
with 8-connected method.
ii. WAP to draw
triangle (use line function) and fill it with blue color using flood fill
algorithm with 4-connected method.

(Space for Answers)


..... ****°°°°*°***°*°*°°°°*°°***°**°*******aee.e*.

******.lude..Stdia:hz.
nuce. onio.h.. **°**°°°°°**°°°°**°°°**°°°°***°******°********°*°
********°****************"e*****************************e** se......
. ude..qraphic..h.

O.fluad Cint.X3.nt.y,int..n9..,in.t...ld.c)
***°°°**°**°*°*°°***°****°
****°*********°°° **********e*****************°******°****.
****° *******°****°°***********°**°°°****°*°°°°***************°°***** ***

***°**°*.. x e . . K 2 ********°***°°**°°***°°*°°°*°°°°°°°°*°*°°*°°°*°**°***°*****°*°°°*****
.dc.2. ....
***°*°°*°*°°°°°°°°°****°°°**°°°°*°°°*°*°°°**°*.°°*°°*°°°°****°°e*°°***
. ....Co.lo n e s .*****°°*°****°°°°°***°°*°°****°*************
.. *******°********** ****°**°*

*****°*°°*

°°*°*°)°*°°**°°°*°°*°***°°°*°*°*****°*****************°°***************°°**°.
pwtpix.LM,4.3.ns °°°°*°°***°*°*°**********°****°°.**°°°******°*°* **°°*****°***°°*
a y . . . ***°°°°°°°°°°*°°°***°°°°°°°***°*'***°°*********°**** ********************.°°°°.**********
Cloo
***oo*******eo.
tl,Mq.ne.c.,oldc..
*e***** . ad.iSX3.4tI., nSold.s..y.
****°*****°°°*°*°°°°**°°*°°**°*°°°*°*°°***°***********°°*
*°°°°°*°°**°°*°******°°°°°*°°°°*°°°*°*°°°***°***
**°***.

******.
logd..Sx.4.4..C9ld.s.l.. *****°°*******°******************* ** °°******
**°***°°?* °**°°°°**°°°*°°°**°°*°**°°**°°**°**°*°**°**

°**°°****°*°*°*°*°°°°°°°*°**°°*°***°°
°°**°************°****°°****°* *°°°*°°°**°* **°°°***°°*
***°*********°***
*************°*°°°°°°°*°°°°°*°°°**°**°*°°
***°°****°°°*°°°°*°*°*°°°**°°°*°°°°°****°°***°°***°*°*****°
.Nolc..au... ****** ** *°°*°°°°°***°***°*°******°**°**°°°°°°**°°°**°°************°°***

..nL.s., poMts..S9,0,0,199,119,.12.0,11.0,1.10.,ISO. ***°*

°°****°°°°°**°*°**°**°°°°***°°°°°°*°°°°*°°***
A..39.,.12.0..1.SD..170.1,.
ok.heaep..Kg..qm2p.. *°*°**°°°°°°°°°°*°****

..nitgaph.Aq,km.
apoly. sints. °°°°**°°°°°°°.°°°° *°**
*** **°*°**************°***e***°

.looskI..ASI,MGI,.S.S...*********************** ****°** **°****.°*°*°°*°°


. e***.

**********************°"e******** e...n..
*****.*°°°°°°°°**°*°**°*°****°********

Maharashtra State Roard of Technical Education

You might also like