Skip to content

murtazabaig/AI-Rice-Image-Analysis

Repository files navigation

Rice Grain Inspection — Computer Vision Pipeline

Status: Executed notebook with preserved outputs • Last updated: 2025-08-15 04:39 PKT

This repository contains an end-to-end computer vision pipeline to detect, count, and measure rice grains from images. It uses Otsu thresholding, morphology, and connected-component analysis to isolate each grain, compute geometry (orientation, length, width), and export a CSV per folder. Rotated, cropped grain images can be saved for visual QA.

Highlights

  • Batch processing across subfolders (each folder = variety/batch)
  • Per-grain metrics: orientation (rad/deg), length, width (extensible to area, aspect ratio, solidity, etc.)
  • Saves aligned ROI crops for inspection
  • Cleaned notebook with ready outputs for portfolio/client review

Quick Results (from preserved notebook outputs)

  • Images processed: 25
  • Total grains detected (sum of per-image counts): 335

Per-folder totals:

  • Adhwar: 60 grains across 5 images
  • kernal: 75 grains across 5 images
  • superIndianAdhwar: 69 grains across 5 images
  • SuperIndianSaila: 52 grains across 5 images
  • superkernalbasmatipurani: 79 grains across 5 images

Repository Structure

rice-cv-inspection/
├─ notebooks/
│  ├─ Rice_Analysis_Cleaned.ipynb      # with outputs, presentation-ready
│  ├─ Rice_Analysis_Lite.ipynb          # no outputs, tiny for quick preview
│  └─ AI Rice Image Analysis.ipynb      # original notebook (as provided)
├─ src/
│  └─ pipeline.py                        # modular skeleton (optional script path)
├─ data_sample/                          # put 5–10 example images here (optional)
├─ outputs_sample/                       # sample CSV/crops (optional)
├─ .gitignore
├─ LICENSE
├─ README.md
└─ requirements.txt

Getting Started

  1. Clone this repository:

    git clone https://github.com/<your-username>/rice-cv-inspection.git
    cd rice-cv-inspection
  2. (Optional) Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate   # Windows: .venv\Scripts\activate
    pip install -r requirements.txt
  3. Open the notebook:

    • notebooks/Rice_Analysis_Cleaned.ipynb → already executed with outputs (no need to run).
    • notebooks/Rice_Analysis_Lite.ipynb → no outputs (fast to load on GitHub).
  4. Run the pipeline later (optional):

    • Place your images under a root folder with subfolders per batch (or a single folder).
    • Adapt src/pipeline.py or the notebook cells to point to your path.
    • Outputs (CSV + crops) will be written under output/<folder>/ or a configured directory.

Tech Stack

  • Python, NumPy, Matplotlib
  • scikit-image (skimage) for thresholding, morphology, regionprops
  • (Optional) scikit-learn for downstream classification/EDA

Roadmap

  • Add EDA notebook: histograms of length/width/aspect ratio, scatter plots, correlation heatmaps
  • Use regionprops major/minor axis for more geometry-robust measurements
  • Small validation set to compare auto vs manual counts

License

This project is released under the MIT License (see LICENSE).

Credits

Maintained by Murtaza. Contributions and suggestions are welcome!

About

Computer vision pipeline to detect, count, and measure rice grains. Includes a cleaned notebook with preserved outputs + modular script.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors