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.
- 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
- 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
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
-
Clone this repository:
git clone https://github.com/<your-username>/rice-cv-inspection.git cd rice-cv-inspection
-
(Optional) Create a virtual environment:
python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt
-
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).
-
Run the pipeline later (optional):
- Place your images under a root folder with subfolders per batch (or a single folder).
- Adapt
src/pipeline.pyor the notebook cells to point to yourpath. - Outputs (CSV + crops) will be written under
output/<folder>/or a configured directory.
- Python, NumPy, Matplotlib
- scikit-image (
skimage) for thresholding, morphology, regionprops - (Optional) scikit-learn for downstream classification/EDA
- Add EDA notebook: histograms of length/width/aspect ratio, scatter plots, correlation heatmaps
- Use
regionpropsmajor/minor axis for more geometry-robust measurements - Small validation set to compare auto vs manual counts
This project is released under the MIT License (see LICENSE).
Maintained by Murtaza. Contributions and suggestions are welcome!