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.

