# Automated Visual Identification of Foliage Chlorosis in Lettuce Grown in Aquaponic Systems
## 3 Research Methodology
### Foliage Color Detection Model Development  
The R, G, and B values of the lettuce foliage (foreground) are extracted from the segmented images. These images are represented as (\(i\)) and (\(j\)) for two classes: (\(g\)) (green foliage--no chlorosis) and (\(y\)) (yellow foliage--leaf chlorosis), respectively. The mean value of each color channel: red (\(\mu_{R}\)), green (\(\mu_{G}\)), and blue (\(\mu_{B}\)) for the two classes is computed using Equations (1) and (2). The elements of Equations (7) and (8) are determined using Equation (9) through to Equation (14). \[\mu_{g,i}=[\mu_{R,i},\mu_{G,\,i},\mu_{B,i}] \tag{7}\]  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]  
where (\(\mu_{g,i}\)) and (\(\mu_{y,j}\)) represent the mean values of the three-color channels of the foreground (lettuce foliage) of two classes. Equations (9)-(14) are used for computing the mean values of the channels. \[R_{i/j}=\sum_{1}^{n_{g,i/j}}R_{n,i/j} \tag{9}\]  
\[G_{i/j}=\sum_{1}^{n_{G,i/j}}G_{n,i/j} \tag{10}\]  
\[B_{i/j}=\sum_{1}^{n_{g,i/j}}B_{n,i/j} \tag{11}\]  
\[\mu_{R,i/j}=\frac{R_{i/j}}{n_{R,i/j}} \tag{12}\]  
\[\mu_{G,i/j}=\frac{G_{i/j}}{n_{G,i/j}} \tag{13}\]  
\[\mu_{B,i/j}=\frac{B_{i/j}}{n_{B,i/j}} \tag{14}\]  
where (\(R_{i/j}\)), (\(G_{i/j}\)), and (\(B_{i/j}\)) refer to the sum of the red, green, and blue values of lettuce foliage in two classes; (\(i/j\)) refers to either image belonging to the (\(g\)) class or (\(y\)) class; and (\(n_{R,i/j}\)), (\(n_{G,i/j}\)), and (\(n_{B,i/j}\)) represent the R, G, and B counts of lettuce foliage, respectively. The obtained background in segmented images is black. Hence, the R, G, and B counts and values of the background are not included while determining the mean value of the R, G, and B channels for the foreground. The process of calculating the mean values of the R, G, and B channels was, again, automated to save time. The values for each channel were automatically saved in an Excel file. While saving the results, it is ensured that the mean values of R, G, and B are saved for their respective image label and class category, (\(g\)) and (\(y\)). Next, the reference or threshold values ((\(g_{ref}\)) and (\(y_{ref}\))) were determined for both (\(g\)) and (\(y\)) classes, using Equations (15) and (16). To compute (\(g_{ref}\)), three average values are calculated, which are related to the mean red, mean green, and mean blue values of the images saved in the Excel file for the (\(g\)) category. The total number of mean values for each channel is (\(m\)). The first average value is obtained by summing all the green channel valuesand dividing the results by the total number of green values (\(m\)). Similarly, the second and third average values are obtained by summing all the red channel values and all blue channel values of all images in the (\(m\)) category and dividing the results by the number of red (\(m\)) and blue values (\(m\)), respectively. A similar computation is done for (\(y_{ref}\)) while considering the channel values and their count (\(l\)) for images in the (\(y\)) category. Equations (17)-(22) are used to calculate (\(g_{ref}\)) and (\(y_{ref}\)). \[g_{ref}=[\overline{x}_{R,m},\overline{x}_{G,\,m},\overline{x}_{B,m}] \tag{15}\]  
\[y_{ref}=[\overline{x}_{R,l},\overline{x}_{G,\,l},\overline{x}_{B,l}] \tag{16}\]  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]0  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]1  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]2  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]3  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]4  
\[\mu_{y,\,j}=\big{[}\mu_{R,j},\mu_{G,j},\mu_{B,j}\big{]} \tag{8}\]5  
where (\(\overline{x}_{R,m}\)), (\(\overline{x}_{G,m}\)), and (\(\overline{x}_{B,m}\)) are the averages of three channel values in the (\(g\)) category and (\(R_{m}\)), (\(G_{m}\)), and (\(B_{m}\)), are the values of three channels in the 'g' category.