CGR Microproject PDF

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

1

A
MICRO PROJECT REPORT
ON

“BOUNDARY FILL
ALGORITHM”

PROGRAM-CGR
COURSE CODE-313014
Submitted by,

Name of student Enrollment No Program

1)Shaikh Samiya 23611980186 CO-CGR


2)Jindam Kalyani 23611980194 CO-CGR
3)Tanushri Gudur 23611980195 CO-CGR
4)Ravija nagare 23611980187 CO-CGR

Under the Guidance of


PROF. PADIR MAM
In partial fulfillment of requirement for the award of
Diploma In computer engineering.

MSBTE, Mumbai.

Academic Year: 2023-24

S.S.M. ADSUL POLYTECHNIC


COLLEGE, CHAS, AHMEDNAGAR-
2

414 005(M.S)
3

S.S.M. ADSUL POLYTECHNIC


COLLEGE, CHAS, AHMEDNAGAR-
414 005(M.S)

CERTIFICATE
This is to certify that the micro project report
entitled

“BOUNDARY FILL
ALGORITHM”

Submitted by,

Name of student Enrollment No Program


Co-CGR
1.Shaikh Samiya 23611980186

2.Jindam Kalyani 23611980194 Co-CGR

3.Tanushri Gudur 23611980195 Co-CGR

4.ravija nagare 23611980187 Co-CGR


Of semester IV institute, Sau. Sundarabai Manik Adsul Polytechnic, Chas,
Ahmednagar (code: 1464) has completed the micro project satisfactorily in course
C G R (313014) for the Academic year 2023-24 as prescribed in the MSBTE curriculum.

Place: Chas Ahmednagar


Date:
………………………….
.
4

Prof.PADIR MAM Prof.Hole.P.P. Prof.Gadakh.R.S.


(Micro Project guide) (Head of Dept.) (Principal)
5

ACKNOWLEDGEMENT

I take this opportunity to acknowledgement the constant encouragement and


continuous help give to me by my guide Prof. padir mam. convey my sincere thanks to his
valuable timely suggestion.
I would also like to thanks Principal Prof. Gadakh.R.S. And Head of department. I
would also like to thank teaching staff of department for achieving this goal.
I also thankful to those think which are directly or indirectly help me for completion
this micro project finally. I thank my parents without whose supports; the completion of the
project would not have been possible.

1)Shaikh Samiya
2)Jindam Kalyani
3)Tanushri Gudur
4)ravija nagare
6

TITLE OF MICRO-PROJECT:-

BOUNDARY FILL ALGORITHM

INDEX

Sr.No Topic Page No

1 INTRODUCTION 4-5

2 4-CONNECTED BOUNDARY FILL 6-8


ALGORITHM

3 8-CONNECTED BOUNDARY FILL 9-10


ALGORITHM

4 PROGRAM FOR BOUNDARY FILL 11


ALGORITHM

5 OUTPUT 12

6 CONCLUSION 13

7 PROJECT OUTCOMES 14

1.INTRODUCTION
7

The Boundary Fill algorithm is a popular computer graphics technique used for filling
closed areas with colors or patterns. It’s often employed for tasks like coloring regions
in a drawing or rendering, such as filling the interior of polygons.

Here’s a basic introduction to the Boundary Fill algorithm:

1. Objective: The primary goal of the Boundary Fill algorithm is to determine a set of
boundary pixels that enclose a closed region and fill the interior of that region with a
specified color.

2. How It Works:
- It begins at a seed point (a known point inside the region) and checks the
neighboring pixels.
- If the neighboring pixel is not already filled and lies within the boundary (i.e., its
color matches the boundary color), it fills that pixel with the desired color and adds its
unprocessed neighbors to a stack.
- The process continues until there are no more unprocessed pixels in the stack.

3. Use Cases: Boundary Fill is often used in applications like graphic design software,
where users can fill the interior of a shape with a specific color, or in paint programs
for “bucket fill” operations.

4. Boundary Conditions: The algorithm may need careful handling for issues like
recursive filling and preventing “spillover” into neighboring regions. One common
approach is to use a 4-connected or 8-connected approach to define what constitutes a
neighboring pixel.

A5. Seed Point Selection: The accuracy of the fill depends on selecting a suitable
seed point inside the region. The choice of the seed point can affect the efficiency and
correctness of the algorithm.

6. Limitations: The Boundary Fill algorithm may not work well for concave shapes or
regions with holes, as it can fill the entire space connected to the seed point.

7. Variants: Variants of this algorithm include the Flood Fill algorithm, which is
similar but fills an area with a boundary based on a different criterion, and the
Scanline Fill algorithm, which fills an area by scanning lines.

2.4-CONNECTED BOUNDARY FILL


8

ALGORITHM

In computer graphics, the 4-connected pixel boundary fill algorithm is a simple


technique used for filling regions or areas of an image with a specified color. This
algorithm is called “4-connected” because it considers pixels that are horizontally and
vertically adjacent as connected, but not diagonally adjacent pixels.

Here’s a basic description of the 4-connected boundary fill algorithm:

Algorithm: 4-Connected Boundary Fill

1. Start at a seed pixel (x, y) inside the area you want to fill.

2. Check the color of the seed pixel.

3. Initialize a stack to store pixel coordinates (x, y).

4. Push the coordinates (x, y) onto the stack.

5. Repeat until the stack is empty:


a. Pop a pixel from the stack (x, y).
b. Check the color of the current pixel.
c. If the current pixel’s color matches the seed color, change the pixel’s color
to the fill color.
d. Check and process the four adjacent pixels (left, right, up, down):
i. If the adjacent pixel’s color matches the seed color, push its coordinates
onto the stack.
e. Repeat step 5 for all adjacent pixels.

6. Continue this process until the stack is empty, and all connected pixels of the same
color are filled with the new color.

7. The algorithm is complete when the entire region has been filled.

It’s important to note that this algorithm might not handle complex cases, such as
regions with holes, and may not be efficient for large areas. To improve efficiency and
handle more complex scenarios, you may need to consider more advanced algorithms
like the scanline fill or flood fill algorithms.
9

ALGORITHM:-

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


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

3.8-CONNECTED BOUNDARY FILL


10

ALGORITHM

The boundary fill algorithm is used to fill a closed region in computer graphics. To fill
an 8-connected pixel region using this algorithm, you can follow these steps:

1. Choose a seed point (x, y) inside the region to be filled.


2. Check the color of the seed point.
3. If the color of the seed point is not the boundary color (the color of the region’s
boundary), then fill the seed point with the fill color (the color you want to fill the
region with).
4. Recursively check and fill the 8-connected neighbors of the seed point if they have
the boundary color. This means you need to check the points to the north, northeast,
east, southeast, south, southwest, west, and northwest of the current point.
5. Continue this process until all adjacent pixels are filled, and you’ve created a filled
region.

It’s important to ensure that you have proper termination conditions to stop the
recursion to avoid infinite loops. Also, you might want to implement some form of
boundary checking to avoid going outside the image boundaries.

Algorithm :

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


{
if(getpixel(x, y) != boundary_color &&
getpixel(x, y) != fill_color)
{
putpixel(x, y, fill_color);
boundaryFill8(x + 1, y, fill_color, boundary_color);
boundaryFill8(x, y + 1, fill_color, boundary_color);
boundaryFill8(x - 1, y, fill_color, boundary_color);
boundaryFill8(x, y - 1, fill_color, boundary_color);
boundaryFill8(x - 1, y - 1, fill_color, boundary_color);
boundaryFill8(x - 1, y + 1, fill_color, boundary_color);
boundaryFill8(x + 1, y - 1, fill_color, boundary_color);
boundaryFill8(x + 1, y + 1, fill_color, boundary_color);
}
}
11

4.PROGRAM FOR BOUNDARY FILL


ALGORITHM

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
void boundfill(int xc, int yc, int r, int b)
{
int cur;
cur = getpixel(xc, yc);
if (cur != b && cur != r)
{
putpixel(xc, yc, r);
delay(1);
boundfill(xc + 1, yc, r, b);
boundfill(xc - 1, yc, r, b);
boundfill(xc, yc + 1, r, b);
boundfill(xc, yc - 1, r, b);
}
}

void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, “..\\bgi”);
rectangle(100, 100, 300, 300);
boundfill(105, 105, 4, WHITE);
getch();
closegraph();
}

5.OUTPUT
12
13

6.CONCLUSION

IN computer graphichs when we use boundry fill algorithm , decding fill algorithm
decinding which oixels are considered neighbors is crucial . the concept of 8-
connected pixels allow the algorithm to connect and fill more and more
comprehensively across the graphics canvas

7.Project Outcomes Integrated

a)Create and utilize Simple Billing System program

b) Learn various OOP features by applying it into the program


14

ANNEXURE II
Evolution Sheet for the Micro Project
Academic Year: 2024-25 Name of Faculty: Prof.Padir Mam

Course :CGR Course Code: 313014 Semesters: 3th

Title of the Project : BOUNDARY FILL ALGORITHM


COs addressed by the Micro Project:

A: Use computer system.


B: Prepare business document using word processing tool.
Major learning outcomes achieved by students by doing the Project:

(a) Practical outcomes:

1. Computer system
2. Create, edit and save document.
3. Document Page Layout.
(b) Unit outcomes in Cognitive domain:

2a. Word processing, Previewing, saving, closing a document.


2b. Editing document, Formatting paragraphs, spacing &
align.
2c. Inserting elements to word documents, Changing layout of a document.
(c)Outcomes in Affective Domain-----------------------------------------------------------------
-------------------------------------------------------------------------------------

Comments/Suggestion about team work/leadership/inter-personal


communication (if any)

Roll
Student Name Marks out Marks out of 4 for Total out
No.
of 6 for performace in oral
performace presentation Of 10
in group
activity
1 Samiya Shaikh
2 Jindam Kalyani
3 Tanushri Gudur
4 Ravija nagare

(Name & Signature of Faculty)


15
16
17
18

You might also like