NIR hyperspectral imaging for detection of nut contamination

Posted: 1 September 2015 | | No comments yet

‘Nut’ is used to describe a wide range of seeds with a seed coat or shell. Because of high-energy content, micronutrients and positive global health impact, nuts have been present for centuries in human diet. However, over recent decades they have increasingly been found to induce adverse health effects. With an increasing number of individuals affected with allergenic reactions, nuts allergies are a growing global concern. Nuts are common food allergens and are the leading cause of fatalities from food-induced allergenic reactions in developed countries. Allergenic conditions arising from the consumption of nuts are generally thought to be life-long and typically severe. No definite treatment is yet available for nut and seed allergies. Dietary avoidance is the primary way to manage these allergies and requires the ability in the food industry to identify peanuts or tree nuts.

NIR hyperspectral imaging for detection of nut contamination

Manufacturing and labelling errors and label misinterpretation can contribute to the risk of inadvertent exposure. To protect allergic consumers, European Directive 2003/89/EC and Regulation (EU) No. 1169/2011, makes the labelling of all ingredients mandatory, especially food allergens used in the recipes of packaged foods. However, manufacturing industries dealing with the processing of multiple powder food products present risk for contamination. Such cross contamination might result in unintentional ingestion of nuts by the sensitised population. Thus, need for an in-line system to detect nut traces at the early stages of food manufacturing is of crucial importance.

In recent years, hyperspectral imaging (HSI) has emerged as a promising tool for monitoring the quality and safety of various food commodities on the basis of surface colour, texture and chemical composition. The ability of HSI to integrate the information of spectroscopy and imaging and to simultaneously acquire spectral and spatial information in a single system has made it a suitable choice for dealing with complex issues associated with evaluating individual food items.

In the present work, a feasibility study regarding the potential of HSI combined with chemometric analysis for implementing in-line to different food manufacturing processes for identifying foreign food materials was performed. The objective was to use HSI for the detection of different nuts traces in wheat flour to assess if the HSI system can be used in a multi-food processing industrial environment.

Materials and methods

Seven sets of samples were measured; four of pure products (wheat flour, peanuts, hazelnuts and walnuts) and three mixes of 0.01% trace levels of peanut in flour, hazelnut in flour and walnut in flour separately. Mixing was performed manually. An aluminum platform with surface area of 95cm2 was used for performing the sample presentation for image acquisition.

The images were acquired with a line-scan push broom hyperspectral imaging system (HySpex SWIR-320m-e by Norsk Elektro Optikk, Lørenskog, Norway). The hyperspectral camera covers the spectral range from 1000 to 2500nm with 320 pixels over the cross-track field of view (FOV). Samples were placed successively on the translation stage to be scanned line by line by the imaging sensors.

Pre-processing of spectroscopic data sets with SAVGOL (Savitsky Golay) followed by SNV (Standard Normal Variate) was performed to reduce effects of baseline shift and variations in global signal intensity. A principal-component analysis (PCA) was carried out on a dataset of pure nuts and flour absorbance spectra (1000–2200nm). PCA loadings were applied to each of the adulterated images with different nuts to obtain the final score images. Score images resulting from the PCA loading application were the threshold according to the image histogram. As a result, a binary classification image was obtained with a clear detection of the nuts. All data analysis was performed with Matlab R2010a (MathWorks, Natick, MA).


Figure 1 shows the mean NIR spectra of pure nuts and flour after preprocessing. Preprocessing of the data allowed clearer identification of different peaks in the spectra. The small particle size of flour (100-212μm) led to a very high degree of light scattering and, consequently, a low level of absorbance. The larger particle size of peanut particles (500–1000μm) led to higher absorbance levels.

Absorbance peaks at 1200nm and 1734nm in the nuts spectra can be related to the presence of long-chain fatty acids, which give rise to a CH2 second overtone at 1200nm and CH2 first overtone at 1734nm. On the wheat flour spectra, two main peaks, related to OH bonds, are observed: at 1450nm and 1940nm. In this case, absorbance at 1450nm is due to the first overtone of OH stretch and at 1940nm to the combination of OH stretch and OH bend4. These peaks were later retrieved in the PCA loadings.

PC loadings, explaining the difference between products (wheat flour and peanut), are represented in Figure 2. According to the PC score plot (Figure 3), positive loading peaks correspond to wavelengths with higher absorbance values for nuts than for flour. The following peaks can be assigned to chemical structures4. Three positive peaks at 1200nm, 1395nm and 1734nm in Figure 2a, are related to CH2 bonds. They are caused by a C–H stretch second overtone, a combination (2 × C–H stretches + C–H deformation) and C–H stretch first overtone, respectively4.

These absorbance bands reflect the higher presence of long-chain fatty acids in peanut regarding wheat flour. A fourth positive peak in Figure 2b appears at 2030nm and this is caused by the C=O stretching second overtone related to amide function. In turn, two main negative peaks appear at 1450nm and 1940nm in Figure 2a and Figure 2b respectively4. They are caused by O–H bond stretch first overtone and the combination of O–H stretch and O–H deformation respectively4. The former is related to starch and water; the latter to water only. This latter peak opposes the hydrophilic and hydrophobic behaviour of flour and nuts, respectively. Another, smaller negative peak, appearing at 1580nm in Figure 2a, is caused by the O–H stretch first overtone and related to starch4. Finally, a clear negative peak appears at 2100nm. This is caused by the combination (2 × O–H deformation + 2 × C–O stretch) and is related to starch4.

PCA presented 97.18% of the variance explained by the two main PC, 83.54% on the first PC (PC1) and 13.64% on the second (PC2). As shown in Figure 4, while PC1 allows clear differentiation between nuts and flour, the PC2 allowed the segregation of peanut from hazelnut and walnut. PC2 also explains variability within products. A wider variability can be observed on nuts scores when compared with flour scores and this could be explained by the larger particle size of nuts samples, which could affect the spectral signal by shadowing or scattering effects.

Figure 4 represents the score and classification images obtained from the application of first PC for different nuts at 0.01% traces in flour. The images in grey scale are the score images where as the binary images are the classification images obtained after setting the threshold for score images. It should be noted that the trace level used in this work was 0.01%. This trace level was decided on the basis of our previous work5 because the same technical conditions for imaging and sample presentation were used. However, with a higher resolution camera and larger sample representation area this limit can go further down. This is what we are now working on.


This investigation was performed to study the feasibility of NIR HSI for detection of nuts traces contamination in wheat flour. The images were processed with PCA and the obtained results show a clear detection of nuts at trace level of 0.01% in flour.

HSI due to its high cost and complexity has limited application to the industry. However, further studies could help to design a multispectral system with specific spectral ranges for detecting nut traces. This approach would allow a transition from HSI to multispectral imaging systems, which will help in quality control on food product processing lines and work in conjunction with different protein detection analytical methods such as Real Time Polymerized Chain Reaction (RT-PCR) and Enzyme Linked Immune Sorbent Assay (ELISA).


  1. L. Hostetler, S.G. Hostetler, G. Phillips and B.L. Martin, “The ability of adults and children to visually identify peanuts and tree nuts”, Ann. Allerg. Asthma Immunol. 108(1), 25–29 (2012). doi: anai.2011.09.012
  2. Yu, J. W., Kagan, R., Verreault, N., Nicolas, N., Joseph, L., St. Pierre, Y., & Clarke, A. (2006). Accidental ingestions in children with peanut allergy. Journal of Allergy and Clinical Immunology, 118(2), 466–472. doi:
  3. Wu, D., & Sun, D.-W. (2013). Advanced applications of hyperspectral imaging technology for food quality and safety analysis and assessment: A review — Part I: Fundamentals. Innovative Food Science & Emerging Technologies, 19(0), 1–14. doi:
  4. Osborne, T. Fearn and P.H. Hindle, Practical NIR Spectroscopy with Applications in Food and Beverage Analysis. Longman Scientific and Technical, Harlow, UK (1993).
  5. Mishra, P., Herrero-Langreo, A., Barreiro, P., Roger, J., Diezma, B., Gorretta, N., & Lleó, L. (2015). Detection and quantification of peanut traces in wheat flour by near infrared hyperspectral imaging spectroscopy using principal-component analysis. Journal of Near Infrared Spectroscopy, 23(1), 15–22. doi:10.1255/jnirs.1141 

About the authors

Puneet Mishra completed his masters in agro-engineering in June 2015 from Universidad Politecnica de Madrid (UPM), Spain, with a scholarship from European Commission. During his masters he was also working as research assistant to Lab for Physical Properties of Food (LPF-TAGRALIA) in UPM. He was visiting student to IRSTEA in Montpellier, AgroParisTech in Paris and King Abdullah University (KAUST) in Saudi Arabia during his master studies. His research interest included statistics, spectroscopy, artificial vision and non-destructive analysis of food.

Belén Diezma obtained her PhD in Agro-Engineering from Universidad Politecnica de Madrid. Since 2007, she has been associate professor in Department of Rural Engineering, Universidad Politecnica de Madrid. She is also director of the research group Lab for Physical Properties of Food (LPF-TAGRALIA). Her research interest includes application of optical and acoustic technology for safety and quality of food in industries (Multispectral-hyperspectral imaging, spectroscopy, UV/VIS/NIR).

Pilar Barreiro obtained her PhD in Agro-Engineering from Universidad Politecnica de Madrid. Since 2010, she has been professor in Department of Rural Engineering, Universidad Politecnica de Madrid. Her research interest includes application of monitoring technologies for agricultural products (artificial vision systems, spectroscopy, chemometrics), applied electronics and instrumentation for agriculture and advanced data modelling and analysis.

Send this to a friend