A measured spectrum is a curve with thousands of data points, which is awkward to store, compare and verify on a production line. The practical fix is to compress that curve into a short string of characters: extract the peak positions, round each one into a numbered band, and map the bands to characters. The result behaves like a fingerprint identifier that a plant database can look up, that a verification reader can check, and that two sites can compare without exchanging raw files. This article explains each step of that pipeline, the design choices that determine how reliable it is, and where the approach breaks down.
Why compress a spectrum at all
Raw spectra are bulky and slow to compare. A typical measurement carries hundreds to thousands of samples, and a database match means correlating every new curve against every reference curve. That is fine for a few hundred references, but it does not scale to a busy line, and it ties every verification to one piece of software with access to the full library.
A symbolic identifier changes the picture. Once a spectrum maps to, say, a 16-character string, the lookup becomes an exact string comparison, the identifier can travel with the part in a database or on a label, and any system that knows the same mapping rules can verify it independently. It also makes the identification auditable: an operator can read the string and see which bands matched.
The cost is resolution. The full curve distinguishes materials that a compressed code may not, so the design work lies in choosing bands that keep the distinctions you actually need. For an introduction to why different materials produce different spectra in the first place, see the article on hyperspectral imaging and how it compares with RGB and filters.
The pipeline in four steps
The conversion from spectrum to identifier follows the same shape whether the source is Raman, infrared or hyperspectral reflectance:
- Preprocess. Remove baseline drift and cosmic-ray or detector artifacts, smooth lightly, and normalise intensity. Peak positions must not depend on brightness, so intensity normalisation is about stability, not appearance.
- Extract peaks. Find local maxima above a signal-to-noise threshold, and record each peak's centre position, not its height. Position is the stable property; intensity varies with focus, surface and illumination.
- Quantise into bands. Divide the measured range into equal or feature-spaced bands, and replace each peak position with its band number. This absorbs small calibration differences between instruments.
- Map to characters. Convert the sequence of band numbers into a string, using a fixed format: a prefix for the method, then the band numbers separated by a delimiter or encoded directly.
A simple convention uses band numbers joined by a separator. With 50 bands across the range, a material with peaks in bands 12, 19 and 24 might encode as S01-012-019-024. Three characters per peak keeps the string readable and makes a partial match visible to a human at a glance.
Choosing the band layout
The band width is the single most important choice. Make the bands too narrow and the same material encodes differently on two instruments, or even after a lamp change. Make them too wide and two distinct materials collapse into the same code.
A workable rule of thumb:
- Set the minimum band width at two to three times the worst-case instrument-to-instrument peak position spread, measured empirically on identical samples.
- Within that floor, prefer feature-spaced bands: place boundaries between known peak clusters in your reference set, so that small shifts never straddle a boundary.
- Reserve one or two bands as coarse position markers so that a wildly wrong spectrum cannot accidentally produce a plausible substring.
Validate the layout before committing to it: measure every reference material at least ten times across the real range of instrument and environmental conditions, encode each measurement, and confirm that every material always yields the same string. If any measurement disagrees, widen the offending band or move its boundary.
A worked example
Suppose a Raman measurement covers 400 to 1800 cm-1, and your instrument-to-instrument tests show peak positions repeat within about 8 cm-1. You choose 25 cm-1 bands, which gives:
A material with peaks at 517, 989 and 1324 cm-1 encodes as follows:
- Peak 517: floor((517 - 400) / 25) + 1 = floor(4.68) + 1 = band 5, written
005 - Peak 989: floor((989 - 400) / 25) + 1 = floor(23.56) + 1 = band 24, written
024 - Peak 1324: floor((1324 - 400) / 25) + 1 = floor(36.96) + 1 = band 37, written
037
The full identifier is S01-005-024-037. A duplicate measurement that lands the first peak at 522 cm-1 still falls in band 5, so the string is stable. Note the near-miss risk: a peak at 1324 cm-1 sits only 1 cm-1 from the band 37/38 boundary, so the validation step from the previous section is not optional. If reference measurements straddle that boundary, shift it to 1330 cm-1.
Capturing the spectrum on the line
For identity checks in production, the measurement hardware depends on how much spatial information you need alongside the identity.
A point measurement answers one question at one spot. If the part is always presented the same way and the material is uniform, this is the simplest path and needs the least data handling.
When identity and location must be answered together, an area scan hyperspectral camera measures a full spectrum in every pixel, so the software can both identify each material and report where it is on the part. The hyperspectral cameras in the shop cover this case; a model such as the LS-HSC-0004 spans 400-1000 nm with 1200 bands over USB3, which is more than enough bands for the extraction pipeline above.
- Interface
- USB3
- Resolution
- 5 MP
- Lens mount
- C-mount
Illumination matters as much as the sensor. Spectral contrast lives in narrow wavelength features, so a broadband, stable source and a light scheme that avoids saturation and glare are prerequisites. If you are sequencing several wavelength regions in one inspection, the article on sequencing colours from a multi-wavelength light shows how to get more out of a single exposure window, and the piece on which LED colour gives the best contrast covers the contrast logic behind colour choice. The special lights category includes broadband and segmented sources built for exactly these set-ups, and the lighting finder lets you filter by wavelength and size. For a build from scratch, start at the lighting step of the configurator.
Verifying the identifier downstream
Once the spectrum has become a string, standard verification tooling applies. Two patterns are common:
- Database verification. The inspection software encodes the spectrum and compares the string with the expected identifier for the part recipe. This is pure string comparison and runs in microseconds.
- Independent verification. The identifier is rendered or attached to the part data, and a separate reader confirms it, closing the loop between measurement and record.
For the second pattern, a fixed industrial reader reads and validates the string on the line. The fixed code readers category includes models aimed at reading generated codes under plant lighting; for example, the LS-CRD-0028 reads at 30 fps with 60 codes/s throughput and an 8 mm lens, and the compact LS-CRD-0047 works at a 60-120 mm reading distance over USB.
- Interface
- Fast Ethernet
- Resolution
- 5 MP
- Resolution
- Up to 3 MP
- Shutter
- Global
When a generated code refuses to read, the usual causes are the same as for any symbology: contrast, blur and glare. The article on preprocessing 1D barcodes for rotation, blur and glare covers the image-side fixes, and the decoding pipeline from pixels to validated data is described in camera barcode decoding.
Where this approach fails
A compressed identifier is a lossy summary, and four failure modes recur:
- Similar materials collapse. Two grades of the same polymer can differ by one weak peak. If that peak sits inside a band you did not model, the codes match and the check passes wrongly. Keep every discriminating peak in its own band, even if it makes the string longer.
- Mixtures. A blend produces a superposition of peaks. Decide explicitly whether a mixture is a valid entry in your library or always a fail; leaving it undefined produces inconsistent results.
- Calibration drift. A shifting wavelength axis moves peaks across band boundaries over weeks. Re-validate the encoding periodically against reference samples, not just at commissioning.
- Intensity illusions. If any part of the encoding uses peak heights, surface finish and focus will change the identifier. Encode positions only.
If material differences are subtler than a band layout can express, a spectral fingerprint identifier is the wrong tool and full spectral matching is the right one. The two can coexist: use the fast string check first and fall back to full correlation only on ambiguity.
Checks before you build it
- Measure every reference material at least ten times under real conditions; each must always encode to the same string.
- Confirm band boundaries do not split any reference peak cluster; move boundaries that do.
- Test the identifier with a second instrument if parts will be inspected at more than one station.
- Decide and document the treatment of mixtures and unknown spectra.
- Agree the string format, including method prefix and delimiters, before any label or database schema is written.
A short checklist for the first deployment
- [ ] Baseline-corrected, normalised spectra from every reference material
- [ ] Peak list with positions and signal-to-noise values, not just peak picks
- [ ] Band layout with widths justified by measured instrument spread
- [ ] Ten-measurement stability test passed for every material
- [ ] Identifier format documented and agreed with the database owner
- [ ] Verification path defined: database string match, or reader-based check
- [ ] Scheduled re-validation against reference samples
If you are planning a spectral inspection station and want help sizing the camera, lighting and verification hardware together, use the system configurator or contact us through the contact page; with every order you get free expert support, and approved businesses can apply for Net 30 terms. You can also browse cameras and lenses directly.
Questions
Can a measured spectrum be stored in a 2D code?
Yes, but not the full curve. A spectrum with thousands of samples is first reduced to a few dozen peak positions, and those positions are quantised into bands and mapped to characters. The resulting string, typically 10 to 40 characters, can be encoded in any standard 2D symbology and verified against a reference library. The trade-off is resolution: two materials that differ only slightly in peak position may map to the same code.
How many peak positions do I need for a reliable identifier?
Three to eight well-separated peaks are usually enough to distinguish a known set of materials. More peaks give a longer code and better discrimination between similar materials, but each peak adds sensitivity to measurement noise and to small wavelength calibration differences between instruments. Validate the mapping across several measurements per material before committing to a band layout.
Should I print the code or only store it in the database?
In most production setups the spectral match is computed in software and the result is a pass or fail flag in the database, so nothing needs to be printed. Printing or rendering the code makes sense when a separate device must verify the identification independently, for example a handheld or fixed reader checking that the label matches the measured material.
Why does the same material give different peak positions on two instruments?
Wavelength calibration, optical resolution and sampling differences shift measured peaks by a few wavenumbers or nanometres between instruments. This is why the band quantisation step exists: bands wider than the expected instrument-to-instrument spread make the mapped code stable across devices. Calibrate each instrument against a reference standard and verify that identical samples map to identical strings on all of them.
Do I need a hyperspectral camera or a dedicated spectrometer?
It depends on the task. A point or probe spectrometer measures one spot with high spectral detail and suits lab identification. A hyperspectral camera such as an area scan model covering 400-1000 nm captures a full spectrum per pixel, so it can also locate where on the part each material sits. If the goal is only identity verification at a fixed inspection point, fewer bands and simpler optics may suffice.


