Skip to content

zosiadd/Project-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Project-algorithms

The goal of this project is to process a raster image represented as an n x n array of black and white pixels, and to identify and label all distinct black regions (connected components). The solution consists of three main steps:

Graph Construction Black pixels are treated as graph vertices. Edges are added between neighboring black pixels using 4-connectivity (top, bottom, left, right).

Connected Components Detection A Depth-First Search (DFS) algorithm is used to explore the graph and detect distinct connected components, each representing a separate black region.

Region Labeling Each black pixel is assigned a unique identifier corresponding to its region, creating a result matrix that visually distinguishes individual blobs.

Example:

image

Output:

Number of distinct black regions

Matrix with labeled regions (black pixels marked with region IDs, white pixels as 0)

The program supports both user-defined and default input matrices and gracefully handles invalid input by falling back to the default option.

This project was carried out as part of student projects by: zosiadd and Aleksandra Gałczyńska

About

Project- algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages