All tools Print with PE stamp box Designed for sealed engineering submittals — print drops PE stamp + signature block at the end.

Photo-Sieve Grain Size Distribution Calculator

Particle-size distribution from a top-down photograph of a gravel bar, riverbed, or armor layer. Returns D₁₆, D₅₀, D₈₄, D₉₀, area-weighted mean, Folk-Ward sorting σ, Wentworth class breakdown, cumulative grain-size curve, and phi histogram. Watershed segmentation runs entirely in your browser via OpenCV.js — your photo never leaves your device.

top-down
Loading OpenCV.js (~10 MB, one-time per visit)…
No photo loaded. Pick a JPEG/PNG/WebP above; nothing is sent to a server.
$$ D_p = \text{b-axis at which } p\% \text{ of the total grain area is finer} $$
$$ \sigma_I = \frac{\varphi_{16} - \varphi_{84}}{4} + \frac{\varphi_{5} - \varphi_{95}}{6.6}, \quad \varphi = -\log_2(d_{\text{mm}}) $$
D₁₆ / D₅₀ / D₈₄ / D₉₀ percentile grain sizes (mm) · σ_I Folk-Ward inclusive graphic standard deviation (sorting), in φ units · b-axis intermediate axis of each grain, the standard size for sieve-equivalence, taken from each grain's minimum-area bounding rectangle · area-weighted percentiles use grain area, the photographic equivalent of mass-percent sieving.

How the algorithm works

The tool implements classical photo-sieving (Graham, Reid & Rice, 2005) with a watershed step to separate touching grains, all running in WebAssembly via OpenCV.js. Steps:

  1. CLAHE local contrast. Contrast-limited adaptive histogram equalization (clipLimit = 2.0, 8×8 tile) flattens uneven lighting before thresholding. Critical for field photos shot under non-uniform sun.
  2. Otsu threshold. Automatic global threshold separates stones (bright) from inter-grain shadow (dark).
  3. Morphological cleanup. Open-then-close with a 3×3 kernel removes salt-and-pepper noise and fills small holes inside grain footprints.
  4. Distance transform. A Euclidean distance map of the stone mask: every foreground pixel gets the distance to the nearest background pixel.
  5. Sure-foreground markers. Threshold the distance map at 45% of its peak; what remains is the centers of grains, even when their edges touch their neighbors'. Background markers come from a 3-iteration dilation of the cleaned mask.
  6. Watershed. OpenCV's marker-based watershed treats each marker as a basin and grows them outward until they collide. The collision lines are the grain boundaries.
  7. b-axis from minimum-area bounding rectangle. For each segmented grain, fit the smallest rectangle that contains its contour; the shorter side of that rectangle is the b-axis. This matches the convention used in mechanical sieving (a particle passes a square-mesh sieve when its b-axis < mesh opening).
  8. Area-weighted percentiles. Sort grains by b-axis; accumulate area; report the b-axis at which cumulative area reaches each target percentile. Equivalent to a mass-percentile sieve curve under the assumption of constant density.

Wentworth scale — full reference

The Wentworth (1922) classification is the de-facto sediment size scale in geology, sedimentology, and gravel-bed hydraulics. Boundaries are at whole-φ values; each class spans one phi unit (factor of 2 in millimeters).

Wentworth grain-size classification
ClassSub-classd (mm)φ
ClayFine clay< 0.0020> 9
Coarse clay0.0020 – 0.00399 – 8
SiltFine silt0.0039 – 0.01568 – 6
Medium silt0.0156 – 0.03126 – 5
Coarse silt0.0312 – 0.06255 – 4
SandVery fine sand0.0625 – 0.1254 – 3
Fine sand0.125 – 0.2503 – 2
Medium sand0.250 – 0.5002 – 1
Coarse sand0.500 – 1.001 – 0
Very coarse sand1.00 – 2.000 – −1
Granule2.00 – 4.00−1 – −2
PebbleFine / medium pebble4.00 – 16.0−2 – −4
Coarse / very coarse pebble16.0 – 64.0−4 – −6
Cobble64 – 256−6 – −8
Boulder> 256< −8

Source: Wentworth, C.K. (1922). "A scale of grade and class terms for clastic sediments." Journal of Geology 30(5): 377–392.

Folk-Ward sorting — verbal scale

The inclusive graphic standard deviation σ_I summarizes the spread of the distribution. The ratio of φ₈₄−φ₁₆ (the central 68%) to φ₉₅−φ₅ (the central 90%) catches both the body and the tails. Note: in PE-Calc and most computational implementations, percentiles are stored by SIZE (D₁₆ < D₈₄), so the equivalent expression is σ_I = (φ_{D16} − φ_{D84})/4 + (φ_{D5} − φ_{D95})/6.6 — both forms give the same positive value.

Folk-Ward verbal sorting classification
σ_I (φ)Verbal descriptionTypical environment
< 0.35Very well sortedBeach swash zone, eolian dune crest
0.35 – 0.50Well sortedMature beach, well-developed eolian sand
0.50 – 0.71Moderately well sortedForeshore, lower-energy eolian
0.71 – 1.00Moderately sortedFluvial sands, mixed-energy beach
1.00 – 2.00Poorly sortedGravel-bed rivers, fluvioglacial
2.00 – 4.00Very poorly sortedGlacial till, debris flow, alluvial fan
> 4.00Extremely poorly sortedMass-flow / colluvial deposits

Source: Folk, R.L., & Ward, W.C. (1957). "Brazos River bar: a study in the significance of grain size parameters." Journal of Sedimentary Petrology 27(1): 3–26.

Worked examples

Example 1 — Riprap D₅₀ check from a constructed slope

Given: Constructed riprap blanket on a 3:1 slope; specification calls for FHWA HEC-23 Class 2 stone with D₅₀ = 6 in. (152 mm). Photograph the as-built blanket from directly overhead with a 12-in. ruler in frame.
Find: Whether D₅₀ meets specification.
Calibration: tap the 0-in and 12-in marks on the ruler → 304.8 mm reference.
Run analysis — read D₅₀ off the stat grid.
Acceptance: D₅₀ ≥ 0.85·spec (HEC-23 Section 5.3 tolerance) → 0.85·152 = 129 mm minimum. The photo-sieve D₅₀ should also be cross-checked against the area-weighted mean and the D₉₀ to confirm the gradation is not undersized at the coarse end.
Use a single overhead photo to flag a low D₅₀ before the contractor demobilizes — much cheaper than a bucket-test re-mobilization.

Example 2 — Bedload competence in a gravel-bed stream

Given: Gravel-bed reach, low-flow channel exposed for survey. Walk a 100 m reach and shoot 8 photographs of representative bar surfaces with a US quarter (24.26 mm) for scale.
Find: Surface D₈₄ for use in Manning's n estimation (Limerinos 1970) and incipient-motion calculations (Shields).
Process each photo — record D₅₀, D₈₄, σ_I.
Combine across the 8 photographs (length-weighted average is appropriate when photos are equally spaced).
Limerinos n: n = 0.0926·R1/6 / (1.16 + 2.0·log₁₀(R/D₈₄)). For a wide channel with R ≈ 1.0 m and D₈₄ ≈ 80 mm: n ≈ 0.038.
Shields critical shear: τ*c ≈ 0.045 (for D₅₀ in the gravel range); critical shear stress τc = 0.045·(ρ_s − ρ)·g·D₅₀. For D₅₀ = 50 mm: τc ≈ 36.5 Pa.
Photo-sieving is faster than pebble-counting (Wolman) and yields a fully digital record for QA/QC. For Wolman-grid equivalence, sample at random pixel locations and report the unweighted (count-weighted, not area-weighted) percentiles.

When NOT to use this tool

Privacy & security

This tool is engineered around a single principle: your photo never leaves your device. The image is decoded into an HTMLCanvas in your browser, processed by OpenCV.js (a WebAssembly build of OpenCV running in your browser's sandbox), and the results are rendered back into the same page. There is no upload endpoint to compromise, no cloud queue holding your photos, no cookie tying analyses to a user. You can verify by opening DevTools → Network and running an analysis: zero outbound bytes from the photograph.

Other hardening: file inputs are MIME-restricted to JPEG/PNG/WebP, file size capped at 10 MB, and the browser canvas decode strips EXIF metadata as a side effect of redrawing pixels. Every tool page on PE-Calc serves a strict Content-Security-Policy meta header so injected scripts and exfiltration channels are blocked at the browser level.

Apps for offline field use in development

Native iOS and Android apps with offline OpenCV are in development for high-throughput field surveys (sealed-bid quantity verification, post-storm bed armor surveys, Wolman-grid-equivalent reach inventories). Sign up to be notified at launch, or follow these store placeholders:

Primary references: Graham, D.J., Reid, I., & Rice, S.P. (2005). "Automated sizing of coarse-grained sediments: image-processing procedures." Mathematical Geology 37(1): 1–28. · Detert, M., & Weitbrecht, V. (2012). "Automatic object detection to analyze the geometry of gravel grains — a free stand-alone tool." River Flow 2012: 595–600. · Wentworth, C.K. (1922). "A scale of grade and class terms for clastic sediments." Journal of Geology 30(5): 377–392. · Folk, R.L., & Ward, W.C. (1957). "Brazos River bar: a study in the significance of grain size parameters." J. Sedimentary Petrology 27(1): 3–26.

Related tools

Monthly engineering case studies

One real stormwater or hydraulics design problem per month, with the math worked out and the gotchas called out. No tutorials, no fluff.

Free. Unsubscribe anytime. Privacy.

Engineer of Record — Stamp & Signature
APPLY PE STAMP HERE
Engineer Name
License No.
State
Signature
Date
Project / Sheet
By stamping and signing, the Engineer of Record certifies that the inputs, formulas, and applicability of this calculation have been reviewed for the specific design context. PE-Calc tools provide computational support only — the engineer is responsible for verifying results, applying engineering judgment, and complying with applicable codes and standards. Photo-sieving samples only the visible armor layer and is subject to the limitations documented in Graham et al. (2005).
Calculation generated at pe-calc.com