Real time chromametry measurement for food quality detection using mobile device

Freshness of the food is the main factor in determining the quality and safety of the consumed food and hence consumers satisfaction. Current technologies for food quality determination depend on colour changing labels to indicate the freshness level, which is subjective to human eyes. The goal of this paper is to design and develop chromatic algorithm based on RGB colour reading and correlation with pH values for real time determination of freshness level of shrimp. The results show that the developed algorithm is able to measure, analyse and display the freshness level of food directly on the screen of a mobile app technology. The mobile app is developed on Android platform and is tested in the shrimp freshness range by stating whether it is “fresh, good or spoiled”.


Introduction
Quality of food is considered to be the main parameter that determines its acceptability by the consumers [1]. Food inspection for high quality and safety assurance has been in high demand due to many factors such as strict rules of the regulatory agencies, costumers' demand for high quality food and increasing food borne illness outbreaks [2]. Richard J. Schonberger [3]stated that "quality is like art, everybody praises it, everybody recognizes it but each one has its own understanding of what it is". Freshness of is one of the main contributors to high quality of food. Many methods have been proposed to detect and ensure the freshness of food; including subjective (sensory), objective (non-sensory) methods, and smart packaging. Sensory assessment which is the most commonly used method is fast and non-destructive; however it is subjective to human senses, which might differ from person to another [4].For instance, the attribute for quality assessment of raw fish is to check the eyes, skin gills and the texture of the fish itself [5].On the other hand, non-sensory food assessment involves instrumental usage to measure physiochemical properties of food [6]. Some of the nonsensory attributes include total volatile base-nitrogen (TVB-N), trimethylamine (TMA), adenosine 5'-triphosphate (ATP) breakdown compounds, K and related values, biogenic amines, texture and total viable count (TVC) [7]. Non-sensory methods are not subjective to human senses, yet they uses only one aspect of food, hence it cannot determine the overall consumer acceptance unless correlated to the sensory assessment methods [8]. Instruments such as gas-chromatography, mass spectroscopy, colorimetry, infrared spectroscopy [9], ultrasound, x-ray, magnetic resonance imaging [2] have been used extensively to evaluate the quality of food. However, these instruments are costly, bulky, bench top instruments, and they require qualified operators. Smart packaging devices are defined as small labels or tags that are attached onto the packages of the food to indicate the food quality and safety [10]. There are two types of smart packaging devices. The first type is called data carriers like barcode labels and radio frequency identification (RFID) tags. The second type of smart packaging devices is called package indicators, which are either used to monitor environmental changes such as time-temperature indicators and gas indicators. Fadable ink for time-temperature control of food freshness has been widely used in printing labels on food packages for the freshness indication. The working principle is that, as time passes, the ink will disappear and indicating that the food is no longer fresh [11]. The label ink will react to the oxygen which will make the colour to fade with time or temperature change. The rate of color change is varied by the chemical composition used to make the ink. In a study [12] pH indicator was used to determine the freshness of shrimp, where the pH values were found to vary from pH 6.24 at fresh to pH 9.04 for the spoiled shrimp after 7 days of the storage. The aim of this paper is to design and develop chromatic algorithm based on relating pH values of spoiled shrimp to RGB values of its color change, and to implement this algorithm in mobile app technology for real time determination of the freshness level of the shrimp.

RGB data
A set of different colors were generated by computer from their corresponding RGB numbers. Then these colors were captured using smart phones, and the RGB values were re-generated and compared with their original values.

pH testing
Theoretically, the different pH values will result in different colours, which are dark purple for pH 14, green for pH 7 and red for pH1 as shown by Figure. 1.

Chromatic parameterand correlation to RGB values
The chromatic number is the main parameter used to develop the algorithm. To calculate the chromatic parameter associated with each pH value and RGB value the formula given by Eq. 1 was formulated and proposed.
where: R , G and B are RGB values obtained from the experimented pH paper, while r , g , and b are the baseline RGB values of particular pH paper. In this case the values of r , g and 1st  Figure 2 shows the computer generated (Original code) results of the 7 colors with their RGB values and the captured counterparts (Colour produced) with the RGB values after captured 3 times using smartphone. Variables such as distance between camera and the captured color and lighting levels were kept constant to avoid any inconsistencies between color captures. The colors were captured 3 times to minimize the errors which might occur due to the different lighting or quality of the camera.

Figure 2. Original colors and smartphone captured colors
It can be seen that the original colors show a slight difference compared to the captured colors.

pH testing results
The studies have been conducted using acidic and alkaline solutions with different pH levels ranges from pH 5.5 to pH 8.5. The test was performed using pH paper to observe the reaction of the pH paper with the solutions. The pH values of the different solutions were accurately measured using pH meter 700.The experiment was conducted using two types (yellow-and 4coloured) of pH papers as shown in Figure. 3 to find their reactions with the different pH solutions. From the experiments the yellow-colored pH paper gave better sensitivity for pH testing compared to the 4-coloured pH paper. The pH papers were immersed inside 6 different solutions with pH of 5.5,6, 6.5, 7, 8 and 8.5. Only the yellow-colored pH paper was used for the further studies. Figure. 4 (a to f) shows the color change of the yellow-colored pH paper for the different solutions with pH sensitivity differs with 0.5.
Above studies were conducted for pH ranging between pH 5.5 to pH 8, which is acidneutral-alkaline, to observe the sensitivity of the yellow-color pH papers. To cover wider range of acid-neutral-alkaline, different solutions with pH ranging between the pH 13 of alkaline to pH 2 of acids were investigated and the corresponding RGB values were found.   The RGB values of these different samples were found and given in Table 1, while the chromatic numbers are shown in Table 2.

Development of the chromatic algorithm and discussion
It was mentioned earlier that the fresh shrimp has a pH 6.24 while for the spoiled shrimp the pH increases to pH 9.04. The data from Table 2 suggests that based on the chromatic parameter, the pH value could be correlated to the freshness of the shrimp. It can be seen that pH 6, pH 7 and pH 8 have different numbers of chromatic parameter X ; fall under range of 78 -85, 116 -120, and 145 -155, respectively. From above values an expressions that indicates the freshness of shrimp based on the chromatic parameter could be formulated as below: pH 6: 78 < X <85 = The shrimp is fresh pH 7: 116 < X <120 = The shrimp is good pH 8: 145 < X <155 = The shrimp is spoiled Above expressions were used to design a mobile applications to assist in measuring, analyzing and displaying the correct freshness of the shrimp based on reading the RGB of the litmus paper.
Two types of Android base development have been tested for the implementation of the algorithm. Firstly, Android studio was used. Apps such as simple mathematics and camera calling were performed. Secondly, user uses MIT inventor for developing the Apps. Some simple Apps from Android Studio were generated such as camera call function and calculator. Camera calling and calculations play a significant role in developing the required App. Android Studio has been used for further developing the Apps. After a few trials of try and error, the App "real-time chromametry measurement" has been developed. The generated Apps were tested with 3 pH papers of pH 6 (fresh shrimp), pH7 (still good shrimp), and pH 8 (spoiled shrimp) to confirm that the Apps show the freshness of food based on the color of the pH paper. Figure 6 shows the results of the App from the screen of the mobile phone. From the developed algorithm and mobile App shown in the figure, it is clear that the developed algorithm is able to predict the freshness level of the shrimp. When the pH paper reads pH 6, the implemented App displays that the food is fresh, while for pH 7 the App displays that the food is still good and it displays spoiled in pH 8, though the pH paper colors of pH 7 and pH 8 looks almost the same.

Conclusion
This paper introduced chromatic algorithm for food freshness indication. The algorithm is based on chromatic parameters assigned to RGB values correlated with different pH levels, which are associated with the freshness level of the food. The algorithm was implemented in mobile App to indicate the freshness level of the food even when there is slight change on the color of the pH paper which is hard for the human eyes to see. The mobile app has been tested on yellow-colored pH papers in the shrimp freshness range by stating whether it is "fresh, good or spoiled".