A computer vision project to automatically detect saffron flowers in agricultural images using image processing techniques.
This project implements an image analysis pipeline using Python and OpenCV to locate saffron flowers in an image. It utilizes color space conversion (RGB → HSV/HSI), thresholding, and morphological filtering to identify flower regions based on their distinct purple/violet color characteristics.
🔬 Application: A useful tool for smart farming, agricultural monitoring, and AI-based plant detection systems.
- 🌈 Color Space Conversion: Efficient RGB to HSV/HSI transformation.
- 🎯 Precise Detection: Identifies flowers using color masking thresholds.
- 🧹 Noise Reduction: implementation of morphological operations (Erosion/Dilation).
- 📦 Modular Design: Easy to extend with Machine Learning models.
- 🖼 Visual Output: Generates annotated images with bounding boxes/contours.
- Input: Load the saffron field image using OpenCV.
- Preprocessing: Convert the image into HSV color space for better color separation.
- Masking: Apply lower and upper thresholds to isolate the saffron purple color.
- Cleaning: Perform morphological operations to remove noise and fill gaps.
- Output: Mark detected regions (contours/centroids) and save the result.
saffronImageProcess/
│
├── saffron_detector.py # Main image processing script
├── utils.py # Helper functions (optional)
├── sample_input.jpg # Input image of saffron flowers
├── sample_output.jpg # Output after processing
├── requirements.txt # Python dependencies
└── README.md # Project documentation
If you have a requirements.txt file:
pip install -r requirements.txtOr install the libraries manually:
pip install opencv-python numpy matplotlibMake sure to place your input image in the project directory (e.g., sample_input.jpg) or update the path in the code.
python saffron_detector.py| Input Image | Output Image |
|---|---|
![]() |
![]() |
- Python 3.x
- OpenCV (Image Processing)
- NumPy (Array Manipulations)
- Matplotlib (Visualization)
- 🔬 Add shape/contour analysis for better accuracy.
- 🤖 Integrate Deep Learning (CNNs) for flower classification.
- 🌐 Add a web-based interface (Streamlit or FastAPI).
- 📤 Export counting results as structured data (CSV/JSON).
Mohammad Davood Vahhab Rajaee
📫 Email: mdvahhabrajaee@gmail.com | mdvr9980@gmail.com


