# Machine-Vision-Based Algorithm for Blockage Recognition of Jittering Sieve in Corn Harvester
## 2 Material and Method
### Algorithm of Blockage Recognition  
This subsection introduces the proposed algorithm of blockage recognition that is summarized in Algorithm 2. The blockages caused by kernels show an obvious difference with sieves in terms of RGB data, that is, the respective components of red, green, and blue bands. This is the theoretical basis of the proposed algorithm, for which we set the upper thresholds and lower thresholds, for reflectance values the three bands, respectively. The thresholds are the basis to search for kernel blockages. Specifically, for an arbitrary pixel of an objective image, expressed as \(\mathbf{x}=[x_{r},x_{g},x_{b}]=\underline{\mathbf{X}}(i,j,:)\), if all three reflectance values, \(x_{r},x_{g},x_{b}\), are within the intervals between their upper thresholds and lower thresholds, that is, \(\theta_{r}<x_{r}<\theta_{r}\) and \(\theta_{g}<x_{g}<\theta_{g}\) and \(\theta_{b}<x_{b}<\theta_{b}\), the pixel is assumed to own the similar spectral reflectance to the kernel, and it is regarded to belong to kernel blockage. For all areas of the objective image except for row edges and columns, each pixel is classified by using steps 2-9 to  
Figure 2: Process of recognizing column edges and the final dividing result. (**a**) Presentation of \(\underline{\mathbf{X}}\). (**b**) Selected maximums of \(\mathbf{e}_{col}\). (**c**) Final dividing result.  
obtain a preliminary recognizing result. In general, not all pixels of a kernel could satisfy the threshold constraint of three bands. Only part of pixels are successfully recognized in the preliminary result. Hence, we develop an expanding operation to obtain the accurate areas of blockage which is provided in steps 10-16. The extending operation is an iterative process. For each iterative cycle, all pixels that own at least \(\lambda\) neighboured pixels with the value of 2 are set to 2. Here, the value 2 indicates that the pixel belongs to the recognized blockage. The neighboured pixels of are defined as the left-upper, the upper, the right-upper, the left, the right, the left-lower, the lower, and the right-lower pixels. The number of neighboured pixels of a common pixel is 8. The numbers are 5 and 3 for the pixels in the border and corner, respectively. The termination condition to quit the iteration is the maximum number of iterative cycles is reached or the outputted results do not change any more. To clearly illustrate the proposed method, we present the flowchart in Figure 3 where the steps of two algorithms are summarized into five main processes. The matrix \(A\) is the intermediate result, and the matrix \(B\) is the final result. The example of blockage recognition that is followed by Figure 2 is presented in Figure 4 with \(\lambda=4\).  
```
0: Original RGB image \(\underline{\mathbf{X}}\in\mathcal{R}^{n_{1}\times n_{2}\times 3}\), dividing result \(A\), upper thresholds \(\vartheta_{r},\vartheta_{g},\vartheta_{b}\), lower thresholds \(\theta_{r},\theta_{g},\theta_{b}\), parameter \(\lambda\).
1: Initialize vector \(\mathbf{B}=\mathbf{A}\);
2:for every spatial point \((i,j)\)do
3:if\(\mathbf{A}(i,j)=0\)then
4: Denote \(x_{r}=\underline{\mathbf{X}}(i,j,1)\), \(x_{g}=\underline{\mathbf{X}}(i,j,2)\), \(x_{b}=\underline{\mathbf{X}}(i,j,3)\);
5:if\(\theta_{r}<x<\vartheta_{r}\) and \(\theta_{g}<x<\vartheta_{g}\) and \(\theta_{b}<x<\vartheta_{b}\)then
6:\(\mathbf{B}_{i,j}=2\);
7:endif
8:endif
9:endfor
10:while the termination condition is not reached do
11:for each pixel of \(\mathbf{B}\), \(\mathbf{B}(i,j)\)do
12:if more than \(\lambda\) of its neighboured pixels equal to 2 then
13:\(\mathbf{B}(i,j)\gets 2\);
14:endif
15:endfor
16:endwhile
17:Recognizing result \(\mathbf{B}\).
```  
**Algorithm 2**Recognizing of blockages