This repository explores an approach that combines deep learning with conventional feature detection techniques to locate multiple circular areas in an image.
Given a grayscale image containing
-
$N_c$ is a random number greater than 1. - The circular areas vary in brightness.
- Their positions are randomly distributed within the image domain.
- The image may contain background noise.
The objective is to develop a model that, when given an input image, accurately returns a list of coordinates corresponding to all detected circular areas.
The process of locating circular areas consists of two key steps:
-
Image Denoising and Brightness Normalization
A deep convolutional neural network (CNN) is utilized to denoise the image and transform circular regions of varying brightness into multiple circles with nearly uniform brightness. -
Center Coordinate Extraction
The Circle Hough Transform is applied to extract the coordinates of the centers of these multi-circles.
Illustration of the model for detecting multiple circular areas
The following presents the training history and evaluation results for the model configured in config.yml
:
Metric | Non-Noised Test Data | Noised Test Data |
---|---|---|
Total Circles | 3,124 | 3,079 |
Detected Circles | 3,048 | 2,975 |
Missed Circles | 76 | 104 |
False Positives | 0 | 0 |
Detection Rate (%) | 97.57 | 96.62 |
Precision | 1.00 | 1.00 |
Recall | 0.98 | 0.97 |
F1 Score | 0.99 | 0.98 |
Circular Area Detection Performance
The code has been successfully tested with the following dependencies:
- Python 3.9.21
- TensorFlow 2.18.0
- PyYAML 6.0.2
- OpenCV-Python 4.11.0.86
- NumPy 2.0.2
- Matplotlib 3.9.4
Ensure all required packages are installed before running the code.
To begin, clone the repository:
git clone https://github.com/chenbei102/cb_multi_circle_detection.git
cd cb_multi_circle_detection
The config.yml
file allows you to customize various settings. You can modify:
- The datasets used for training, validation, and testing.
- The deep CNN architecture.
- The noise level added to input images.
- Other relevant parameters.
Edit this file as needed before proceeding.
Run the following command to generate three datasets for training, validation, and testing:
python gen_dataset.py
python train.py
The trained model and training history will be saved.
To plot training and validation loss over epochs, run:
python plot_history.py
Assess the model's circular area detection performance with:
python evaluate.py
Evaluation metrics such as detection rate, precision, recall, and F1-score will be calculated.
python plot_predict.py
A sample image will be processed to detect circular regions. The detected circles will be visually overlaid on the original image, which will then be displayed.