Image Algorithms (img-algos) is a collection of Python-based image processing and computer vision implementations using OpenCV, PyTorch, and TensorFlow.
The repository explores classical computer vision concepts and modern deep learning architectures for visual recognition, object localization, object detection, distance estimation, and image segmentation.
It brings together several independent projects covering different aspects of computer vision, including YOLO-based object detection, real-time visual recognition, instance segmentation, and medical image analysis.
The primary objective is to provide practical implementations and experimental environments for understanding, developing, and evaluating image algorithms and deep learning-based computer vision systems.
- Image Processing and Computer Vision
- Object Detection and Localization
- Real-Time Object Detection
- Object Counting and Distance Estimation
- Convolutional Neural Networks (CNNs)
- Semantic and Instance Segmentation
- Medical Image Segmentation
- Deep Learning-Based Visual Recognition
- OpenCV and PyTorch Implementations
- TensorFlow-Based Computer Vision Models
The repository currently contains four major computer vision projects.
Directory: ObjDet-Distance/
An object detection and distance estimation system based on YOLO architectures and deep learning.
The implementation uses YOLOv3 as its primary object detection model and includes a separate YOLOv4 implementation.
Key Features
- Real-time object detection using webcam input.
- Object localization with bounding boxes.
- Object counting.
- Approximate distance estimation using bounding-box dimensions.
- FPS monitoring.
- Multiple-camera streaming examples.
- Flask-based video streaming interface.
- YOLOv3 and YOLOv4 implementations.
Technologies
- Python
- PyTorch
- OpenCV
- NumPy
- Flask
- YOLOv3 / YOLOv4
Project Structure
ObjDet-Distance/
β
βββ YOLOv4/
β βββ camera.py
β βββ object_detection.py
β βββ ...
β
βββ utils/
βββ app.py
βββ camera.py
βββ object_detection.py
βββ util.py
βββ README.md
Run the YOLOv3 Webcam Detection
cd ObjDet-Distance
pip install -r requirements.txt
python object_detection.pyRun the YOLOv4 Webcam Detection
cd ObjDet-Distance/YOLOv4
python object_detection.pyImportant: Download and configure the corresponding YOLO configuration files, model weights, and COCO class labels before execution.
The distance measurement is an approximate estimate derived from detected bounding-box dimensions. It should not be treated as calibrated metric depth measurement.
Directory: YOLO-OpenCV/
A computer vision implementation demonstrating object detection using YOLOv3, OpenCV's Deep Neural Network (DNN) module, and Python.
The project uses a YOLOv3 model trained on the COCO dataset, supporting detection across 80 object categories.
Key Features
- Object detection in static images.
- Object detection in video files.
- Real-time webcam object detection.
- Bounding-box localization.
- Object classification with confidence scores.
- Non-Maximum Suppression (NMS).
- FPS and inference-time monitoring.
The repository also includes a separate real-time MobileNet SSD webcam detection example.
Technologies
- Python
- OpenCV DNN
- NumPy
- YOLOv3
- MobileNet SSD
- imutils
Project Structure
YOLO-OpenCV/
β
βββ image object dection/
β βββ yolo.py
β
βββ video object dection/
β βββ yolo_video.py
β
βββ real-time-object-detection/
β βββ real_time_object_detection.py
β
βββ README.md
Installation
pip install numpy
pip install opencv-python
pip install imutilsA. Image Object Detection
Run from the image detection directory:
python yolo.py --image images/baggage_claim.jpgB. Video Object Detection
Run from the video detection directory:
python yolo_video.py \
--input videos/airport.mp4 \
--output output/airport_output.avi \
--yolo yolo-cocoC. Real-Time Webcam Detection
Run from the real-time detection directory:
python real_time_object_detection.pyModel Requirements
For YOLOv3, prepare:
yolov3.cfgyolov3.weightscoco.names
For the MobileNet SSD example, prepare:
MobileNetSSD_deploy.prototxt.txtMobileNetSSD_deploy.caffemodel
Known Limitation
YOLOv3 may struggle with very small objects and multiple objects located close together within the same image region.
Directory: YOLACT-tf/
A TensorFlow 2 implementation of YOLACT (You Only Look At CoefficienTs), a one-stage instance segmentation architecture.
Unlike conventional object detection, which primarily predicts object classes and bounding boxes, instance segmentation generates a separate pixel-level mask for each detected object.
YOLACT achieves this through two parallel components:
- Prototype Mask Generation: Generates a collection of shared prototype masks.
- Prediction Head: Predicts object classes, bounding boxes, and mask coefficients.
The final instance masks are assembled by combining the prototype masks with their corresponding predicted coefficients.
Key Features
- Real-time instance segmentation architecture.
- Prototype mask generation.
- Bounding-box prediction.
- Object classification.
- Fast Non-Maximum Suppression (Fast NMS).
- Feature Pyramid Network (FPN).
- COCO 2017 dataset support.
- Pascal SBD dataset support.
- Custom COCO-style dataset preparation.
- Configurable feature extraction backbones.
Supported Backbones
| Backbone | Framework |
|---|---|
| ResNet-50 | TensorFlow / Keras |
| ResNet-101 | TensorFlow / Keras |
| MobileNetV2 | TensorFlow / Keras |
| EfficientNet-B0 | TensorFlow / Keras |
Technologies
- Python
- TensorFlow 2
- Keras
- NumPy
- COCO Dataset
- Deep Learning
Project Structure
YOLACT-tf/
β
βββ data/
β βββ coco_dataset.py
β βββ coco_tfrecord_creator.py
β βββ coco_tfrecord_decoder.py
β
βββ layers/
β βββ detection.py
β βββ fpn.py
β
βββ loss/
β βββ loss_yolact.py
β
βββ utils/
β βββ augmentation.py
β βββ learning_rate_schedule.py
β βββ utils.py
β
βββ config.py
βββ yolact.py
βββ train.py
βββ eval.py
βββ README.md
Dataset Preparation
The project supports COCO 2017 training and validation data.
Download:
Extract the required images and annotation JSON files into the data/ directory.
Generate TFRecord files:
python -m data.coco_tfrecord_creator \
-train_image_dir ./data/train2017 \
-val_image_dir ./data/val2017 \
-train_annotations_file ./data/instances_train2017.json \
-val_annotations_file ./data/instances_val2017.json \
-output_dir ./data/cocoTraining
Configure model parameters in config.py.
For COCO training:
python train.py \
-name coco \
-tfrecord_dir ./data \
-weights ./weights \
-batch_size 8 \
-momentum 0.9 \
-weight_decay 0.0005 \
-print_interval 10 \
-save_interval 5000Note: Custom dataset configuration and several inference instructions in the existing project documentation are still incomplete.
Original Research Paper
Bolya et al., YOLACT: Real-time Instance Segmentation.
https://arxiv.org/abs/1904.02689
Directory: iter-FCN/
An implementation of Iterative Fully Convolutional Networks for automatic vertebra segmentation in medical images.
The project focuses on instance-aware segmentation of individual vertebrae in three-dimensional CT and MRI image volumes.
Traditional fully convolutional networks can struggle to separate adjacent vertebrae because of anatomical similarities and complex spatial structures.
Iter-FCN addresses this challenge through an iterative segmentation strategy that uses two inputs:
- Image Patch: The current three-dimensional medical image patch.
- Instance Memory Patch: A memory representation of previously segmented structures.
The instance memory helps the network identify the next unsegmented vertebra and progressively segment individual structures.
Key Features
- Automatic vertebra segmentation.
- Three-dimensional medical image processing.
- Patch-wise segmentation.
- Instance-aware segmentation.
- Instance memory mechanism.
- Image preprocessing and resampling.
- Distance-transform-based weight calculation.
- Elastic deformation and image augmentation.
- Dice coefficient evaluation.
Technologies
- Python
- PyTorch
- NumPy
- SciPy
- SimpleITK
- MedPy
Dataset
The implementation uses the CSI2014 spine segmentation challenge dataset.
Dataset source:
SpineWeb β Medical Image Segmentation Datasets
Preprocessing includes
- Resampling images and masks to isotropic 1 mm Γ 1 mm Γ 1 mm resolution.
- Calculating weight penalty coefficients using distance transforms.
- Cropping images and masks.
- Generating image patches.
- Generating instance memory patches.
- Preparing mask and weight patches.
Project Structure
iter-FCN/
β
βββ data/
β βββ dataset.py
β βββ preprocessing.py
β
βββ utils/
β βββ metrics.py
β
βββ iterativeFCN.py
βββ train.py
βββ instance_segmentation.py
βββ eval.py
βββ README.md
Installation
cd iter-FCN
pip install -r requirements.txtStep 1 β Dataset Preprocessing
python -m data.preprocessing \
--dataset /path/to/CSI2014Step 2 β Model Training
python train.py \
--dataset /path/to/preprocessed_datasetStep 3 β Instance Segmentation
python instance_segmentation.py \
--test_dir /path/to/test/images \
--weights /path/to/pretrained/weightsStep 4 β Evaluation
python eval.py \
--label_dir /path/to/test/labels \
--pred_dir /path/to/predictionsReported Segmentation Result
The existing project documentation reports the following average Dice coefficient:
| Evaluation | Average Dice |
|---|---|
| Repository implementation | 0.918 |
| Original paper | 0.958 |
The repository notes that additional refinement techniques for preprocessing and postprocessing were not used in its reported implementation.
These figures are reported project results, not an independently reproduced benchmark.
The repository provides practical exposure to several important computer vision concepts.
| Category | Concepts / Algorithms | Project |
|---|---|---|
| Object Detection | YOLOv3, YOLOv4 | ObjDet-Distance |
| Object Detection | YOLOv3, OpenCV DNN | YOLO-OpenCV |
| Real-Time Detection | MobileNet SSD | YOLO-OpenCV |
| Object Localization | Bounding Boxes, NMS | ObjDet-Distance, YOLO-OpenCV |
| Distance Estimation | Bounding-Box-Based Estimation | ObjDet-Distance |
| Instance Segmentation | YOLACT, Prototype Masks | YOLACT-tf |
| Feature Extraction | ResNet, MobileNetV2, EfficientNet | YOLACT-tf |
| Medical Image Segmentation | Iterative FCN, Instance Memory | iter-FCN |
| Evaluation | Dice Coefficient | iter-FCN |
| Deep Learning | CNNs, FPN, Fully Convolutional Networks | Multiple Projects |
The repository contains independent implementations that explore different computer vision tasks.
flowchart TD
A["Image Algorithms Repository"]
A --> B["Object Detection"]
A --> C["Instance Segmentation"]
A --> D["Medical Image Segmentation"]
B --> E["YOLOv3 / YOLOv4"]
B --> F["OpenCV DNN"]
B --> G["MobileNet SSD"]
E --> H["Object Localization"]
E --> I["Object Counting"]
E --> J["Distance Estimation"]
F --> K["Image Detection"]
F --> L["Video Detection"]
C --> M["YOLACT"]
M --> N["Prototype Masks"]
M --> O["Mask Coefficients"]
N --> P["Instance Masks"]
O --> P
D --> Q["Iterative FCN"]
Q --> R["Image Patches"]
Q --> S["Instance Memory"]
R --> T["Vertebra Segmentation"]
S --> T
The repository explores different computer vision and deep learning technologies.
- Python
- OpenCV
- OpenCV DNN
- Image preprocessing
- Object localization
- Image segmentation
- PyTorch
- TensorFlow 2
- Keras
- YOLOv3
- YOLOv4
- MobileNet SSD
- YOLACT
- ResNet
- MobileNetV2
- EfficientNet
- Fully Convolutional Networks (FCNs)
- NumPy
- SciPy
- Pillow
- Matplotlib
- SimpleITK
- MedPy
- imutils
- Flask
Because the repository contains multiple independent implementations, each project should be configured with its own Python environment.
git clone https://github.com/Miraj-Rahman-AI/img-algos.git
cd img-algospython3 -m venv .venvActivate the environment.
macOS / Linux
source .venv/bin/activateWindows
.venv\Scripts\activateNavigate into the project you want to execute and install its dependencies.
For example:
cd iter-FCN
pip install -r requirements.txtFor other projects, follow the installation instructions in their respective README files.
- PyTorch and TensorFlow should be installed in compatible environments rather than assuming that one environment supports every project.
- The original ObjDet-Distance documentation references legacy PyTorch 1.2.0 and torchvision 0.4.0 versions. Modern Python and CUDA installations may require dependency updates.
- ObjDet-Distance imports
win32com.clientfor Windows text-to-speech functionality. Running the current scripts on macOS or Linux requires modifying or replacing that Windows-specific dependency. - The Iter-FCN inference implementation explicitly uses CUDA. CPU execution requires code modifications.
- YOLACT requires TensorFlow 2, as checked by its model implementation.
Different projects require different datasets and pretrained model weights.
| Project | Dataset / Model Resources |
|---|---|
| ObjDet-Distance | YOLOv3 / YOLOv4 weights and COCO labels |
| YOLO-OpenCV | COCO pretrained YOLOv3 weights and MobileNet SSD model files |
| YOLACT-tf | COCO 2017 and Pascal SBD |
| iter-FCN | CSI2014 Spine Segmentation Dataset |
Some datasets and model weights must be downloaded separately and placed in the directories expected by the corresponding scripts.
Before running experiments, verify the configuration paths, pretrained checkpoints, dataset structure, and annotation formats.
The repository contains research implementations and experimental code. Some components may require additional configuration before they can be used in a new environment.
Known considerations include:
- Separate Dependencies: The projects use different deep learning frameworks and dependency versions.
- Hardware Compatibility: Some implementations rely on CUDA-specific operations.
- Legacy Implementations: Older model implementations may require updates to work with current Python and deep learning framework versions.
- Model Weights: Certain pretrained weights and configuration files need to be obtained separately.
- Dataset Preparation: Medical imaging and instance segmentation experiments require specific preprocessing pipelines.
- Distance Estimation: The bounding-box-based distance estimate requires camera-specific calibration and validation for reliable real-world measurements.
- YOLO Limitations: YOLOv3 may have difficulty detecting small or closely grouped objects.
- Incomplete Documentation: Some YOLACT custom dataset and inference instructions remain unfinished.
The repository is intended primarily for educational, experimental, and research purposes. Experimental results should be independently validated before being used in production systems.
Potential future improvements include:
- Implementing additional classical image processing algorithms.
- Adding more object detection architectures, including YOLOv5, YOLOv8, and newer models.
- Expanding semantic and instance segmentation implementations.
- Adding Vision Transformer (ViT)-based computer vision models.
- Improving distance estimation through camera calibration and depth estimation.
- Supporting modern PyTorch and TensorFlow versions.
- Adding reproducible evaluation scripts and standardized benchmarks.
- Improving documentation and installation procedures.
- Developing more efficient real-time computer vision applications.
This repository brings together different computer vision implementations and research-oriented projects, including work based on existing open-source architectures and research contributions.
Acknowledgment is given to the original researchers, authors, and developers whose models, algorithms, datasets, and open-source implementations support these projects.
Please refer to the individual project documentation for specific implementation references and attribution.
Image Algorithms | img-algos
Computer Vision Β· Image Processing Β· Deep Learning
Exploring Visual Intelligence Through Algorithms and Implementation