Skip to content

ferreiradiego/maize-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Classification of defects in Zea Mays corn grain samples

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.

Description

This project uses digital image processing techniques for the classification of corn grains of the Zea Mays species through the color of the grains.

Contents

Repository contents list

Folder Content
img
  • aquisition_device: images of the acquisition device
  • dataset: image database, in grayscale and in RGB, both without background
src
  • Python and Jupyter Notebook code for preprocessing, model creation, and sample classification
  • aquisition_device: PlatformIo project in C/C++ to load on ESP-32 CAM
  • tools: various functions for preprocessing and for the main code
resources Dataset in dataframe format and classification results

Dataset

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.

Description of items for each image label
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.

Getting Started

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
Front View Setup Top View Setup

The code to be loaded into the ESP-32 CAM is aquisition_device.

Preprocessing

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
RGB example Grayscale example

Installation

Dependencies

You can install any missing dependencies with pip.

How to install

Follow these steps to clone the repository and install the necessary dependencies:

  1. Clone the repository:

    git clone https://github.com/ferreiradiego/maize-classification.git
    
  2. Navigate into the cloned repository:

    cd maize-classification
    
  3. Create a virtual environment:

    python3 -m venv env
    
  4. Activate the virtual environment:

    • On Windows:
      .\env\Scripts\activate
      
    • On Unix or MacOS:
      source env/bin/activate
      
  5. Install the necessary dependencies:

    pip install -r requirements.txt
    

Running the Program

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