Most food plants I visit keep a jar. It holds the foreign material the quality team has pulled out of product over the years: a fragment of blue glove, a twist of baling twine, a splinter of pallet wood, a shard of crate plastic, a stone, a piece of shell. Some of it was caught by X-ray. Much of it was found by a person, or by a customer, because it is no denser than the food around it.
Spectral imaging detects contamination by chemistry rather than density, so it finds a different set of contaminants from X-ray — not a better set. On the right product, the two together close a gap neither closes alone. This article covers what spectral imaging adds, how multispectral and hyperspectral systems differ, and the engineering decisions that determine whether one works on a line.
What spectral imaging adds to RGB and X-ray
Each detection technology responds to a different physical property, which is why each misses something.
| Technology | Detects by | Strong on | Weak on |
|---|---|---|---|
| Metal detector | Conductivity and magnetic properties | Ferrous and non-ferrous metal | Non-metals; stainless steel is harder |
| X-ray | Density and thickness | Metal, glass, stone, calcified bone, dense plastics | Most plastics, wood, paper, insects, plant material |
| Color (RGB) vision | Color and shape | Contaminants that contrast with product | Contaminants the same color as product |
| Spectral imaging | Chemical composition at the surface | Plastics, wood, paper, shell, stems on the surface | Anything buried; particles smaller than a few pixels |
A color camera records three broad bands, roughly as the eye does. A white plastic fragment on a chicken breast, or a wood chip among roasted almonds, can look almost identical in those three bands. At specific near-infrared wavelengths they do not. Water, fats, proteins, sugars, cellulose and the carbon-hydrogen bonds in plastics absorb light at characteristic wavelengths, so materials that look alike to the eye often have clearly different spectra.
The limit is physical. Spectral imaging sees the surface and, in the near-infrared, a few millimeters below it at most. A contaminant buried in a portion or sealed inside a pack is invisible to it. That is why it complements X-ray rather than replacing it.
Multispectral or hyperspectral?
A hyperspectral camera records a continuous spectrum at every pixel, typically in a hundred or more narrow bands. The result is a data cube with two spatial dimensions and one spectral. It is the right tool for discovering which wavelengths separate product from contaminant. It is also expensive, data-heavy and often slower than a line wants.
A multispectral system records a handful of selected bands. It is faster and cheaper, produces far less data and runs simpler models. Our Lensnode M, for example, captures eight bands from the visible to 1,000 nm.
The workflow that works uses both: hyperspectral in the lab to find the bands that matter, multispectral on the line to run them. Spectral range matters as much as band count. Silicon sensors cover the visible and near-infrared to about 1,000 nm. Many plastics and organic materials have stronger, more distinctive absorption features in the short-wave infrared, roughly 1,000–1,700 nm, which needs costlier InGaAs sensors. If the lab data says your separation needs short-wave infrared, a visible and near-infrared camera will not do, and we will tell you so; that becomes a custom optical sensor question.
Band selection
Band selection is where these projects are won or lost.
- Gather the right samples. Product from several lots, seasons and moisture levels; every contaminant from the jar, in the colors and thicknesses you actually see; and the confusers — acceptable features such as skins, stems or bruises that must not be rejected.
- Image them hyperspectrally under controlled light, and convert to reflectance (see calibration below).
- Look before you model. Plot mean spectra and their spread. Separation you can see on a plot tends to survive on a line; separation only a complex model can find tends not to.
- Select for robustness. Prefer bands on broad absorption features over knife-edge ones, and use ratios or differences between bands to cancel brightness changes from product height and angle.
- Validate on held-out lots, never on the lots you selected bands from.
Illumination
A spectral camera can only measure wavelengths present in its light. Tungsten-halogen lamps give a smooth spectrum well into the short-wave infrared, but run hot, drift as they age and need replacing. White LEDs emit very little beyond roughly 750 nm, so they are blind to most of the near-infrared. Arrays of LEDs at selected wavelengths are efficient, cool and easy to strobe, which suits multispectral systems, provided each band has its own source and the array is temperature-controlled — LED output and peak wavelength both shift with temperature.
Geometry matters as much as spectrum. Wet, oily or glossy product throws specular reflections that saturate pixels and erase spectral information. Angle line lights so the specular path misses the lens, and use diffuse illumination where product shape varies. Our article on lighting geometry covers the trade-offs.
Line-scan or snapshot?
| Line-scan (push-broom) | Snapshot (mosaic filter) | |
|---|---|---|
| How it works | A slit images one line across the belt, a grating or prism spreads it into a spectrum, and belt motion builds the image | A filter mosaic on the sensor captures every band in one frame |
| Spectral detail | High, often hundreds of bands | Limited, typically a few dozen bands or fewer |
| Spatial resolution | Full sensor width in every band | Reduced, shared among bands |
| Best for | Conveyors at steady speed, with encoder sync | Discrete objects, robotic handling, irregular motion |
On most food conveyors, line-scan is the natural fit: the product is already moving past the camera.
Throughput is arithmetic
Take a hypothetical bulk-product line: a belt 600 mm wide moving at 0.5 m/s, and a requirement to detect a 3 mm fragment. At about 1 mm per pixel, the fragment spans three pixels — the practical minimum. That means 600 pixels across the belt and 500 lines per second, with no more than 2 ms of exposure per line.
At 200 bands and 2 bytes per value, that is 120 MB/s of raw data. At eight bands, it is 4.8 MB/s. Double the belt speed and the line rate doubles, the exposure time halves, and narrow bands start to run short of light. That is why deployed systems usually run a few selected bands, and why illumination power is a design parameter rather than an afterthought.
Presentation sets a ceiling too. The camera sees only the top surface, and a contaminant under a layer of product is out of view. Spreading product into a monolayer, or viewing both sides as it falls from the end of the belt, often does more for detection than a better camera.
Calibration: white and dark references
Raw camera counts depend on the light, the lens and the sensor as much as on the product. Converting them to reflectance makes measurements comparable over time:
reflectance = (raw − dark) / (white − dark)
The dark reference is captured with no light reaching the sensor and records its offset, which drifts with temperature. The white reference is a stable, diffuse, high-reflectance target imaged across the full belt width, because illumination is never perfectly even from edge to edge. Capture both at start-up and on a schedule, and automate where you can — a reference strip at the belt edge seen on every line, or a target that swings into view between batches. Trend the white-reference signal: a slow decline means an aging lamp or a dirty window. And keep the reference clean, because contamination on it shifts every reflectance value calculated from it.
Building a spectral library
A spectral library is a labeled set of spectra for product and contaminant classes. Collect it on the production rig, not only in the lab, because light and geometry differ. Include the states you meet in practice: wet and dry, frozen and thawed, fresh and weathered wood, every color of glove and crate plastic in the building.
Start with interpretable classifiers — band ratios, linear discriminants — and move to small neural networks only when they earn their place. Add an anomaly model that flags anything that is not product, so contaminants missing from the library are not silently passed; see anomaly detection vs supervised classification. Classify per pixel, then require a minimum cluster of adjacent contaminant pixels before rejecting, to suppress false rejects from noise.
Ejection is half the system
Detection is worthless if the contaminant stays in the product. Bulk lines usually use a bank of air jets across the belt or at the belt end; packaged or larger items use diverters or pushers. The controller tracks each detection from the scan line to the ejector by encoder, allowing for valve response time and for light pieces flying differently from heavy ones. Every ejection takes some good product with it, so measure good-product loss per ejection and tune the jet window. Then verify: audit the reject stream regularly, and make sure an ejector fault raises an alarm rather than failing silently. Our article on encoders, handshakes and reject gates covers the timing.
If you have a jar of your own, it is the best place to start. A Feasibility Sprint images your product and contaminants in our optics lab and shows which bands separate them before anyone buys a camera. For production systems, see continuous thermal and multispectral monitoring and our work in food and beverage.