Skip to content

Segments objects in an image by grouping connected pixels with similar RGB values using a flood-fill algorithm. It filters small objects, identifies the largest as the background, and assigns unique IDs. The results are visualized by overlaying object IDs on an output image, skipping the background.

License

Notifications You must be signed in to change notification settings

AnkitSinghGTHB/2d-object-detection-without-opencv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

2d-object-detection-without-opencv

Segments objects in an image by grouping connected pixels with similar RGB values using a flood-fill algorithm. It filters small objects, identifies the largest as the background, and assigns unique IDs. The results are visualized by overlaying object IDs on an output image, skipping the background.

Image Object Segmentation and Overlay

This project performs object segmentation in an image based on color similarity. It identifies connected components, assigns unique IDs to each object, and generates an overlay image with object IDs.

Features

  • Flood-Fill Algorithm: Groups connected pixels with similar RGB values.
  • Object Filtering: Removes small objects below a size threshold.
  • Background Identification: Recognizes and labels the largest object as the background.
  • Overlay Generation: Outputs an image with object IDs displayed.

Requirements

  • Python 3.7+
  • Libraries: Pillow, numpy

Install dependencies with:

pip install Pillow numpy

Usage

  1. Place your input image in the input directory and name it image1.png (or modify the file_path in the script).

  2. Run the script:

python script.py
  1. The output image with overlaid object IDs will be saved to the output directory as overlay_with_numbers.png.

Parameters

  • Threshold (threshold) : Adjusts color similarity sensitivity (default: 170).

  • Min Object Size (min_object_size) : Filters out small objects (default: 100).

Example

License

This project is licensed under the MIT License. See LICENSE for details.

About

Segments objects in an image by grouping connected pixels with similar RGB values using a flood-fill algorithm. It filters small objects, identifies the largest as the background, and assigns unique IDs. The results are visualized by overlaying object IDs on an output image, skipping the background.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages