# Dual mode multispectral imaging system for food and agricultural product
quality estimation

Darsha Udayanga, Ashan Serasinghe, Supun Dassanayake, Roshan Godaliyadda, ,
H.M.V.R. Herath, , M.P.B. Ekanayake, , H.L.P. Malshan The authors are with the
Department of Electrical and Electronic Engineering, Faculty of Engineering,
University of Peradeniya, Sri Lanka.Corresponding author’s email:
<EMAIL_ADDRESS>
###### Abstract

Multispectral imaging coupled with Artificial Intelligence, Machine Learning
and Signal Processing techniques work as a feasible alternative for laboratory
testing, especially in food quality control. Most of the recent related
research has been focused on reflectance multispectral imaging but a system
with both reflectance, transmittance capabilities would be ideal for a wide
array of specimen types including solid and liquid samples. In this paper, a
device which includes a dedicated reflectance mode and a dedicated
transmittance mode is proposed. Dual mode operation where fast switching
between two modes is facilitated. An innovative merged mode is introduced in
which both reflectance and transmittance information of a specimen are
combined to form a higher dimensional dataset with more features. Spatial and
temporal variations of measurements are analyzed to ensure the quality of
measurements. The concept is validated using a standard color palette and
specific case studies are done for standard food samples such as turmeric
powder and coconut oil proving the validity of proposed contributions. The
classification accuracy of standard color palette testing was over 90% and the
accuracy of coconut oil adulteration was over 95%. while the merged mode was
able to provide the best accuracy of 99% for the turmeric adulteration. A
linear functional mapping was done for coconut oil adulteration with an R2
value of 0.9558.

###### Index Terms:

Multispectral imaging, Machine Learning, Food quality estimation, Imaging
system, Experimental validation, Classification, Regression modeling.

##  I Introduction

Food quality is an integral and essential part of global food security.
Ensuring food quality includes the assurance that the food is void of harmful
contaminants and unacceptable adulterants [1, 2]. However, analyzing food
samples for contaminants and adulterants requires sophisticated laboratory
measurement systems and relies on skilled professionals. There are hardly any
convenient and robust measurement systems that can be used at field level even
for the most rudimentary of such tests.

Humans rely on their senses, especially smell and vision to gauge the
potential quality of food prior to consumption. As the sense of smell involves
complex chemical phenomena, it does not provide an easy avenue for automatic
detection. On the other hand, visual sensation provides ample opportunities
for such automated testing. Therefore, vision based sensing is a popular
choice for quality assessment in various applications [3, 4, 5], including but
not limited to medical [6, 7], astronomical [8, 9], cultural heritage [10, 11]
and agricultural [12, 13] fields.

Multispectral Imaging (MSI) is an enhancement of tri-color red-green-blue
(RGB) imaging. MSI utilizes multiple narrow bands of color covering not only
the visual range but also near-infrared (NIR) and near-ultraviolet (NUV).
Therefore, MSI provides a rich set of information [14], over standard RGB
imaging, including finer details that depend on chemical properties. This
advantage of MSI can be further enhanced via the incorporation of the recent
advances in artificial intelligence (AI) and machine learning (ML) [15, 16].

There are high-end industrial grade MSI devices, which are usually purpose-
specific, bulky, and expensive [17, 18, 19]. However, in cases where onsite
testing is necessary, opting for a versatile and portable design with
innovative concepts to enhance and enrich the captured MSI is a more
reasonable approach. Furthermore, since the purpose of such a system is
primarily to be deployed in the large scale and multilayered retail market,
simplicity and cost effectiveness take priority. Moreover, the use of MSI
system may be extended beyond food applications to various other types of
specimens that require simple, cost-effective onsite testing.

Contemporary MSI devices utilized different techniques to acquire
multispectral images of specimens [20]. One study [21] has utilized liquid
crystal tunable filters (LCTFs) to divide the spectrum. Another design [22]
has used a multispectral filter array (MSFA) and a multispectral demosaicing
algorithm. Using filters is a common practice for acquiring MSI as evidenced
by this device [23] which comprises several mirrors and filters. An iris
capture device [24] was also designed using filters and LEDs as the
illumination source. Two studies [25, 26] were found to make use of
hyperspectral tunable filters and diffraction grating respectively.

One study [27] published in 2020 with the title of ‘Characterization of a
multispectral imaging system based on narrow bandwidth power LEDs’ which has
utilized an array of Narrowband LEDs with the wavelength ranging from 410 nm
to 950 nm across 15 pairs of LEDs. The system includes a multispectral
lighting system, an optical sensor, a light controller and an image capture
environment. The multispectral lighting system was a circularly arranged set
of LEDs controlled using the light controller. The light generated by the LEDs
was shined upon the specimen and the reflectance image was captured using the
camera. This process was carried out within a special image capture
environment that was created for this purpose. The intensity of the light
could be controlled using a PWM (Pulse Width Modulation) signal.

In principle, MSIs of a sample can be acquired either by illuminating it with
light sources of specific narrowband wavelengths [28] or by illuminating the
sample with a broadband light source and filtering the required light
frequencies using an array of narrowband filters [29, 30, 31, 32]. The former
is simpler in design, robust, expandable, and overall, more economical; while
the latter is more compact, yet much more expensive and less flexible.

One limitation identified in the above mentioned system [27] was its inability
to process liquid or similar samples due to the lack of a transmittance mode
imaging method. This is a huge drawback because this limits the use of the
said device strictly to solid specimens and reflectance mode. Few other above-
mentioned studies also contained the same limitation [21, 22, 23, 24, 25, 26].
The lack of a light directing mechanism of the said system [27] is another
drawback because the light generated by LEDs usually disperses around the
generation source. Therefore, a light directing mechanism is required to guide
the light onto the specimen. The other mentioned studies exhibit a few
additional design limitations such as low spectral resolution [24] (Only three
color bands) and the lack of light directing mechanism onto the specimen [25].

Considering the nature of the problem at hand, an MSI system which illuminates
the sample with narrowband LEDs is proposed in this paper as it is the more
economical alternative to get more spectral bands in the desired range.
Innovative design concepts of the proposed system include a dual mode
capability for reflectance and transmittance imaging, a versatile modular
architecture, an intensity control mechanism for flexibility, integrating
hemispheres to ensure uniform light distribution and a controller system
coupled with an easy-to-use user interface. Thereafter, context specific AI,
data analytic and signal processing algorithms are developed to obtain
functional relationships between contaminants/adulterants and statistical
characteristics of multispectral measurement data. Furthermore, ML algorithms
are used for classifications based on contamination/adulteration levels.

To evaluate the imaging system, system validation must be done. The validation
process can be carried out in two methods. Either by testing standard colors
[33] or by conducting experimental tests on real samples [34] to determine the
applicability of the device. The study under consideration [27] has only
carried out the standard color test. While this gives substantial information
on the functionality of the system, it’s challenging to determine the real-
world applicability of the system. Hence, conducting experiments on real
samples is required. Furthermore, the study [27] has attempted to visualize
the separation of 24 distinct colors using the imaging device. Correlation
analysis of the spectral signatures of these colors was done by applying
Principal Component Analysis (PCA). It was compared with a high grade
Hyperspectral Imaging (HSI) system. Moreover, one of the systems under
consideration [21] has utilized both testing using standard lamps and
experimental testing using traditional Chinese medicines as specimens. Another
study [22] was tested experimentally by capturing their own set of images and
comparing them with standard multispectral datasets. Since the algorithm
development part was one of the main objectives, two algorithms were applied
to the dataset and the results were compared. In another study, [23] their own
synthesized tests were performed and PCA was used as well. A multispectral
Iris Capture Device [24] was validated by creating a dataset by imaging
different subjects. They have used their own image-level fusion algorithm. 1-D
log-Gabor wavelet recognition method [35] was used to identify the iris
images. A multispectral skin imaging system [25] was validated using real
samples. However, they have only used two test samples which may have affected
their validation accuracy. One other considered study [25] has also failed to
validate their device using actual real experimental testing. When examining
previous studies, very few studies have focused on building functional
relationships between the parameters of the sample and the MSI parameters
[36]. Functional maps or regression models offer the ability to operate in a
continuum as opposed to mere classification which operates only on a few
designated classes.

Considering the current state of the art and the identified research gaps, the
major contributions of the proposed work are summarized as follows. As opposed
to the above studies, the proposed system is equipped with a dedicated
transmittance mode. Furthermore, rather than being limited to a single mode,
it has dual mode capabilities which enables switching between reflectance mode
or transmittance mode at will. In addition to the dual mode operation where
the device toggles between reflectance and transmittance modes, it provides
the option to operate effectively on a merged transmittance-reflectance mode.
This enables the spectral information of a given sample to be captured through
both modes separately and then combined, which will be referred to as the
merged mode hereafter. Essentially, it makes use of spectral components of
both modes, creating a dataset with a higher dimensionality. Thus allowing AI
and ML algorithms to perform better due to the larger number of features in
the dataset, resulting in increased accuracy. As an example, turmeric powder
can be captured in reflectance mode as a powder. Then, the same sample can be
dissolved in water and captured in transmittance mode as a liquid, and both
sets of images can be combined to enable the merged mode operation.
Furthermore, some non-translucent liquids can also be tested via this merged
mode.

A case study was conducted to analyze turmeric powder samples using the merged
mode as previously described. A study was also carried out to assess the
temporal and spatial variations of measured data to identify the optimum image
acquisition area. To validate the device and proposed algorithms on standard
and real-world data, first, a validation study was conducted on a standard
color palette. Furthermore, a case study was conducted to classify among
adulteration levels of rice flour on turmeric powder. Finally, another case
study was performed to build a functional relationship between the
adulteration level of palm oil on coconut oil using the Kullback-Leibler (KL)
divergence as the metric.

##  II Multispectral Imaging system

The multispectral imaging system encompasses several noteworthy features. The
main elements are the lighting panels, the controller board, the image capture
environment and the controller software including the graphical user
interface. The user is connected to the system via a computer.

Since the LED acts as a single point light source, the light is concentrated
around the center. Reflecting hemispheres with dull surfaces are used in
combination with lighting panels to diffuse and direct the generated light in
the required direction. Also, the light panels are constructed in a modular
architecture, so the intensity of each light panel quarter could be handled
individually, thus providing better control over the light spread and
intensity on a specimen. The system covers wavelengths from Ultraviolet (UV)
to near Infrared (NIR) where the range extends from 365 nm to 940 nm. It is
made sure to have enough illumination on a specimen by using eight LEDs per
color band per light panel. LEDs are distributed in a radial manner which
ensures the uniformity of the light on the specimen. Finally, to establish
ease of operation for the user and to maintain control over the system, the
controller software is developed including a Graphical User Interface (GUI)
which provides the user with a preview of the captured image and a lot of
options in handling the system.

Figure 1: Multispectral light panel with one segment enlarged.

###  II-A Multispectral light panels

The LED panels are designed to have four identical segments as depicted in
Fig. 1. Each segment has LEDs of 13 color bands with the spectral range
spanning from 365nm to 940nm. The relative intensities of LEDs are shown in
Fig. 2. The device is designed in such a modular architecture to enable
intensity control of each segment. This way, it permits the user to control
each quarter of the light panel individually. The LEDs in each segment are
placed symmetrically and radially in order to obtain a uniformly dispersed
light onto the specimen. The segments are connected to each other using
connectors. In addition, in case of a malfunction in one of the four segments,
other segments continue to function independently. The whole system does not
have to be taken down for maintenance. Other segments can function normally
while the malfunctioned segment is being repaired. Malfunction identification
of these light panels is also made significantly easier by deploying this
modular architecture. The PCB layout of a light segment is shown in Fig. 3.

Figure 2: Relative intensity vs wavelength of LEDs. Figure 3: PCB of one light
segment in the LED panel.

###  II-B Image capture environment (specimen illumination chamber)

A dark chamber is used as the image capture environment for the specimens. It
blocks out all the unwanted external interference. One light panel is mounted
on top of the chamber for reflectance imaging purposes while the other light
panel is mounted at the bottom of the chamber for transmittance imaging
purposes. Each light panel is covered by a reflecting hemisphere to ensure
light dispersion and to direct the light in the intended path. A cross section
of the whole system is presented in Fig. 4

The camera is directly placed above the transmittance light panel. Therefore
it can capture the light directly coming through the specimen. Similarly, the
light reflected from the specimen in the reflectance mode is also captured by
the same camera. The platform which holds the specimen can be switched between
a transparent glass sheet or an opaque wooden panel depending on the mode of
illumination used ( transmittance or reflectance). The main controller board
is mounted on the top outer surface of the chamber, closer to the camera.

Figure 4: Cross section of the system.

###  II-C Control Board

The control board is used for three main purposes.

  1. 1.

Turning on/off the corresponding color band in the light panel.

  2. 2.

Controlling the intensity of each segment of the light panel.

  3. 3.

Communicating with the controller software.

Figure 5: Circuit diagram of a single color band.

Fig. 5 shows the circuit of a single color band. The LEDs are connected to the
power supply through two MOSFETS. One BJT is used to block the back current
into the microcontroller. In addition to these components, biasing resistors
and current controlling resistors are used as necessary. The microcontroller
is used to provide the switching and PWM signals into the MOSFETS. The
controller board is designed as a shield for the Arduino Due board, so it can
be attached directly to the microcontroller board. The PCB layout of the
control board is illustrated in Fig. 6.

#### Turning on/off the corresponding color band in the light panel.

Switching on/off of a specific color band is handled by the Q2 MOSFET. It is
an N-MOSFET. When a digital HIGH signal is fed into the gate terminal (VGS =
5V) of the Q2 MOSFET, the MOSFET goes to the saturation region, closing the
circuit. The MOSFET acts as an electronic switch.

Figure 6: PCB of the control board.

#### Controlling the intensity of each segment of the light panel.

Intensity control of each segment is handled by the Q3 MOSFET. It is a
P-MOSFET. The Q1 BJT is used to isolate the microcontroller from the rest of
the circuit. This also acts as a signal amplifier. The PWM signal is fed into
the base of the BJT. With the PWM signal at the base of the BJT, the collector
voltage follows the PWM signal which is then fed into the gate of the MOSFET.
Which results in a varying intensity of the LED according to the PWM value.
Here both the MOSFET and the BJT work in the linear region. The MOSFET was
selected due to its ability to operate in higher frequency ranges than other
power transistors.

#### Communicating with the controller software.

The system is handled via the software running on the computer, the user can
control the device from the graphical user interface. The user commands are
sent through the controller software and executed using the microcontroller.
Therefore, the communication between the microcontroller board and the
software should be maintained.

###  II-D Controller software and the graphical user interface

#### Control Architecture

The central control element of the system is the desktop application running
on a computer. Where it receives user inputs and then communicates to the
camera and the control panel. The control panel turns the relevant LEDs on and
immediately after, the camera captures the image. When the capturing ends, the
LEDs are turned off instantly. A three-way handshake method is implemented to
ensure the synchronization between the camera and the LEDs. The desktop app
stores the captured images in the local disk of the computer in which the app
is running. The communication structure is depicted in Fig. 7.

#### Control board firmware

Arduino Due is utilized as the microcontroller board of the system. The
microcontroller board communicates with the desktop app via Universal Serial
Bus (USB) interfaces using Universal Asynchronous Receiver-Transmitter (UART).
Microcontroller board firmware works in three states,

  1. 1.

Waiting.

  2. 2.

turning on all the LEDs sequentially.

  3. 3.

Turning on a given LED

Initially, the program is in the waiting state. Control characters are sent by
the desktop app as a mechanism to switch the state. If a match is recognized,
the state will switch from the waiting state to the corresponding state. At
the end of each state, the program returns to the waiting state.

The light intensity of each light segment can be adjusted using 8
potentiometers on the board. Four potentiometers are dedicated to the top LED
panel while the other four are dedicated to the bottom LED panel. The
intensity of each LED panel varies with the input signals taken from the
potentiometers. The program takes the reading of each potentiometer before
proceeding to the state two or three. Then the PWM signals are generated by
the program according to the potentiometer readings. Once the program is in
state 1 or 2 (on/off stage of LEDs) the intensity cannot be changed.

Figure 7: Communication structure of the system.

#### Desktop application and camera control

The desktop app controls the microcontroller board as well as the camera.
Also, it interacts with the local disk of the computer. The camera installed
in the system is a FLIR monochrome industrial machine vision camera. To access
the camera, the Spinnaker SDK is used.

There are six indicators on the interface to show the intensity level of LEDs.
As mentioned above, these levels change with the inputs of the eight
potentiometers. The user can either capture all the color bands with one press
of a button or they may select only the required color bands and capture them
exclusively. While the image acquisition procedure is underway, each captured
image is previewed on the GUI.

###  II-E Calibration and image acquisition

To image a specimen using the proposed system, a certain procedure must be
followed. This includes the mode selection and calibration. First, the
prepared sample must be placed inside the image capture environment. After
that, the required mode of imaging ( reflectance or transmittance) must be
selected using the control board. A key thing to consider here is that the
platform which holds the sample must also be changed according to the
operation mode. It must be opaque for the reflectance mode and it must be
transparent for the transmittance mode. Then, the aperture of the camera must
be adjusted. This setting controls the amount of light entering through the
lens of the camera. For a sample that might saturate the sensor of the camera,
a lower aperture is suitable. This will prevent the loss of information when
imaging. After that, the focus of the camera must be set. This ensures the
best resolution and sharpness of details in the image. Next, the required
color bands must be selected via the GUI. Finally, all the selected color
bands of the specimen will be captured and stored in the computer as presented
in Fig. 8.

Figure 8: A set of captured images of a sample.

##  III Materials and methods

The reliability of the device as a measurement system was assessed by
considering several metrics such as spatial consistency (reflectance
intensity, spectral signature distortion), repeatability and variance of
sample measurements. A single uniform piece of white paper was imaged using
the device and the above metrics were observed.

In order to validate and evaluate the proposed imaging system, two methods
were used. One was standard color testing and the other was validation by real
experimental procedures and results.

For the standard color testing, a color chart with 24 distinct colors was
used. Different algorithmic techniques were used to differentiate between
colors using the spectral information captured using the system.

As real experimental testing, two case studies were created to cover the full
capability of the system.

  1. 1.

Estimation of adulteration level of turmeric powder with wheat flour [37]
(solid powdery specimen).

  2. 2.

Estimation of adulteration level of coconut oil with palm oil (liquid
specimen).

As per the case study 1, turmeric powder is a solid specimen which can be
imaged in the reflectance mode while also being a type of sample which can
then be dissolved in water and again imaged in transmittance mode. This case
study provides the ground to validate both our reflectance and transmittance
mode while enabling it to create a dataset with one sample having both
reflectance and transmittance data bundled together in the feature space
increasing the dimensionality of the dataset. Thus, validates the proposed
merged mode.

As per the case study 2, coconut oil is a liquid specimen which can be imaged
in the transmittance mode. From this case study, the performance of the
transmittance mode of the system can be thoroughly analyzed and compared with
other modes. The main objective is to build a functional mapping between the
adulteration level and the transmittance spectral data.

###  III-A Sample Preparation

#### Case Study 1: Turmeric Adulteration

Samples of authentic turmeric powder, made from freshly harvested turmeric
rhizomes, were gathered for the study. To adulterate the turmeric, the pure
turmeric powder was then mixed homogeneously with varying amounts of rice
flour, creating different ratios ranging from 0% to 40% by weight. For each
adulteration level (0%, 5%, 10%, 15%, 20%, 25%, 30%, 35%, and 40% by weight),
nine identical samples were prepared, resulting in a total of 81 powdery
samples.

In order to be used in the merged mode described above, new dissolved samples
had to be created using the same powdery samples. For that, prepared turmeric
powder samples were dissolved by mixing them with an equal volume of distilled
water. The mixture was then stirred thoroughly until all the solid particles
had completely dissolved in the water. A total of 81 dissolved turmeric
samples were prepared as well.

#### Case Study 2: Coconut Oil Adulteration

This experiment is carried out to assess palm oil adulteration in coconut oil.
The pure coconut oil was combined with varying proportions of palm oil,
resulting in different volume ratios ranging from 0% to 40%. For each level of
adulteration (0%, 5%, 10%, 15%, 20%, 25%, 30%, 35%, and 40% by volume), eight
identical samples were prepared, resulting in a total of 72 liquid samples.

###  III-B Imaging using the system

#### Case Study 1: Turmeric Adulteration

During the process of obtaining multispectral images from the adulterated
turmeric powder samples, a meticulous procedure was followed. First, an equal
amount of the powdered samples was spread evenly across the surfaces of the
petri dishes. This meticulous distribution was essential to establish a
uniform layer, ensuring consistency across all samples. Then, the reflectance
mode of the device was utilized to capture images of the powder samples.
First, placed turmeric powder-filled petri dish in the image-capturing
environment, ensuring consistent placement throughout the experiment. In this
process, the light was projected onto each sample, and the reflected light was
captured using the camera.

To employ the merged mode for turmeric analysis, it was necessary to capture
the dissolved samples created from the powdery samples. For that, the device
was switched to transmittance mode. Transmittance images involve passing light
through a substance and capturing the resulting information. The dissolved
powder mixture was poured carefully into a container specifically designed
with a transparent bottom and placed in the image-capturing environment where
the transparent bottom of the container enabled the light rays to pass through
the mixture unobstructed. Then, the light was transmitted through each sample
and it was captured using the camera.

#### Case Study 2: Coconut Oil Adulteration

The coconut oil samples, after being prepared, were placed inside a container
with a transparent bottom. The mixture was then gently stirred to ensure that
no air bubbles remained in the mixture. This careful stirring helped create a
consistent and even composition. Using the transmittance mode of the device,
the light was passed through each sample and it was captured as an image.
Captured sets of images were used for further analysis.

###  III-C Multispectral Image Preprocessing

Image preprocessing is a vital step prior to multispectral image analysis
because it extracts the useful information and enhances it. Preprocessing can
also reduce the effect of noise which may have occurred during image
acquisition.

#### Image Cropping

Cropping is a common image preprocessing technique that removes unwanted
elements to direct the focus onto specific areas of interest. It is often
performed before further processing to eliminate distractions and to ensure
only necessary information is used for further analysis. Therefore, every
captured image was cropped into a 100×100-pixel image which only contains the
information about the specimen to be analyzed. Since there are 14 images of a
single sample (consisting of a dark image and 13 spectral bands), an identical
region was cropped from all 14 images.

#### Dark Current Reduction

Multispectral imaging systems face random noise sources like camera read-out,
wire connections, data transfer, electronic noise, and analog-to-digital
conversion, which can affect the outcomes of image analysis [38]. In the
preprocessing stage random noise is reduced using dark current subtraction.
Pixel recording can happen even when any source of light is not present. Dark
current primarily emerges from currents generated during the creation of the
depletion region and irregularities on the silicon lattice surface of the
photodiode. To mitigate this effect, a dark current image is captured at the
beginning of multispectral imaging, and then it is subtracted from all the
following lighted images. This technique reduces random noise in photodiodes
and photosensors.

Figure 9: Spectral signatures of coconut oil samples.

#### Bilateral Filtering

Bilateral filtering is another noise reduction preprocessing technique. It is
utilized to reduce noise while preserving edges and fine details. The
bilateral filter calculates the weighted average of neighboring pixels, where
the weights are determined by both spatial proximity and intensity similarity.
This weighting scheme helps to smoothen the image while preserving edges. It
achieves this by applying a weighted average of nearby pixels, where the
weights depend on both the spatial distance and the similarity in pixel
intensities.

###  III-D Representation of Multispectral Image Data

#### The Data Matrix

Multispectral data consists of monochromatic images representing intensities
at different wavelength bands. These images contain vector pixels with
spectral and spatial information. Initially, from all the images, 10×10-pixel
sections were averaged out to create superpixels which are less noisy. This
was done for cropped images with the size of 100×100-pixels, resulting in 100
superpixels per image. Said superpixel intensities were stored vertically in a
data matrix - X with dimensions of 100×13 (13 spectral bands). This process
was repeated for all the samples, resulting in a vertical stack of intensity
values of superpixels.

#### Spectral Signatures

After creating the data matrix, the average pixel intensity of all the samples
in each adulteration level across every spectral band was obtained. Then, the
average pixel intensity vs wavelength was plotted for different adulteration
levels. The spectral signature of Coconut oil samples is illustrated in Fig.
9.

##  IV Results

The classification models in the following sections were trained on 75%
training data and it was tested on 25% test data.

###  IV-A Reliability assessment of the measurement system

The images taken from the device have adequate consistency in terms of
reflectance intensity as shown in Fig. 10. Same shape of reflectance intensity
was observed for all the color bands. Only the intensity plot of 770 nm
wavelength is displayed for brevity. In addition to that, the spectral
signature distortion with the spatial difference is depicted in Fig 11. The
best location for specimen placement in the system would be the intersection
between the highest intensity area of Fig. 10 and the lowest spectral
signature distortion area of Fig. 11. The repeatability of the system was
tested by imaging the same sample with temporal gaps. As indicated in Fig. 12,
multispectral image parameters across all the color bands did not show a
substantial deviation with time. The maximum percentage deviation from the
mean with time was observed to be 1.32%. In the functional mapping development
attempt in case study 2, box plots were utilized to analyze the distribution
of data points of the same class created using Kullback-Leibler (KL)
divergence as displayed in Fig. 15. The data points of the same class were
observed to be placed without a high variance indicating the validity of the
measurements.

Figure 10: Normalized reflectance intensity of 770 nm band. Figure 11: Spatial
variation of the Euclidean distance of the spectral signatures with respect to
the center pixel of the highest illumination region when imaging a white
paper. Figure 12: Average intensity of all color bands across multiple
samples.

###  IV-B Standard Color Testing

The multispectral images of the standard color chart were preprocessed and the
dataset was created. Then, the dimensionality of the dataset was reduced by
using Linear Discriminant Analysis (LDA) and Principal Component Analysis
(PCA). PCA is used as a dimensionality reduction technique where it transforms
the feature space into a new feature space containing all the useful
information. LDA is another dimensionality reduction technique that focuses on
maximizing the separability of classes as a supervised method. Fig. 13 shows
the variation of data along the first two LDA components. Superpixel average
was utilized to plot the spectral signature and to classify between the
colors. Support Vector Machines (SVM) Classifier coupled with PCA and LDA
provided the best accuracy of around 90%. Accuracies for the standard color
test are listed in the TABLE I.

TABLE I: Standard color classification accuracy. Classifier | With PCA | With LDA
---|---|---
Decision tree | 0.86 | 0.86
KNN | 0.88 | 0.88
Logistic regression | 0.87 | 0.86
Random forest | 0.88 | 0.89
SVM | 0.90 | 0.90
Figure 13: LDA applied on indicated standard colors.

###  IV-C Case Study 1: Turmeric Adulteration

Classification of turmeric samples was done in three stages. First, the
classification was done on images taken using the reflectance mode. The best
accuracy recorded for that was 51% given by the Support Vector Machines (SVM)
classifier. In the next stage, algorithms were applied to the same samples in
dissolved state which were imaged using transmittance mode. Classification
accuracy slightly increased with 66% being the highest. Finally, both modes
were combined as the merged mode and it yielded the best accuracies for all
the classifiers. Decision Tree Classifier resulted in the best accuracy of
around 99%, thereby establishing the validity of the newly proposed merged
mode as an effective method to analyze different specimens. Fig. 14 depicts
the accuracy comparison between modes.

Figure 14: Turmeric classification accuracy across modes.

###  IV-D Case Study 2: Coconut Oil Adulteration

#### Classification model

Various machine learning classifiers were employed on the generated dataset to
assess the capability of the system to distinguish between different levels of
coconut oil adulteration. Before classification, dimensionality reduction was
done by applying Linear Discriminant Analysis (LDA) to the dataset. The
Decision Tree classifier provided the best accuracy around 95%. All the
algorithms yielded very good accuracies which are presented in TABLE II. All
of them were greater than 88%. In conclusion to this case study, it can be
verified that the proposed multispectral imaging system provides a good
solution to quantify the adulteration level of palm oil in coconut oil. This
was made possible due to the dedicated transmittance mode of the device.
Furthermore, this establishes the use of transmittance multispectral imaging
to analyze liquid samples.

TABLE II: Coconut oil adulteration classification accuracy. Classifier | Accuracy
---|---
Logistic Regression | 0.89
KNN | 0.95
SVM | 0.95
Decision Tree | 0.95

#### Functional mapping

Kullback-Leibler (KL) divergence was used to develop a functional mapping for
adulteration levels. A statistical measure from information theory known as
the KL divergence metric is frequently used to quantify the deviation of one
probability distribution from a reference probability distribution. The
following equation is used to calculate KL divergence.

$KL(P\|Q)=\sum_{x_{i}}P\left(x_{i}\right)\log\frac{P\left(x_{i}\right)}{Q\left(x_{i}\right)}$
(1)

Q(x) is the sample probability distribution, while P(x) is the reference
probability distribution.

A functional relationship was established between the KL divergence metric and
adulteration level as shown in Fig. 15 The statistic mentioned above was
determined for each adulteration level’s nine replicates. The measure was
calculated using randomly chosen data points from the 0% adulteration level as
the reference. The generated functional relationship for KL divergence is

$Y=1.0497X-1.001$ (2)

with R2 = 0.9558. Where X and Y represent the percentage adulteration level
and the KL divergence respectively. As represented in Fig. 15, the KL
divergence increases with the level of adulteration. As a result, using
multispectral imaging, the developed model can predict the palm oil
adulteration level in coconut oil with significant precision.

Figure 15: Functional Mapping of Coconut oil adulteration.

##  V Conclusion

A versatile multispectral imaging device that can be used for reliable
assessment of food quality in a field setting is proposed in this paper. This
system provides the capability of both reflectance mode MSI and transmittance
mode MSI, with the ability to easily switch between the two modes. This
enables the user to make the measurements using only transmittance, or only
reflectance, or using both modes for the same sample preparation, or using
both modes with different preparations derived from the same sample. In the
case when both reflectance and transmittance images are acquired, it is
possible to achieve better results by merging the measurements to obtain a
higher number of features. For the instrumentation setup, an extensive spatio-
temporal variation study was performed to identify the optimal area for
imaging acquisition for processing. Different machine learning algorithms are
used to classify food samples while KL divergence based signal processing
algorithms were developed to obtain a functional relationship between measured
samples and adulteration levels. The measurement attributes such as
repeatability, consistency, precision, and accuracy of this device are
assessed in detail via controlled calibration tests and case studies. Design
features of this system include symmetric and modular light panels, a
centralized controller module, reflecting hemispheres, and an intuitive GUI.

The system as a whole was validated thoroughly by standard color palette
testing as well as real experimental testing including food specimens such as
turmeric powder and coconut oil. The system was able to identify different
colors with all the classifiers providing more than 85% accuracy while the SVM
classifier was the best with 90%. The transmittance mode was proved to be
accurate with classifiers applied on coconut oil samples giving more than 89%
accuracy where KNN, SVM and Decision Tree algorithms yielded an accuracy of
95%. The effectiveness of the merged mode was affirmed by the fact that the
Decision Tree Classifier was able to provide the best classification results
under the merged mode analysis utilizing powdered and dissolved turmeric
samples. Reflectance mode and transmittance mode individually provided 38% and
55% accuracies respectively while merged mode was able to provide an accuracy
of 99%. The linear functional map developed in the regression model for
determining the adulteration level of coconut oil can be considered successful
as the obtained R2 value is 0.9558.

While the paper is focused on food quality estimation, the applications of the
device are not limited to food and can be extended further. The developed
system can be used for any solid or liquid specimens if they can be placed
inside the system and if they are able to produce an observable spectral
change in the used spectral regions of the device. The proposed merged mode
strategy for higher dimensionality in feature space construction and KL
divergence type metric utilization for obtaining functional relationships with
adulteration and contamination levels can be extended beyond the recommended
food quality applications.

## Acknowledgments

The authors would like to thank H.M.P.S. Madushan, K.K. Abewickrama, J.A.S.T.
Jayakody and G.A.S.L. Ranasinghe of University of Peradeniya, Sri Lanka for
their valuable contribution towards experimental testing of the system.

## References

  * [1] E. Scott and D. Heldman, “Simulation of temperature dependent quality deterioration in frozen foods,” _Journal of Food Engineering_ , vol. 11, no. 1, pp. 43–65, 1990.
  * [2] H. Anwar, T. Anwar, and S. Murtaza, “Review on food quality assessment using machine learning and electronic nose system,” _Biosensors and Bioelectronics: X_ , vol. 14, p. 100365, 2023.
  * [3] S. Nizamov, S. D. Sazdovska, and V. M. Mirsky, “A review of optical methods for ultrasensitive detection and characterization of nanoparticles in liquid media with a focus on the wide field surface plasmon microscopy,” _Analytica Chimica Acta_ , vol. 1204, p. 339633, 2022.
  * [4] Y.-T. Chen, Y.-C. Lee, Y.-H. Lai, J.-C. Lim, N.-T. Huang, C.-T. Lin, and J.-J. Huang, “Review of integrated optical biosensors for point-of-care applications,” _Biosensors_ , vol. 10, no. 12, p. 209, 2020.
  * [5] M. Weisbrich and K. Holschemacher, “Comparison between different fiber coatings and adhesives on steel surfaces for distributed optical strain measurements based on rayleigh backscattering,” _Journal of Sensors and Sensor Systems_ , vol. 7, no. 2, pp. 601–608, 2018.
  * [6] P. Symvoulidis, C. C. Pérez, M. Schwaiger, V. Ntziachristos, and G. G. Westmeyer, “Serial sectioning and multispectral imaging system for versatile biomedical applications,” in _2014 IEEE 11th International Symposium on Biomedical Imaging (ISBI)_ , 2014, pp. 890–893.
  * [7] S. Kirschenmann, M. Bezak, S. Bharthuar, E. Brücken, M. Emzir, M. Golovleva, A. Gädda, M. Kalliokoski, A. Karadzhinova-Ferrer, A. Karjalainen, P. Koponen, N. Kramarenko, P. Luukka, J. Ott, H. Petrow, T. Siiskonen, S. Särkkä, J. Tikkanen, R. Turpeinen, and A. Winkler, “Multispectral photon-counting for medical imaging and beam characterization — a project review,” _Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment_ , vol. 1039, p. 167043, 2022.
  * [8] C. Guilloteau, T. Oberlin, O. Berné, and N. Dobigeon, “Hyperspectral and multispectral image fusion under spectrally varying spatial blurs – application to high dimensional infrared astronomical imaging,” _IEEE Transactions on Computational Imaging_ , vol. 6, pp. 1362–1374, 2020.
  * [9] S. De Angelis, M. C. De Sanctis, F. Altieri, M. Ferrari, E. Ammannito, S. Novi, M. Dami, F. Antonacci, F. Villa, M. Meini, F. Ruggiero, S. Fonte, M. Formisano, A. Frigeri, P. Tinivelli, M. Giardino, R. Mugnuolo, and S. Pirrotta, “The pre-launch on-ground characterization of Ma_MISS spectrometer for ExoMars-Rosalind Franklin Rover mission. II. Radiometric calibration,” _Review of Scientific Instruments_ , vol. 94, no. 9, p. 094501, 09 2023.
  * [10] A. Vietti, M. Parvis, N. Donato, S. Grassini, and L. Lombardo, “Development of a low-cost and portable device for reflectance transformation imaging,” in _2023 IEEE International Instrumentation and Measurement Technology Conference (I2MTC)_ , 2023, pp. 1–6.
  * [11] L. E. Sebar, L. Lombardo, M. Parvis, E. Angelini, A. Re, S. Grassini, A. Bovero, and A. L. Giudice, “Metrological validation of a photogrammetry-based technique,” in _2022 IEEE International Instrumentation and Measurement Technology Conference (I2MTC)_ , 2022, pp. 1–6.
  * [12] V. B. Raju and E. Sazonov, “Detection of oil-containing dressing on salad leaves using multispectral imaging,” _IEEE Access_ , vol. 8, pp. 86 196–86 206, 2020.
  * [13] A. Gorey, S. Shukla, J. Prasad, S. Verma, A. Sharma, and S. Vasudevan, “A compact laser diode based photoacoustic spectral response technique to differentiate brucellosis infected goat tissue from normal tissues,” _Journal of Instrumentation_ , vol. 14, no. 05, p. P05017, may 2019.
  * [14] D. A. Landgrebe, “Information extraction principles and methods for multispectral and hyperspectral image data,” 1999.
  * [15] T. R. C. Konfo, F. M. C. Djouhou, M. H. Hounhouigan, E. Dahouenon-Ahoussi, F. Avlessi, and C. K. D. Sohounhloue, “Recent advances in the use of digital technologies in agri-food processing: A short review,” _Applied Food Research_ , vol. 3, no. 2, p. 100329, 2023.
  * [16] W. Liu, H. Deng, Y. Shi, C. Liu, and L. Zheng, “Application of multispectral imaging combined with machine learning methods for rapid and non-destructive detection of zearalenone (zen) in maize,” _Measurement_ , vol. 203, p. 111944, 2022.
  * [17] W. Vijvers, R. Mumgaard, Y. Andrebe, I. Classen, B. Duval, and B. Lipschultz, “Conceptual design and proof-of-principle testing of the real-time multispectral imaging system mantis,” _Journal of Instrumentation_ , vol. 12, no. 12, p. C12058, dec 2017.
  * [18] C. Hou, T. Qiao, H. Zhang, Y. Pang, and X. Xiong, “Multispectral visual detection method for conveyor belt longitudinal tear,” _Measurement_ , vol. 143, pp. 246–257, 2019.
  * [19] Z. Zhao, B. Li, S. Zhang, T. Liu, and J. Cao, “Battery screen print defect detection based on stationary velocity fields neural network matching and optical flow rectification,” _Review of Scientific Instruments_ , vol. 93, no. 11, p. 115110, 11 2022.
  * [20] S. Kirschenmann, M. Bezak, S. Bharthuar, E. Brücken, M. Golovleva, A. Gädda, M. Kalliokoski, A. Karadzhinova-Ferrer, P. Koponen, N. Kramarenko, P. Luukka, J. Ott, J. Tikkanen, R. Turpeinen, and A. Winkler, “Quality assessment of cadmium telluride as a detector material for multispectral medical imaging,” _Journal of Instrumentation_ , vol. 17, no. 01, p. C01070, jan 2022.
  * [21] Z. Jing, P. Qichang, M. Ji, Z. Xiwen, and M. Qingxia, “Multispectral imaging system applied to element testing of biology,” in _2008 International Conference on BioMedical Engineering and Informatics_ , vol. 2, 2008, pp. 648–651.
  * [22] Y. Monno, S. Kikuchi, M. Tanaka, and M. Okutomi, “A practical one-shot multispectral imaging system using a single image sensor,” _IEEE Transactions on Image Processing_ , vol. 24, no. 10, pp. 3048–3059, 2015.
  * [23] F. Kazemzadeh, S. A. Haider, C. Scharfenberger, A. Wong, and D. A. Clausi, “Multispectral stereoscopic imaging device: Simultaneous multiview imaging from the visible to the near-infrared,” _IEEE Transactions on Instrumentation and Measurement_ , vol. 63, no. 7, pp. 1871–1873, 2014.
  * [24] Y. Gong, D. Zhang, P. Shi, and J. Yan, “High-speed multispectral iris capture system design,” _IEEE Transactions on Instrumentation and Measurement_ , vol. 61, no. 7, pp. 1966–1978, 2012.
  * [25] H. Erives and N. B. Targhetta, “Implementation of a 3-d hyperspectral instrument for skin imaging applications,” _IEEE Transactions on Instrumentation and Measurement_ , vol. 58, no. 3, pp. 631–638, 2009.
  * [26] C. Harrison Brodie, J. Devasagayam, and C. M. Collier, “A hyperspectral imaging instrumentation architecture based on accessible optical disc technology and frequency-domain analyses,” _IEEE Transactions on Instrumentation and Measurement_ , vol. 68, no. 7, pp. 2531–2538, 2019.
  * [27] M. A. T. Monsalve, G. Osorio, N. L. Montes, S. Lopez, S. Cubero, and J. Blasco, “Characterization of a multispectral imaging system based on narrow bandwidth power leds,” _IEEE Transactions on Instrumentation and Measurement_ , vol. 70, pp. 1–11, 2021.
  * [28] H. Weng, Y. Tian, N. Wu, X. Li, B. Yang, Y. Huang, D. Ye, and R. Wu, “Development of a low-cost narrow band multispectral imaging system coupled with chemometric analysis for rapid detection of rice false smut in rice seed,” _Sensors_ , vol. 20, p. 1209, 02 2020.
  * [29] C. Harrison Brodie, J. Devasagayam, and C. M. Collier, “A hyperspectral imaging instrumentation architecture based on accessible optical disc technology and frequency-domain analyses,” _IEEE Transactions on Instrumentation and Measurement_ , vol. 68, no. 7, pp. 2531–2538, 2019.
  * [30] M. Rosenberger, A. Wemhoff, D. Rebhan, P.-G. Dittrich, R. Illmann, and G. Notni, “Investigations on industrial water detection on surfaces using multichannel imaging techniques,” in _2020 IEEE International Instrumentation and Measurement Technology Conference (I2MTC)_ , 2020, pp. 1–6.
  * [31] Y. Wang, G. Tong, B. Li, X. Guo, X. Song, Y. Zhao, S. Karim, C. Deng, J. Zhou, W. Zhang, and Y. Yu, “Miniaturized customized filtering-wheel-based multispectral imaging system for target detection,” _Measurement_ , vol. 221, p. 113506, 2023.
  * [32] M. Rosenberger, R. Celestre, and G. Notni, “Image plane moving stage for high precision multispectral imaging,” _Measurement_ , vol. 119, pp. 85–90, 2018.
  * [33] C. Blaksley, M. Casolino, and G. Cambié, “Design and performance of a hyperspectral camera for full-face in vivo imaging,” _Review of Scientific Instruments_ , vol. 92, no. 5, p. 055108, 05 2021.
  * [34] M. Pirbhai, C. Albrecht, and C. Tirrell, “A multispectral-sensor-based colorimetric reader for biological assays,” _Review of Scientific Instruments_ , vol. 92, no. 6, p. 064103, 06 2021.
  * [35] L.-L. SHEN and Z. JI, “Gabor wavelet selection and svm classification for object recognition,” _Acta Automatica Sinica_ , vol. 35, no. 4, pp. 350–355, 2009.
  * [36] Y. Zhao, X. Hu, W. Zheng, and S. Wang, “Diagnosis method for corn nitrogen status measurement based on multispectral imaging,” in _2017 IEEE International Instrumentation and Measurement Technology Conference (I2MTC)_ , 2017, pp. 1–5.
  * [37] W. G. Chaminda Bandara, G. W. Kasun Prabhath, D. W. Sahan Chinthana Bandara Dissanayake, V. R. Herath, G. M. Roshan Indika Godaliyadda, M. P. Bandara Ekanayake, D. Demini, and T. Madhujith, “Validation of multispectral imaging for the detection of selected adulterants in turmeric samples,” _Journal of Food Engineering_ , vol. 266, p. 109700, 2020.
  * [38] E. M. Valero, M. A. Martínez, E. Kirchner, I. van der Lans, M. García-Fernández, T. Eckhard, and R. Huertas, “Framework proposal for high-resolution spectral image acquisition of effect-coatings,” _Measurement_ , vol. 145, pp. 379–390, 2019.