On-premise computer-vision grading & sizing for corn flakes
Prepared for Sri Bhagyalakshmi Agro Foods by Svayou
Your 19 Oct sample — every flake detected, measured and gradedToday a batch is accepted or rejected on a manual, subjective judgement. FlakeGrade replaces the human estimate with measurement — every flake, every time.
Each individual flake is assigned a grade from your master standard — no sampling by eye.
Length, width and equivalent diameter for every flake, from a calibrated camera.
Batch grade mix vs your master, run through your rule — with a full per-flake audit trail.
| Grade | Definition | Target |
|---|---|---|
| Pure | Well-formed, uniform golden flake | 61.1% |
| Joint | Two or more flakes fused | 11.9% |
| Small | Undersized flake | 11.0% |
| Unpolished | Dull / incompletely polished surface | 5.5% |
| Hard | Over-processed, deep-coloured | 5.4% |
| Embryo | Pale germ tissue attached | 3.1% |
| Broken | Fragmented / broken piece | 2.0% |
Pure
Joint
Small
Unpolished
Hard
Embryo
| Grade | Sample | Master |
|---|---|---|
| Pure | 68.0% | 61.1% |
| Joint | 5.2% | 11.9% |
| Small | 9.7% | 11.0% |
| Unpolished | 7.9% | 5.5% |
| Hard | 8.5% | 5.4% |
| Embryo | 0.2% | 3.1% |
| Broken | 0.6% | 2.0% |
From a 1280×720 phone photo with no reference object. Full interactive report with every flake's measurements: flakegrade-bhagyalakshmi.pages.dev/report
The imaging, geometry, colour science, statistics and edge-deployment engineering behind every number in the report.
Each frame flows through deterministic, versioned stages. Every intermediate result is inspectable — nothing is a black box.
Fixed-geometry camera, diffuse LED, locked exposure & white balance
Lens undistortion, flat-field, colour card, mm-per-pixel scale
sRGB → linear → CIE XYZ (D65) → CIELAB / LCh
LCh gating, morphology, chroma-aware hole filling
Distance transform, seed detection, geodesic split
~20-dimensional geometric + colorimetric descriptor per flake
Rule cascade + trained model, batch-relative
Proportions, confidence intervals, accept / reject
With the camera fixed square above the tray, scale is constant across the field:
mm/px = Wref / wpx · e.g. 50 mm marker / 148 px = 0.338 mm/pxCoefficients estimated once at install from a checkerboard (Zhang's method), then every frame is undistorted so edge flakes measure as accurately as centre flakes.
A dark frame D and a flat white frame F remove lighting fall-off and vignetting — essential for colour grades like Hard and Unpolished.
A reference colour card in frame fixes white balance and exposure per session, so a "deep-coloured" flake means the same thing on every shift, under any factory lighting.
POC today: scale assumed from the sheet width (A1, 841 mm → 0.674 mm/px on the 1280-px photo).
RGB is device-dependent and perceptually uneven. Every pixel is converted to CIELAB, where equal numeric distances are equal visible differences.
sRGB → linear: c = ((c′ + 0.055) / 1.055)2.4 linear → XYZ: [X Y Z]ᵀ = MD65 · [R G B]ᵀ L* = 116 f(Y/Yₙ) − 16 a* = 500[f(X/Xₙ) − f(Y/Yₙ)] b* = 200[…] Chroma C* = √(a*² + b*²) Hue h = atan2(b*, a*)
1Input region (sRGB)
2Computed chroma field C* — flakes glow, sheet goes darkThe sample surface is found as the largest low-saturation connected component; morphological closing and hole-filling define the tray. Hands, table and labels outside it are excluded.
Followed by morphological opening (3×3, 2 iterations) to cut thin bridges between touching flakes.
Interior holes are filled only if small and cream-coloured (C* > 11 — germ tissue). White gaps enclosed by a ring of flakes stay open, so empty space is never counted as a fused "joint".
2Chroma field
3Binary flake mask M(x)The hardest problem in flake counting: piles touch. A connected blob may contain several flakes. We split them geometrically.
 = robust single-flake area (45th percentile); low solidity reveals the "waist" where two flakes meet.
Each flake body becomes a peak; necks become valleys. Local maxima with D > 0.42·r̂ become seeds.
Seeds grow simultaneously inside the blob until they meet, partitioning it along the necks — every pixel assigned, none lost.
3Mask
4Distance transform + seeds
5Instance labels
6Graded output
Flake #456 · — max Feret · — min Feret · — convex hull| Descriptor | Definition | #456 |
|---|---|---|
| Length | max Feret (rotating calipers on hull) | 21.8 mm |
| Width | min Feret over hull edges | 10.4 mm |
| Eq. diameter | √(4A / π) | 14.8 mm |
| Area | pixel count × (mm/px)² | 170.9 mm² |
| Solidity | A / Ahull | 1.00 |
| Circularity | 4πA / P² (Crofton perimeter) | 0.77 |
| Aspect ratio | Feretmax / Feretmin | 2.10 |
Solidity flags fused pairs and ragged fragments; circularity separates broken pieces from whole flakes; Feret length drives the Small grade and is printed on each flake.
| Feature | Computed over flake interior Ω | #456 |
|---|---|---|
| Lightness | μ(L*) | 59.1 |
| a*, b* | μ(a*), μ(b*) | 9.0, 60.4 |
| Chroma / hue | μ(C*), atan2(b*, a*) | 61.3 · 81.5° |
| Surface roughness | σ(L*) over Ω ⊖ B₂ | 4.65 |
| Germ fraction | P(L* > L̃+10 ∧ C* < 0.72C̃) | 0.7% |
| Dark fraction | P(L* < L̃ − 14) | 0.6% |
Ω ⊖ B₂ = interior eroded by 2 px, so edge halos don't pollute colour statistics. L̃, C̃ = batch medians.
Factory light shifts absolute colour. So every colour feature is scored against the batch itself with a robust z-score:
z = (x − median(x)) / (1.4826 · MAD(x))MAD — median absolute deviation — ignores outliers, so a handful of dark flakes can't drag the baseline.
"Hard" becomes z(L*) < −1.5: a flake markedly deeper than its own batch — stable across shifts, cameras and lighting.
Every threshold is a parameter in a versioned config — tunable per line.
Rules stay as guard-rails: the model can never call a 40 mm fused cluster "Small".
A grade share is an estimate from a sample. We report it with a Wilson score 95% interval — correct even for rare grades near 0%.
p̂ ± … = [p̂ + z²/2n ± z√(p̂(1−p̂)/n + z²/4n²)] / (1 + z²/n)| Grade (n = 660) | Estimate | 95% interval |
|---|---|---|
| Pure | 68.0% | 64.4 – 71.5% |
| Small | 9.7% | 7.7 – 12.2% |
| Hard | 8.5% | 6.6 – 10.9% |
| Unpolished | 7.9% | 6.1 – 10.2% |
| Joint | 5.2% | 3.7 – 7.1% |
To know Pure (≈61%) within ±3 points at 95% confidence: n ≈ 1,015 flakes → about two trays per batch. Within ±4 points: ≈ 571.
Lab grading is by weight. Per-grade mean flake mass (from your weigh-method calibration) converts count shares into weight shares.
Reject only when the interval — not just the point estimate — crosses your limit. Fewer false rejections of good batches.
The same image always returns the identical result — verified by repeat uploads. Results only change on a deliberate, versioned upgrade.
Every flake is logged: id, coordinates, length, width, solidity, circularity, L*a*b*, the rule that fired and the engine version — exportable as CSV / JSON for QA records.
Low-confidence flakes are queued for QA review → confirmed labels feed periodic retraining → each new model is validated against a held-out set and released as a new pipeline version, with drift monitoring on the grade mix.
The capture station, the honest state of play, and the path to production.
Fixed above the sample tray
FlakeGrade model & app
One-click Scan → report
Every report stored on site
| Component | Suggested specification | Indicative ₹ |
|---|---|---|
| Edge PC | Intel i5/i7, 16–32 GB RAM, 512 GB SSD, NVIDIA RTX 4060 (8 GB) — or Jetson Orin NX 16 GB | 85,000 |
| Camera | Industrial USB3 machine-vision camera, ~12 MP colour | 35,000 |
| Lens | Fixed focal-length C-mount, matched to working distance | 10,000 |
| Lighting | Diffused LED ring / bar rig, shadow-free | 12,000 |
| Stand | Adjustable overhead copy stand — fixed camera height | 10,000 |
| Touchscreen | 21–24″ (or an existing PC + monitor) | 16,000 |
| Tray, colour card & UPS | Matte uniform tray, reference colour/scale card, small UPS | 7,000 |
| Indicative total — procured directly by you | ~1,75,000 | |
Indicative retail estimates, not billed by Svayou. We confirm exact models before purchase, then install and calibrate the station.
None of these are dead-ends — they are capture and data steps that the on-site station resolves.
Engine, per-flake report and overlay — validated on your samples.
Station set up; lens, flat-field, colour and mm scale calibrated; QA labelling.
Colour-grade model trained on your labels; thresholds tuned to your rule.
On-site acceptance test against the weigh-method, staff training, go-live.
Later, optional: an in-line camera over the conveyor for continuous, real-time accept / reject — the same engine, applied to the moving belt.
e.g. reject if Pure < X% or Broken > Y%.
Your QA team confirms grades on a set of sample photos.
Physical weigh figures for a few batches, to calibrate count → weight.
Tray dimensions or a calibration marker for exact millimetres.
Where the station sits, and samples per shift.
Capture station to our spec — we install and calibrate.
FlakeGrade software — on-prem model, capture-station app, calibration & deployment
Capture-station hardware — procured directly by you (indicative)
Cloud hosting and per-scan fees — everything runs on site