CGR Practical No 5
CGR Practical No 5
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
34
Maharashtra State Board
of Technical Education
Date.
Page
Output
nteY X and poSiton fu Ccle_
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.
°**°**
*********.***
.
XIV. Conclusion(s)
***********" °°°°°***.
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..
**************
***
**********°******°***°°*
**********°******
** *°°****
**°********
********
************
********°°°*°***°°*********
. * * * * * * * * * * * * * * * * *
* * * * * * " * * * * * * * * * * * * * * * * * *
* * * * * * *
***
***
***°°********
* *
°***
* * * * * * * * ° * * * * * ° * *
** °*********°*********
* * * * * * * * * * *
* * * * ° * * * * * * * *
* * * * * * * * * * *
********°°******°***
* * * * * * * * *
***°***°°**********°*
*****°°***************
****************.
.. . ***
***°***°***"**
*****°******** ****
****************
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.
******.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... ****** ** *°°*°°°°°***°***°*°******°**°**°°°°°°**°°°**°°************°°***
°°****°°°°°**°*°**°**°°°°***°°°°°°*°°°°*°°***
A..39.,.12.0..1.SD..170.1,.
ok.heaep..Kg..qm2p.. *°*°**°°°°°°°°°°*°****
..nitgaph.Aq,km.
apoly. sints. °°°°**°°°°°°°.°°°° *°**
*** **°*°**************°***e***°
**********************°"e******** e...n..
*****.*°°°°°°°°**°*°**°*°****°********