VisionSeg is a modular computer vision framework for classical image segmentation, designed with software engineering principles.
Unlike simple scripts, this project is built as a scalable system with:
- Config-driven pipelines
- Modular architecture
- Extendable components
It focuses on separating foreground objects from background using traditional computer vision techniques.
- Fixed Thresholding
- Otsu Thresholding
- Adaptive Thresholding
- Erosion
- Dilation
- Opening (noise removal)
- Closing (hole filling)
- Connected Components
- Object Counting
- Area Filtering
- Bounding Boxes
- Object Highlighting
- Result Export
- Config-driven pipeline (
config.yaml) - Modular code structure
- Easy extensibility
- Image Segmentation
- Binary Thresholding
- Morphological Transformations
- Noise Reduction
- Connected Component Analysis
- Pipeline Design in Computer Vision
Technologies Used:
- Python: Core programming language.
- OpenCV (cv2): Image processing, thresholding, morphology, and component analysis.
- NumPy: Matrix operations and statistical calculations (e.g., median area).
- PyYAML: Configuration management.
Pipeline Flow:
1. Input Image
↓
2. Preprocessing (Grayscale, CLAHE Contrast Enhancement, Gaussian Blur)
↓
3. Segmentation (Otsu / Adaptive / Fixed Thresholding)
↓
4. Morphology (Opening, Closing, Dilating, Eroding for Noise Removal)
↓
5. Component Analysis (Connected Components, Area Filtering, Circularity)
↓
6. Visualization & Output (Bounding Boxes, Highlighted Objects)
visionseg/
│
├── main.py
├── config.yaml
├── requirements.txt
├── README.md
│
├── src/
│ ├── preprocessing/
│ │ └── grayscale.py
│ ├── segmentation/
│ │ └── threshold.py
│ ├── morphology/
│ │ └── operations.py
│ ├── analysis/
│ │ └── components.py
│ ├── visualization/
│ │ └── draw.py
│ └── pipeline/
│ └── pipeline.py
│
├── resources/
│ └── coins.jpg
│
└── outputs/
└── result.png
- Python 3.x
- OpenCV
- NumPy
- PyYAML
-
Create a Virtual Environment:
python -m venv venv
-
Activate the Environment:
- Mac / Linux:
source venv/bin/activate - Windows:
venv\Scripts\activate
- Mac / Linux:
-
Install Dependencies:
pip install -r requirements.txt
git clone https://github.com/nguyenpd-vincent/VisionSeg.git
cd VisionSegEdit config.yaml:
preprocessing:
grayscale: true
segmentation:
method: otsu # threshold | otsu | adaptive
threshold:
value: 120
adaptive:
block_size: 11
C: 2
morphology:
operation: close # open | close | erode | dilate | none
kernel:
size: 5 # 3, 5, 7
shape: ellipse # square | ellipse | cross
analysis:
min_area: 500
max_area: 50000python main.py --image resources/coins.jpg- Accurate foreground-background separation
- Noise reduction via morphology
- Detection and counting of objects
Can explore:
- Different threshold values
- Kernel sizes (3x3 → 5x5)
- Morphological operations
- Otsu vs Adaptive thresholding
This project demonstrates:
- Strong understanding of classical computer vision
- Ability to design modular systems
- Experience with configurable pipelines
- Practical segmentation and object detection skills