A lightweight PySide6 desktop application for counting early-season crop stands (sunflower, corn, and other row crops) from large RGB GeoTIFF orthomosaics.
Designed for:
- Research plot trials
- Emergence assessment (e.g., ~7 DAE sunflower)
- Early corn stand counts
- High-throughput field phenotyping workflows
Optimized for large TIFFs (hundreds of MB to multi-GB) with built-in pyramid support.
- Define plots by clicking start/end points for each row
- Configurable number of rows per plot
- Configurable row spacing
- Optional fixed row length mode (e.g., standardized 20 ft strips)
- Adjustable row AOI width (ft)
- Excess Green (ExG) vegetation segmentation
- Otsu thresholding inside row AOI
- Morphological cleanup
- Connected components plant detection
- Cluster/double detection heuristic
- Raw and adjusted counts
Per Row:
- Row length (ft)
- Adjusted plant count
- Raw plant count
- Plants per foot
Per Plot:
- Total adjusted plants
- Total raw plants
- Plants per acre (adjusted + raw)
- Plot area (ft²)
- Built-in pyramid (overview) creation
- Option to build overviews in-place or on a copy (copy recommended)
- Smooth zoom and pan for large mosaics
rows.csv— row-level dataplots.csv— plot-level summariesannotated_overview.png- Individual plot images:
plot_####_raw.pngandplot_####_annot.png
⚠️ The original TIFF is never modified by annotations.
- Python 3.11 or 3.12+
Create and activate a virtual environment (recommended):
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/LinuxInstall dependencies:
pip install pyside6 rasterio opencv-python numpy scikit-imageOr using requirements.txt:
pyside6
rasterio
opencv-python
numpy
scikit-image
pip install -r requirements.txtpython Sunf_count_GUI.py- Go to File → Open GeoTIFF
- Set your Output Folder
- Check Ensure overviews (pyramids) on open
- Select Build overviews on a COPY (recommended)
This ensures smooth navigation on large images.
- Rows per plot
- Row spacing (inches)
- Row AOI width (ft)
- Fixed row length (optional)
- Detection parameters (area, circularity, cluster factor)
Click to define row endpoints:
- Row 1 → start, end
- Row 2 → start, end
- … After the final required click → preview computes automatically
| Shortcut | Action |
|---|---|
a |
Accept & Save |
d |
Discard |
ESC |
Discard preview |
Additional controls:
- Show Preview (Left) — visually inspect detection
- Mouse wheel — zoom
- Right-click drag — pan
- Reset View — return to full overview
- Compute Excess Green index:
ExG = 2G - R - B - Otsu thresholding within the row AOI
- Morphological closing
- Remove small objects
- Connected components labeling
For each row:
- Compute median blob area
- If
blob_area > cluster_factor × median:- Flag as cluster
- Assign a size multiplier (capped)
- Adjusted counts sum multipliers per row
- Sunflower emergence (~7 days after planting)
- Corn early stand counts
- Multi-row research plots
- Fixed-length sampling strips (e.g., 15 ft, 20 ft, 30 ft)
Place images in
docs/images/and reference them below.
output_folder/
│
├── rows.csv
├── plots.csv
├── annotated_overview.png
└── plots/
├── plot_0001_raw.png
├── plot_0001_annot.png
├── plot_0002_raw.png
└── ...
.
├── Sunf_count_GUI.py
├── README.md
├── requirements.txt
├── LICENSE
└── docs/
└── images/
Specify your license here (e.g., MIT, Apache 2.0).
If you use this tool in your research, please consider citing or acknowledging the source. Contributions and issues are welcome via GitHub.

