Welcome to our repository which tackles corn grain classification using Digital Image Processing (DIP). This repository contains scripts, notebooks, a dataset, and a code for image acquisition using an ESP-32 CAM module.
This project uses digital image processing techniques for the classification of corn grains of the Zea Mays species through the color of the grains.
Folder | Content |
---|---|
img |
|
src |
|
resources | Dataset in dataframe format and classification results |
The dataset contains a total of 1314 different images, which are presented in two different color spaces: RGB (color) and grayscale.
The image labels identify the percentages of defects and the quantity of grains in each sample.
Item | Description |
---|---|
first |
- a1 are samples with 30% of defective grains - a2 are samples with 25% of defective grains - a3 are samples with 20% of defective grains - a4 are samples with 15% of defective grains - a5 are samples with 10% of defective grains - a6 to a11 are samples with all healthy grains |
second | Quantity of grains: 50, 60, 70, 80, 90 and 100 |
third | Image number, for each defect percentage and grain quantity there are 20 images. Samples with healthy grains have varied quantities of images. |
Acquisition of images for the dataset
The images illustrate the acquisition device, where the grains are placed on the blue background, and the microcontroller at the top captures the image with each new command coming through Serial Communication.
The dimensions of the box are 30x30x30 cm. Two 12 W LED lamps are used for the lighting system
Front View Setup | Top View Setup |
![]() |
![]() |
The code to be loaded into the ESP-32 CAM is aquisition_device.
After obtaining the images of the samples, preprocessing is applied, which prepares and labels the images for the model creation and classification stages. The resulting images from the preprocessing are shown below, with the grayscale image being used for classification.
RGB example | Grayscale example |
![]() |
![]() |
- Python 3.7+
- NumPy
- Pandas
- Scikit-learn
- Matplotlib
- Plotly
- Seaborn
- OpenCV
- Pandas
- NumPy
You can install any missing dependencies with pip.
Follow these steps to clone the repository and install the necessary dependencies:
-
Clone the repository:
git clone https://github.com/ferreiradiego/maize-classification.git
-
Navigate into the cloned repository:
cd maize-classification
-
Create a virtual environment:
python3 -m venv env
-
Activate the virtual environment:
- On Windows:
.\env\Scripts\activate
- On Unix or MacOS:
source env/bin/activate
- On Windows:
-
Install the necessary dependencies:
pip install -r requirements.txt
The scripts required for data preprocessing and model training are located in the src
directory.
You can run Jupyter notebooks in either JupyterLab or Jupyter Notebook