# Peeling Damage Recognition Method for Corn Ear Harvest Using RGB Image
## 2 Materials and Methods
### Recognition of Corn Kernel  
In this section, we introduce the process of recognizing corn kernels that is achieved by using the correlation between the original image and the learned dictionary [35]. For this purpose, we should first train dictionaries for corn kernel, ear damage, and backgrounds. The outline of the proposed dictionary learning strategy in given in Algorithm 1. Without loss of generality, we primarily introduce the training process for corn kernels, and the methods for ear damage and backgrounds are similar. In this method, we employ a set of regions of corn kernels, containing \(3\times 10^{5}\) spatial pixels totally. Then, we reshape and normalize them into training samples. Figure 3 shows the graphical representation for the generation of kernel training samples. Specifically, let \(\mathbf{Z}\in\mathcal{R}^{3\times\xi}\) denote the normalized collection of selected samples, \(\mathbf{Z}=[z_{1},z_{2},\cdots,z_{\xi}]\), and \(\|\mathbf{z}_{t}\|_{2}=1\), \(t=1,2,\cdots,\xi\)  
Figure 2: Example on conventional image segmentation method. Each column of \(\mathbf{Z}\) denotes a sample, expressed as \(z_{t}\in\mathcal{R}^{3}=[z_{t}^{r},z_{t}^{g},z_{t}^{b}]^{T}\), where \(z_{t}^{r},z_{t}^{g}\), and \(z_{t}^{b}\) represent the reflection of the pixel in the red, green, and blue bands, respectively. These samples are used to train a dictionary, \(\mathbf{D}^{k}\in\mathcal{R}^{3\times q}\), that satisfies  
\[\forall t\in\{1,2,\cdots,\xi\},\ \|{\mathbf{D}^{k}}^{T}z_{t}\|_{\infty}\geq\epsilon, \tag{1}\]  
where \(\|\cdot\|_{\infty}\) returns the maximum absolute entry of a vector. The above constraint ensures at least one atom of the learned dictionary is correlative enough to each sample. The parameter \(\epsilon\) controls the threshold of correlation. In this study, we set \(\epsilon=0.01\). ```
0:\(\mathbf{Z}=[z_{1},z_{2},\cdots,z_{\xi}]\), \(\|z_{t}\|_{2}=1\), \(t=1,2,\cdots,\xi\), threshold \(\epsilon\). 1: Initialize \(\mathbf{D}=[]\);
2:for\(t=1\) to \(\xi\)do
3:if\(1-\|\mathbf{D}^{T}z_{t}\|_{\infty}<\epsilon\)then
4:\(\mathbf{D}=[\mathbf{D},\mathbf{z}_{t}]\);
5:endif
6:endfor
7: Learned dictionary \(\mathbf{D}\). ```  
**Algorithm 1** Proposed dictionary learning algorithm. The RGB information in the objective is regarded to be similar to that in the training samples. Therefore, we can always find an atom strongly correlative to RGB data of a core kernel pixel in objective images. Besides corn kernel, we also utilize the proposed algorithm to train dictionaries for ear damage and backgrounds, denoted as \(\mathbf{D}^{e}\) and \(\mathbf{D}^{u}\), respectively. Based this consideration, we recognize whether an arbitrary spatial pixel belongs to core kernel using Algorithm 2. We compute the correlation between \(x_{0}\) and each atom of the dictionary and find the atom that is most correlative to \(x_{0}\). If the atom belongs to \(\mathbf{D}^{k}\) and the reflection of the red band satisfies \(x^{r}>\gamma^{r}\), we then regard this pixel as corn kernel. As indicated in Step 4 of Algorithm 2, two preconditions are set to determine whether a pixel should be an alternative based on the prior information of corn kernels. The two preconditions can reduce the interference of dark backgrounds, shadow, etc. Through the above operations, the original RGB image is transformed into binary image, \(\mathbf{C}_{1}\). The recognized kernels are displayed as 1, i.e., white, while other pixels are set to be 0, i.e., black. Next, we provide an example for the proposed corn kernel recognition method. As presented in Figure 4a, a damaged ear was selected with the spatial size of \(800\times 600\) for our test. The dictionary was trained using the method given in Algorithm 1 based on \(3\times 10^{5}\) training samples. Then, we utilized  
Figure 3: Graphical representation for the generation of training samples. Algorithm 2 to recognize corn kernels.