*Article* **Electronic Eye Based on RGB Analysis for the Identification of Tequilas**

**Anais Gómez, Diana Bueno and Juan Manuel Gutiérrez \***

> Bioelectronics Section, Department of Electrical Engineering, CINVESTAV-IPN, Mexico City 07360, Mexico; arochag@cinvestav.mx (A.G.); dbuenoh@ipn.mx (D.B.)

**\*** Correspondence: mgutierrez@cinvestav.mx; Tel.: +52-55-5747-3800

**Abstract:** The present work reports the development of a biologically inspired analytical system known as Electronic Eye (EE), capable of qualitatively discriminating different tequila categories. The reported system is a low-cost and portable instrumentation based on a Raspberry Pi single-board computer and an 8 Megapixel CMOS image sensor, which allow the collection of images of Silver, Aged, and Extra-aged tequila samples. Image processing is performed mimicking the trichromatic theory of color vision using an analysis of Red, Green, and Blue components (RGB) for each image's pixel. Consequently, RGB absorbances of images were evaluated and preprocessed, employing Principal Component Analysis (PCA) to visualize data clustering. The resulting PCA scores were modeled with a Linear Discriminant Analysis (LDA) that accomplished the qualitative classification of tequilas. A Leave-One-Out Cross-Validation (LOOCV) procedure was performed to evaluate classifiers' performance. The proposed system allowed the identification of real tequila samples achieving an overall classification rate of 90.02%, average sensitivity, and specificity of 0.90 and 0.96, respectively, while Cohen's kappa coefficient was 0.87. In this case, the EE has demonstrated a favorable capability to correctly discriminated and classified the different tequila samples according to their categories.

**Keywords:** biologically inspired; electronic eye; optical methods; RGB analysis; tequila

**1. Introduction**

Tequila is the traditional Mexican spirit made with agave *tequilana weber* (blue variety), which is grown in five states of Mexico, namely: Guanajuato, Michoacán, Nayarit, Tamaulipas, and Jalisco. Those geographical regions are established in the Protected Designation of Origin (PDO) [1], which guarantees both the manufacturing procedures and the quality necessary to comply with the strict export specifications from the United States [2] and the European Union [3].

Three main categories of tequila are recognized. The first category is Silver tequila. It is obtained directly from the distillation process without additives; it has a transparent appearance, not necessarily colorless proper to an unaged tequila. The second category is called Aged tequila, which means that the tequila has been aged at least two months using oak casks. This process produces a mellowed product with rich color and flavor. Finally, the third category is known as Extra-aged. This tequila is considered more sophisticated because it has been aged for at least one year in wood or oak recipients with V ≤ 600 L, which has enhanced its flavor with predominant woody notes in its color and aroma [1].

These spirits, whose world consumption ranks fourth after whiskey, vodka, and rum, have a significant presence in more than 120 countries, representing sales of more than 200 million liters per year [4]. Hence, quality control is increasingly important to know, characterize, and monitor its aging process, alcoholic content, and volatile composition that define each kind of tequila's flavor, color, and characteristic aroma.

Nowadays, several tests are carried out in the laboratory to analyze tequila, most of them performing conventional analytical methods such as UV–Vis spectrophotometry [5],

**Citation:** Gómez, A.; Bueno, D.; Gutiérrez, J.M. Electronic Eye Based on RGB Analysis for the Identification of Tequilas. *Biosensors* **2021**, *11*, 68. https://doi.org/10.3390/bios11030068

Received: 29 January 2021 Accepted: 25 February 2021 Published: 2 March 2021

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

Raman spectroscopy [6], Gas Chromatography-Mass Spectrometry (GC-MS) [7], High-Performance Liquid Chromatography (HPLC) [8], Surface Plasmon Resonance (SPR) [9], and electrochemical analysis [10]. Nonetheless, despite their reliability and accuracy, they have several flaws related to long protocols demanding an analysis period from hours to days to carry out the tests, expensive equipment, and the need for technically qualified personnel, without forgetting that their use is confined to special installations with no online quality control possibilities.

Hence, there is an urgen<sup>t</sup> need for fast, inexpensive, portable, and effective alternatives that achieve reliable, non-destructive analytical measurements. Today, biologically inspired analytical systems are beginning to play an important role in the food industry [11,12]. These technologies, sometimes defined as artificial senses, have the perspective of evaluating complex composition samples by emulating the human senses to determine their relevant characteristics. Essentially, the electronic eye has been designed to mimic human eyesight to analyze color and some other attributes related to the sample's appearance [13,14]. This task can be performed using computer vision, colorimetric, or spectrophotometric methods [15–17].

Usually, an electronic eye is built of technology capable of converting optical images into digital images, subsequently analyzed to identify particularities that allow the characterization of what is being observed, avoiding the subjective interpretation of a person [18]. In this sense, image sensors based on a Charge Coupled Device (CCD) or a Complementary Metal Oxide Semiconductor (CMOS) technology are commonly used. Both types of sensors are essentially made up of metal oxide semiconductors (MOS) distributed in a matrix form, and that each independently constitutes a pixel [19]. Once the images are collected, they are subjected to an image processing phase to improve their quality and extract characteristics requiring specific computational algorithms for their interpretation [20].

Electronic eyes have been proven to have an advantage in foodstuff analysis; their applications cover different food industry areas such as quality control, freshness assessment, shelf-life determination, process monitoring, and authenticity assessment [14]. Although the use of electronic eyes in the analysis of some liquids have widely described during the last two decades, these works were focused on samples such as orange juice [21], coffee [22], virgin olive oils [23], milk [24] and some semi-liquids like honey [25], and yogur<sup>t</sup> [26]. Only a few studies reported the analysis of alcoholic beverages mainly related to wine [27,28], beer, and vodka [29]. Comparatively, the tequila study still continues using conventional techniques instead of an electronic eye. Most tequila analyses have been focused on the determination of quality characteristics [30], sensory properties related to the distillation process [31], evaluation of volatile compounds [32], the relevance of the aging process [33], authenticity [34,35], and adulterations [36].

This work aims to establish the foundations for using an electronic eye in the qualitative identification of different kinds of tequila. The developed analytical system comprises an acquisition image platform that captures and digitalized images directly from tequila, coupled with a biomimetic processing stage based on the trichromatic theory of color vision [37]. In this context, RGB absorbances of images were evaluated and subsequently discriminated against using a Principal Component Analysis (PCA) and Linear Discriminant Analysis (LDA), with was possible to correctly classify the three main tequila categories coming from the Jalisco state region.

The paper is divided into five sections as follows: Section 1 introduction and state of art, Section 2 describes the materials and methods, including details of tequilas set under study, the electronic eye hardware design, experimental setup, image analysis, and data modeling of the proposed biomimetic vision system; Section 3 reports the experimental results obtained from the proposed RGB component analysis, followed by Section 4 where it discusses and compares the key results achieved with our work compared to those reported with conventional analytical techniques. Finally, Section 5 contains the conclusion together with some directions for future work.

#### **2. Materials and Methods**

#### *2.1. Tequilas under Study*

A total of 25 samples of different brands were acquired at the local supermarket, all of them with POD, made with 100% agave and certified by Consejo Regulador del Tequila (CRT, for its acronym in Spanish) to ensure their authenticity. These samples were chosen according to the main described categories and considering that they were made in the state of Jalisco. In this way, the formed set includes 8 Silver, 12 Aged, and 5 Extra-aged tequilas. Table 1 summarizes detailed information about the tequila samples used.


**Table 1.** Tequila samples under study grouped by category.

#### *2.2. Electronic Eye System*

A single-board computer Raspberry Pi (Model 3B+, Pencoed, Wales, UK) with a Raspbian operating system was chosen as a core for developing the Electronic Eye (EE) prototype. The light source was a white Light-Emitting Diode (LED) 2xLED (Flash Module Huawei LYA-L09, Shenzhen, Guangdong, China), and a camera module (Raspberry Pi Camera V2, Pencoed, Wales, UK) with an 8 Megapixels image sensor (Sony IMX219, Minato, Tokyo, Japan) to perform the image acquisition. It also has a 7-inch Liquid Crystal Display (LCD) (Hilitand hfpq73zx89, Shenzhen, Guangdong, China) that allows interaction with the equipment through a Graphical User Interface (GUI) created in MATLAB ®2020a (MathWorks, Natick, MA, USA). The complete system is managed via Python IDLE 2.7 software, using specific routines programmed by the authors. Figure 1 shows a schematic diagram of the developed EE.

Different EE electronics parts are placed in an enclosure designed in SolidWorks 2019 and printed with a Da Vinci 3D 1.1 printer (Xyzprinting, New Taipei City, Taiwan) to operate as a PC peripheric. The design allows the light source location, camera module, and a disposable plastic UV-cuvette (BRAND, Wertheim, Germany) within a dark chamber. The cuvettes' filling volume has a range of 1.5 to 3.0 mL, with external dimensions of 4.5 mm × 23 mm that fits into an internal holder of the chamber, allowing it to be located at

a fixed distance of 30 mm from the focal plane of the image sensor of the camera. The white LED was positioned in a centered zenith plane to improve accuracy and image acquisition (this position is widely used for samples with flat surfaces) [16]. In this way, white light can propagate from the source, passes from the chamber through the sample held in a cuvette, and reaches the image sensor avoiding possible external interference. At this point, it is possible to acquire the sample's corresponding digital image. The set of images captured by the EE system were saved automatically in a USB (Universal Serial Bus) device and processed offline employing the GUI designed for this purpose.

**Figure 1.** Schematic diagram of the developed Electronic Eye showing different electronic parts assembled and communication interface used.
