Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this tutorial the detection of plastic impurities on sausage is summarized

Table of Contents

Children Display

 

Outline

In food processing the detection of unwanted objects on goods is needed. This page summarizes a simple example on the detection of some plastic pieces on top of a sausage stack.

The aim is to find a model which allows the distinction between the sausage (the good) and unwanted objects (the plastic parts). As a result the achieved model is applied onto the measurement data and results in a color image showing a distinction by different coloring of objects.

In this tutorial a sausage stack and plastics are investigated by NIR line-scan HS imaging. After a short exploratory analysis, different CCI modeling methods are applied and the results are discussed.

Data, Samples & Measurement

Download the example project Sausage contaminated with plastics from the download section.

Expand
titlesausage_plastics
TitleSausage contaminated with plastics
CategoryFood - Impurity detection
Sample Description2x2 plastics on the top of a sausage stack ("Extrawurst").
Sample IDunknown
Sample Locationunknown
DonorMarkus Burgstaller
Date of Measurement16-04-27
Measurement SystemSTEMMER IMAGING HS Setup: Allied Vision GoldenEye CL033SWIR, Specim N17E slit30um, KOWA F12.5, Perception System
Measurement DescriptionMeasurement of reflectance
Measurement SetupIllumination: Halogen diffuse, background: black foam
Measurement ID20160527132739
FormulaUnknown
AnalysisUnknown
PreprocessingUnknown
Spectroscopic DiscussionUnknown
Sample Image(s)

 

Expand
titlesausage_plastics_highSpeed
TitleSausage contaminated with plastics
CategoryFood - Impurity detection
Sample Description2x2 plastics on the top of a sausage stack ("Extrawurst").
Sample IDunknown
Sample Locationunknown
DonorMarkus Burgstaller
Date of Measurement16-04-27
Measurement SystemSTEMMER IMAGING HS Setup: Allied Vision GoldenEye CL033SWIR, Specim N17E slit30um, KOWA F12.5, Perception System
Measurement DescriptionMeasurement of reflectance
Measurement SetupIllumination: Halogen diffuse, background: black foam
Measurement ID20160527132739
FormulaUnknown
AnalysisUnknown
PreprocessingTo enable highspeed scanning, the spectral range was restricted.
Spectroscopic DiscussionUnknown
Sample Image(s)

 

Start the project

Install the example project by double click on the downloaded file and follow the instructions of the installer.

Open the Perception Studio program (e.g. from a link on your desktop) and change to the Start perspective.

Switch to example projects and select Sausage contaminated with plastics from the list shown in the Start perspective.

Now, all data are loaded into the Perception Studio program, please give the system some seconds time to load all the data (watch the progress bar).

Exploratory analysis of the data

Change to the Explore perspective and select the HS cube sausage_plastics from the project browser.
In the Explore perspective the Hyperspectral data loaded (data set sausage_plastics) is visualized by an image in the center of the perspective as well as a spectra view on the bottom and a cube intersection view to the right.

Explore spectral information

The loaded example data come along with some predefined spectra sets. Have a look in the spectra view and study the shown spectra sets.

The reflectance measurement was done in the NIR range (~1000-1700nm). The background spectra (black foam) shows a reflectance around 0 over to whole spectra range. The plastics came along with distinct absorption bands at around 1150, 1200 and 1400nm. The reflectance spectra of the sausage shows a large influence of water (band at 1450nm). The spectra sets are showing varying reflectance information expressed by the shadow around the thick line in the middle.

It seem that both plastics are distinguishable clearly from the sausage in between the spectral range 1100-1250nm.

Explore the nature of information nested

In the following illustration the preview of the data is shown.

without1st derivative2nd derivative

Without preprocessing the plastics are hardly distinguishable in the image above by their color information. By applying the 1st derivative the impurities are distinguishable from sausage by their color information. So, the spectra of the objects are much more distinct compared to the image without preprocessing. The 2nd derivative causes a distinction but of only small color contrast.

When the separation of plastics is desired, the "1st derivative" seem to be a proper candidate for preprocessing.

Explore statistical information

In the following illustration some statistical information about the reflectance data are shown.

MinMax

Mean

Plastic_2 gets visible when investigating the minimum of the reflectance spectra - this is obvious since the minimum of the objects is quite different for spectra set Plastics_2 compared to all other (see section explore spectral information).
The max and mean of reflectance spectra does not give a clear separation between impurities and sausage. The mean feature might give a stable criteria if the separation of objects from background is needed.

Model application relevant information

Change to the Model perspective and select the HS cube "sausage_plastics" from the project browser.

In the Model perspective the Hyperspectral data loaded (data set sausage_plastics) is visualized by an image in the upper left of the perspective as well as a spectra view and a model view on the bottom left and the result image as well as a control field to the right.

From the ribbon menu a set of CCI modeling methods are accessible. An achieved model is saved in the project by click on the Save Model button and is later accessible from the project browser to the left of the Model perspective.

Modeling based on the extraction of principle components

From pre-selected spectra sets (sausage, plastic_1, plastic_2, etc.) principle components are extracted automatically. Their score per pixel is shown in the image collection in the bottom right.

Info

Please note: by applying the Extract method spectra get "unscrambled" in components. Typically a handful components are necessary to describe the major part of information nested in spectra.

Doing so, the components score images are selected which potentially hold application relevant information. If no application relevant information is available from the score images, the Extract method might be not suitable for your application. In this case, continue with one of the other CCI methods available (e.g. Correlate or Constrain).

Without preprocessing

Set Intensity in the HS Preprocessing section and select the CCI modeling method Extract.
In the following unscrambled component score images are shown:


PC1


PC2


PC3


PC4


PC5

PC6

PC1, PC2 and PC3 hold information valuable to solve the aimed application - they distinguish the plastics from the sausage stack.
PC4 holds information about the sausage (the spots might correspond to the varying fat content).
PC5 and PC6 primarily show information about a detail of plastic_2 (also part of PC1 and PC2).

Info

To influence the unscrambling process of principle components, you can arrange the spectra selection differently (e.g. reject the background spectra if you wish the objects only should influence the unscrambling process) or you should consider to apply one of the HS Preprocessing methods accessible from the ribbon menu.

A perception (a color image) is gained by assignment of proper PC's to the color channels of the resulting color image.
In this example the assignment is chosen automatically to be:

  • PC1 >> red
  • PC2 >> green
  • PC3 >> blue

This assignment results in the following image shown in the upper right of the Model perspective:

Resulting perception (PC1 => red, PC2 => green, PC3 => blue)

plastic_1 is described by an average portion of PC1 (red), a low portion of PC2 (green) and a high portion of PC3 (blue). Therefore, plastic_1 is shown by violettish information in the perception.
plastic_2 is described by a high value of PC1 (red) and PC2 (green) but a small portion of PC3 (blue). Therefore, plastic_2 is shown by a yellowish information in the perception.
Since PC1 (red) come along with the highest value of the sausage, the sausage is colored in a reddish information.

By assignment of other score images to the perceptions color channels, other perception can be obtained. In the following example PC4 (which describes varying information in the sausage) is assigned to red, green and blue - therefore a gray value image is obtained. The varying information in the sausage gets visible:

Resulting perception (PC4 => red, green, blue)

Applying preprocessing to spectra

In the next we want like to investigate preprocessed spectra by the Extract method. In section explore spectral information we recognized the spectral information of sausage and plastics to be much more distinct when 1st derivative is selected as HS Preprocessing from the ribbon menu.

Info

Please note:

The unscrambling of spectra into components is much more aiming, when the spectra are preprocessed properly.

Select sausage_plastics data set from the project browser and select 1st derivative in the HS Preprocessing section of the ribbon menu.
This results in the following components score images:


PC1


PC2

PC3

PC4

PC5

PC6

PC1, PC2 and PC3 hold information valuable to solve the aimed application - they distinguish the plastics from the sausage stack.
PC4, PC5 and PC6 hold information about noise.

The assignment of PC's to the result image is shown in the following image (upper right of the Model perspective):

Resulting perception (PC1 => red, PC2 => green, PC3 => blue)

We can summarize, that by applying the 1st derivative, only 3 components are needed to describe the spectral information in the data. By assignment of this PCs to color channels, a perception is gained, which describes the distinction between sausage and plastics very well.

Info

We suggest to apply preprocessing to the data even if the gained results compared to without preprocessing seem to be comparable.
Preprocessing typically allows application to be more independent from environmental influences (like varying lighting etc.). So such models provide typically more stable results compared to models carried out without preprocessed spectra.

Summary

By means of the Extract method, a perception was obtained capable to describe unwanted objects (plastics) differently to the good (sausage). The information extraction was done unsupervised (the method automatically unscrambles selected spectra into principle components). The unscrambling result can be greatly influenced by preprocessing of spectra or by the selection of spectra. The information transported through a resulting color image is selectable by the user through the assignment of score images to be the color channels of the resulting image.

We suggest to use the preprocessing 1st derivative instead of no preprocessing - such a resulting model is typically much more stable against environmental influences - it gains more robust results in industrial environment.

Modeling based on the correlation of spectra sets

Pre-selected spectra sets (sausage, plastic_1, plastic_2, etc.) are interpreted by the software as pure components and are correlated to the scene. Their correlation per pixel is shown in the image collection in the bottom right.

Info

Please note: A spectra can be a mix of different spectra of pure components. By knowledge of  „all“ pure components, a correlation value per component and pixel can be calculated. By assignment of component score images to colour channels, a perception is gained.

Without preprocessing

Set Intensity in the HS Preprocessing section and select the CCI modeling method Correlate.
In the following correlation score images are shown:

SausagePlastic_1Plastic_2background


PC1, PC2 and PC3 hold information valuable to solve the aimed application - they distinguish the plastics from the sausage stack.
PC4 holds information about the sausage (the spots might correspond to the varying fat content).
PC5 and PC6 primarily show information about a detail of plastic_2 (also part of PC1 and PC2).

Info

Ensure to select only objects which can be understood to be "pure" - spectroscopically independent to each other (orthogonal).
In case you miss this prerequisite, the results might not bring a value to you - they might get noisy.

To influence the correlation process, you should consider to apply one of the HS Preprocessing methods accessible from the ribbon menu.

A perception (a color image) is gained by assignment of proper score images to the color channels of the resulting color image.
In this example the assignment is chosen automatically to be:

  • sausage >> red
  • plastic_1 >> green
  • plastic_2 >> blue

This assignment results in the following image shown in the upper right of the Model perspective:

Resulting perception (sausage => red, plastic_1 => green, plastic_2 => blue)

Applying preprocessing to spectra

In the next we want like to investigate preprocessed spectra by the Correlate method. In the section explore spectral information we recognized the spectral information of sausage and plastics to be much more distinct when 1st derivative is selected as HS Preprocessing from the ribbon menu.

Info

Please note:

In general, the correlation of pure components is much more aiming, when the spectra are preprocessed properly.

Select sausage_plastics data set from the project browser and select 1st derivative in the HS Preprocessing section of the ribbon menu and study the results. After that, select 2nd derivative and try to understand the differences.

This results in the following components score images:

 SausagePlastic_1Plastic_2background
1st der
2nd der

The gained correlation score images of preprocessing 1st derivative are quite comparable to those without preprocessing.
This is different to the results gained by applying the 2nd derivative beforehand. The 2nd derivative comes along with a lot of noise in the spectra - also the scone images are noisy too.

The following table summarizes perceptions gained when different preprocessing was applied beforehand.

without1st der2nd der

Resulting perceptions (sausage => red, plastic_1 => green, plastic_2 => blue)

We can summarize, that by applying the 1st derivative, the results are quite comparable than without preprocessing. The 2nd derivative tends to noisy results.

Info

We suggest to apply preprocessing to the data even if the gained results compared to without preprocessing seem to be comparable.
Preprocessing typically allows application to be more independent from environmental influences (like varying lighting etc.). So such models provide typically more stable results compared to models carried out without preprocessed spectra.

In case a higher order derivative has to applied, one should consider to apply some smoothing on the gained output image in order to reduce noise.

Misleading selection

Now, we like to do a misleading selection to see how results can change.
Set 1st Derivative in the HS Preprocessing section and select the CCI modeling method Correlate.
Open the Select tool from the Edit section in the ribbon and append a new spectra:

Click on + New Spectra Set button and select an object which is already defined by an available spectra set.
I selected some pixels (red dots) of the 2nd piece of plastic_1 and named it plastic_1b:

You can modify the name and color of spectra sets by clicking on its name or color box respectively.


In the following correlation score images are shown:

sausageplastic_1aplastic_1bplastic_2background

The gained correlation score image are now misleading. It is not possible correlate spectra to the scene if they are not orthogonal too each other (does not have something in common with each other). This gets visible by studying the results for plastic_1a and plastic_1b which describe the same chemistry and result in noisy images.

Summary

By means of the Correlate method, a perception was obtained capable to describe unwanted objects (plastics) differently to the good (sausage). The information extraction was done unsupervised (the method automatically correlated selected spectra to the scene). The correlation process can be greatly influenced by misleading selection of spectra. Be sure to select spectra which hold independent information (orthogonal information), so pure components (constituents).

The information transported through a resulting color image is selectable by the user through the assignment of score images to be the color channels of the resulting image.

We suggest to use the preprocessing 1st derivative instead of no preprocessing - such a resulting model is typically much more stable against environmental influences - it gains more robust results in industrial environment.

 


 © 2016 2019 by Perception Park GmbH
The content of this page and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact Perception Park and delete copied material. Perception Park GmbH, Nikolaiplatz 4 / 3Wartingergasse 42, A-8020 8010 Graz; Austria; FN 400381x