Spectroscopy Since 1975
Metrohm Advertisement

Near infrared hyperspectral imaging for foreign body detection and identification in food processing

1 December 2013 | Article
Published in Spectroscopy Europe/World Vol. 

Aoife A. Gowen* and Colm P. O’Donnell

College of Engineering and Architecture, Belfield, Dublin 4, Ireland. E-mail: [email protected]


Hyperspectral imaging (HSI) combines imaging and spectroscopy for enhanced non-destructive analysis of materials. When combined with chemometric (i.e. multivariate) analysis, HSI can be applied for prediction of the concentration and distribution of multiple components in a sample. This makes the technique attractive for many routine quality inspections within the food industry.1 One potentially useful application of HSI is foreign body detection in food processes.

Foreign body contamination is recognised as one of the most common reasons for food product recalls. Consequently, in order to comply with requirements for product safety and maintain consumer confidence, there is a need for rapid, non-destructive techniques for foreign body detection and identification in products of the food industry. Glass, metal and plastic are the most frequently cited foreign bodies in processed foods. Metal detectors are commonly implemented in food processing chains to prevent metal fragments occurring in finished products; however, these instruments are not capable of detecting glass and plastic contamination.

In this article, chemometric analysis of hyperspectral imaging data for identification and classification of foreign bodies in grains is presented. Hyperspectral images were obtained using a pushbroom line-scanning HSI instrument (DV Optics Ltd, Padua, Italy) operating in diffuse reflection mode in the near-infrared (950–1700 nm) wavelength range.2 The foreign bodies investigated were: plastic shards, glass beads and rubber fragments. Two types of grain samples were examined: a relatively uniform sample of white rice grains and a mixed variety grain sample (containing a variety of dehydrated grain legumes).

Hyperspectral imaging for contaminant detection in grain samples

The mean and standard deviation reflectance spectra of each contaminant show the differing optical properties of the contaminants studied [see Figures1(a)–(c)]. The glass samples exhibited a very low spectral response, indicating the low levels of light reflected from these samples. The plastic and rubber samples exhibited characteristic absorbance of near infrared (NIR) radiation at specific wavelengths. Although the contaminants are quite distinct from each other in spectral character, there was some overlap in the spectral response of the food samples studied with those of the contaminants; therefore, identification of contaminants using single band images was not appropriate.

One major advantage of HSI over other methods of foreign body detection is the ability to detect, as well as classify, foreign bodies according to their spectral properties. Principal components analysis (PCA) can be applied to hyperspectral images to compress them into linear combinations of the individual wavelength images (“scores”), resulting in maximal variance projection. As such, PCA is a useful tool for identifying underlying patterns in HSI data. In order to demonstrate this, PCA was applied to the images of grain samples containing the foreign bodies.

Variability in the spectral response of the mixed grain sample caused significant variability in the PC scores images when no spectral pre-treatment was applied, making identification of foreign bodies difficult. Thus, in order to highlight differences between the grain samples and foreign body contaminants in PC score space, various spectral pre-treatments were applied to the diffuse reflection spectra. It was found that a combination of first derivative Savitsky–Golay smoothing followed by standard normal variate pre-processing resulted in the best separation of the various foreign bodies in PC scores space. Due to the application of the aforementioned spectral pre-treatment, the grain samples appeared homogenous in the PC scores image, having a relatively higher [in the case of rice, Figure 1(d)], or lower [in the case of the mixed grain sample, Figure 1(g)] pixel intensity than the foreign bodies. Consequently, it was possible to segregate the contaminants from the image background by simple thresholding. However, some edge regions of the grains suffered misclassification [see Figures 1(e) and (h)] due to their curvature. In order to remove these false positives and maintain the true foreign bodies in the thresholded image, morphological dilation and erosion operations were applied, resulting in more accurate foreign body detection images [see Figures 1(f) and (i)].

In order to build a discriminant model for foreign body identification, PCA was applied to the pixels belonging to the foreign body class [as defined by Figures 1(f) and (i)]. The PC2 image and its corresponding histogram for the mixed grain sample are shown in Figures 2(a) and (b), respectively. There are three peaks in the histogram, one corresponding to each contaminant. Thresholding the PC2 image according to these peaks allows identification of each contaminant, as shown in Figure 2.

The results from the PCA analysis on each sample can be used in algorithm development for detection and identification of contaminants in the processing line. A flow diagram for a typical routine based on the analysis described in the preceding sections for detection and classification of foreign bodies for the mixed grain sample is shown in Figure 3. Standard image pre- and post-processing steps such as background removal and dead pixel removal are omitted for clarity. Application of PC eigenvectors thus enables the detection and identification of foreign bodies in a sample. The PC eigenvectors used in this method are sample and foreign-body specific. However, this kind of analysis can easily be modified to perform in a typical processing environment in which the food sample is well characterised and a range of potential likely foreign bodies is known.


Hyperspectral reflectance imaging in the NIR wavelength range combined with chemometrics shows much promise for detection and identification of foreign bodies among food grains. This method is particularly well suited to the identification of plastic and rubber foreign bodies, since these materials exhibit characteristic absorbances in the near infrared wavelength region. This study also indicates the potential of NIR reflectance HSI for detection of glass in amongst grain samples. The method proposed could be modified for detection and identification of foreign objects among raw material samples, for example, in a food processing chain. In situations where a foreign body is likely to be contained within the food sample of interest, transmission of light is a more desirable mode than reflection for detection, since reflectance imaging reveals mainly surface characteristics. Transmission HSI in the visible-near infrared wavelength region may be suitable for sub-surface detection of foreign bodies; but its usefulness will, typically, be sample specific, being strongly dependent on the light scattering properties of the sample.


  1. A.A. Gowen, C.P. O’Donnell, P.J. Cullen, G. Downey and J.M. Frias, “Hyperspectral imaging—an emerging process analytical tool for food quality and safety control”, Trends Food Sci. Technol. 18, 590 (2007). doi: 10.1016/j.tifs.2007.06.001
  2. C. Esquerre, A.A. Gowen, J. Burger, G. Downey and C.P. O’Donnell. “Suppressing sample morphology effects in near infrared spectral imaging using chemometric data pre-treatments”, Chemometr. Intell. Lab. Syst. 117, 129 (2012). doi: 10.1016/j.chemolab.2012.02.006
Rate this Article
Average: 5 (787 votes)