Automating leaf measurement
Extracting leaf traits from digitized herbarium specimens of Lobelia sect. Lobelia at aggregator scale.
This was my undergraduate research at Kent State University, advised by Dr. Andrea Case in the Department of Biological Sciences. The proposal is dated December 2021, and the work ran through 2022 with a final data pull in early 2024. It sat inside a larger NSF-funded programme — BEE: Ecological and evolutionary processes affecting the co-existence of close relatives (DEB-2015606, Case at Kent State; collaborative with Lynda Delph at Indiana and Nico Cellinese at Florida) — which uses Lobelia sect. Lobelia as a model for why closely related species do or don’t manage to live alongside each other. My piece of it was the phenotype side: getting trait data out of herbarium sheets without measuring every one by hand.
A second, related piece of work came out of the same lab project — the digital reconstruction of Lobelia silhouettes, whole-plant outlines drawn from restored herbarium specimens. The two are easy to conflate, because both end in a plant reduced to an outline. They are not the same thing: that one is reconstruction for depiction, this one is segmentation for measurement.
The data is already collected
The argument for this work is that the specimens already exist. Centuries of botanists have pressed, mounted and labelled plants, and digitization programmes have since photographed a large fraction of them and put the images behind public APIs. What has not happened is the measurement. A sheet photographed at 5100 × 3500 px contains leaf areas, blade widths, petiole dimensions, stem thickness and phenology — all of it visible, essentially none of it in a database.
Lobelia sect. Lobelia is a good test case precisely because it is awkward. The clade spanned 23 species as the project scoped it in 2021 — the section’s circumscription has since moved, and the 2025 phylogenomic paper puts it at 26 with 24 sampled — with real morphological range, from the tall red-flowered L. cardinalis to the small aquatic L. dortmanna, and several of them grow as basal rosettes. Most published herbarium-vision work targets plants with clearly separated, planar leaves on a stem. A rosette pressed flat is a pile of overlapping blades radiating from one point, and the whole difficulty of the project is downstream of that fact.
Acquisition was the first real problem
Before any model could be trained, the corpus had to be assembled and audited. Records came from GBIF, SERNEC, iDigBio and the Kent State herbarium, filtered to preserved specimens with coordinates, no flagged geospatial issues, and an attached still image.
The tedious part was that aggregators return duplicates: the same physical sheet surfaces repeatedly under one gbifID, sometimes with several images of differing usefulness. Each species was reconciled by hand — duplicates identified, the most representative image kept, broken links purged, and every deletion logged with its reasoning in a per-species ledger.
That ledger survives, and it is the most honest description of the dataset:
| stage | count |
|---|---|
| species accounted for | 23 |
| occurrence records screened | 2,906 |
| specimen images retained | 2,733 |
A later, narrower pull for L. siphilitica alone is permanently citable, since GBIF mints a DOI for every download (GBIF.org, 2024) — 10.15468/dl.5gavr9, 452 preserved-specimen records across 19 institutional datasets, retrieved 2024-02-16.
The record is long-tailed
Splitting the retained images by species exposes something the project didn’t set out to find. Herbarium coverage of this clade is extremely uneven:
| species | screened | retained |
|---|---|---|
| L. cardinalis | 899 | 811 |
| L. spicata | 484 | 468 |
| L. kalmii | 334 | 315 |
| L. glandulosa | 230 | 230 |
| L. puberula | 211 | 206 |
| L. paludosa | 129 | 127 |
| L. feayana | 123 | 122 |
| L. nuttallii | 116 | 115 |
| L. dortmanna | 151 | 111 |
| L. homophylla | 51 | 51 |
| L. appendiculata | 44 | 44 |
| L. elongata | 26 | 26 |
| L. floridana | 24 | 23 |
| L. brevifolia | 23 | 23 |
| L. georgiana | 20 | 20 |
| L. canbyi | 18 | 18 |
| L. flaccidifolia | 11 | 11 |
| L. rogersii | 9 | 9 |
| L. gattingeri | 2 | 2 |
| L. apalachicolensis | 1 | 1 |
Three orders of magnitude separate the best- and worst-sampled species — 811 sheets for L. cardinalis, a single usable one for L. apalachicolensis. Showy, common, widely cultivated plants get collected; narrow endemics do not. Any model trained on this corpus inherits that skew, and any trait comparison across the clade has to carry it as a caveat rather than average it away.
The diversity being measured
All of the above is machinery. This is the thing it exists to capture — the same extraction run across the clade, one representative leaf per species:
Nine species, not ten. L. canbyi is absent because its only mask cannot supply a leaf: the largest component in it is 3,257 px at 0.55 solidity — a stem sliver — against 0.93–0.97 for a clean blade. That is a segmentation failure, and dropping the species is more honest than showing debris under its name.
Does outline alone identify a species?
Showing that the shapes differ is not the same as showing they separate. Every one of the 104 masks yields multiple leaves, so the question can be asked quantitatively: 486 leaves from 88 specimens across 8 species, each outline resampled to 128 equally spaced pseudo-landmarks, aligned, scaled to unit centroid size, and ordinated by PCA. This follows the same family of method as the Procrustes pseudo-landmark approach the Case lab later published for leaf shape.
PC1 carries 48% of shape variance and is almost exactly leaf breadth — its correlation with directly measured width-to-length is r = 0.978, so the axis is a checked quantity rather than a label I assigned by eye. Species order along it monotonically, from L. glandulosa at a width:length of 0.109 to L. apalachicolensis at 0.439.
That axis is also where the species signal lives, and essentially nowhere else:
| PC1 | PC2 | |
|---|---|---|
| share of shape variance | 48% | 26% |
| between-species share of that axis (η²) | 0.493 | 0.006 |
PC2 is real variation — it is just variation within plants, not between species.
Classifying species from outline alone, with cross-validation grouped by specimen so no leaf from a test plant is ever seen in training:
| accuracy | |
|---|---|
| LDA, grouped by specimen | 0.372 |
| permuted-label null | 0.166 |
| majority-class baseline | 0.191 |
| LDA, naive split (leaves of one plant span train and test) | 0.430 |
So outline alone runs at roughly twice chance — a real signal, and a modest one. The naive split scores 6 points higher, which is the size of the pseudo-replication illusion you get for free if you forget that ten leaves off one plant are not ten independent observations.
What this does not show. Sampling is uneven (93 leaves from puberula, 26 from inflata) and specimen counts more so (21 for glandulosa, 3 for apalachicolensis), so the per-species positions are not equally trustworthy. Absolute size is discarded by construction, and size is a real diagnostic character. Venation, margin dentition and pubescence — all of which a botanist uses — are not in an outline at all. L. cardinalis (3 leaves) and L. canbyi (no usable leaf) are excluded entirely.
The honest reading is that leaf outline is a weak-but-genuine species character in this clade, and that the automation was never going to identify species from shape alone. That is a useful thing to have measured rather than assumed.
The pipeline
Specimen sheets are large and mostly empty, which makes naive whole-image segmentation wasteful and imprecise. The workflow was therefore two-stage, built on GinJinn2 (a herbarium-oriented wrapper over Detectron2) with a Mask R-CNN R101-FPN backbone:
- Annotate. Training masks were drawn in CVAT and exported as COCO. Sheets were rescaled from 5100 × 3500 to 1200 × 800, with model inputs normalized to 256 × 256. Target was 500+ annotated images, split 60 / 20 / 20 into train / validation / test.
- Detect. Sheets were cut into 2048 px sliding windows with 512 px overlap so that individual leaves occupied a usable fraction of the frame. Bounding boxes were predicted per window, then merged back across window seams to reconstruct whole-sheet predictions.
- Crop. Merged boxes were cropped with padding (
-p 25), turning one sheet into many single-leaf images. - Segment. A separate instance-segmentation model ran on the crops, producing the per-leaf masks the morphometrics depend on — and the leaf outlines shown above.
Splitting detection from segmentation matters: it lets the detector work at sheet scale, where context disambiguates a leaf from a label or a scale bar, while the segmentation model sees a tightly framed leaf and can spend its resolution on the margin, which is where the shape information actually lives.
The dismembered-sheet track
Running alongside the digital pipeline was a physical one, used both to generate clean training data and to provide ground truth. Specimens were dismembered, laid out and photographed, then processed under a fixed protocol: rotate every image in ImageJ so leaf tips face the same direction, record the 1 cm scale standard, and measure base-to-first-leaf, base-to-first-flower, and stem thickness at both the base and the first flower. Leaves too folded or damaged to read were excluded by explicit criterion rather than by eye.
What comes out the far end is a binary mask per specimen — every leaf reduced to an outline, ordered down the stem. This is the measurable object, and the thing the whole pipeline exists to produce:
The masks also make plain why the workflow needed an explicit exclusion criterion rather than a trained eye:
</div>
Leaf area then came from the LeafArea R package driving ImageJ, calibrated at 85 px/cm:
library(LeafArea)
run.ij(set.directory = ".../leafcrops",
distance.pixel = 85,
known.distance = 1, # cm
trim.pixel = 0)
Orientation is the quiet constraint here. Nearly every leaf-morphometrics tool assumes leaves are aligned on a common axis, which is trivial for a dismembered specimen you photographed yourself and decidedly not trivial for an arbitrary herbarium sheet.
What didn’t work
The morphometrics tooling was surveyed before anything was committed to, and most of it did not survive contact with real specimens:
| tool | outcome |
|---|---|
| MorphoLeaf | Needs single leaves on a clean, high-contrast, clutter-free background with uniform orientation. Herbarium sheets are none of those. |
| LeafJ (ImageJ) | Failed to detect whole leaves on our samples; manual correction was more work than measuring by hand. |
| LeafMachine | Promising, but MATLAB-licensed. |
| MASS | Also MATLAB. |
| TraitEx | Would not import our leaf images at all. |
| Morphidas | Too little documentation to evaluate. |
Two things are worth saying plainly. First, the binding constraint on this kind of work is rarely the model — it is that measurement tools assume an idealized input that digitized herbarium material never satisfies. Second, the rosette problem was never fully solved. Delineating individual leaves in a flattened rosette, where blades overlap and converge on a single point, remained the hard open edge of the project.
Status
This is completed undergraduate work, presented here as a record rather than as a maintained project. The trait-extraction work was never written up in its own right, and the pipeline is not packaged for reuse.
The code and the original workflow notes are now on GitHub at musharna/lobelia-leaf-morphometrics — the GBIF acquisition and Hough line-removal notebooks, the GinJinn2 and annotation commands, the dismembered-sheet protocol, the morphometrics tool survey, and the per-species acquisition ledger the counts on this page come from. Notebook outputs are stripped, and no specimen imagery is included: the raw sheets carry all-rights-reserved notices burned into the pixels regardless of the licence field on the aggregator record.
The wider programme it belonged to has since published its phylogenomic arm, under the same NSF awards (Godden et al., 2025).
Provenance. Specimen images are the property of their holding institutions and are used here under their respective terms; the GBIF download above is CC BY-NC 4.0. Counts on this page come from the project’s own acquisition ledger, and the two incomplete species tabs are flagged rather than silently dropped.
References
2025
- MPEPopulation-level phylogenomic analysis yields insights into species cohesion and population substructure of Lobelia section Lobelia (Campanulaceae)Molecular Phylogenetics and Evolution, 2025Phylogenomic arm of the same NSF BEE programme (DEB-2015606) that the Lobelia Silhouettes trait-extraction work sat within.
2024
- DataGBIF Occurrence Download: Lobelia siphilitica preserved specimens with imagesFeb 2024452 preserved-specimen records across 19 institutional datasets, retrieved 2024-02-16. Taxon key 5409120, country US, georeferenced, no geospatial issue, media type StillImage, CC BY-NC 4.0.