## 4 Image Processing  
In this part, the vision machine is applied to the analysis of visible imaging. This process consists of 3 steps shown in Figure 5. In the first step, the images are acquired through the roller conveyor system inside the image processing chamber which is sealed and lighted. In the second step, captured images are processed by multiple algorithms such as increase fps (frames per second), image noise filter, edge detection, and boundary tracking. In the final step, length, width, and defect are extracted to generate a dataset. A reference [5] described a threshold method. The digital images are converted into binary images, then it is processed via a sequence of morphological image processing. Each frame is handled through different algorithms including filtered noise, edge detection, and boundary trace to detect objects in the images [12]. The structure of the hardware and the vision chamber are designed based on the required productivity of the system, therefore the flow of moving mango is treated continuously during its movement. During the movement of mango inside the vision chamber, the image of the mango is sent to a central processor consecutively. The sorting system should handle continuously for a certain time so mango's images are acquired in real-time. The frame rate is a factor that affects the accuracy of processing. The accuracy is proportional to the increase in frame rate. Therefore, using algorithms to increase frame rate is a suitable choice. Besides, the defect is detected from captured images, therefore depth-aware video frame interpolation [13] is used to ensure the small error estimation. The new \(i\)th frame (\(\mathrm{f_{i}}\)) is created from two adjacent frames (\(\mathrm{f_{i-1}}\)) and (\(\mathrm{f_{i+1}}\)), the value of frame rate increases to more double. The new frame is synthesized from 2 successive frames (\(\mathrm{f_{i-1}}\)) and (\(\mathrm{f_{i+1}}\)) by arbitrary-time flow interpolation [14]. The intermediate frame (\(\mathrm{f_{i}}\)) is relied on visual flow from image \(f_{(\mathrm{i-1})\rightarrow(\mathrm{i+1})}\) and image \(\mathrm{f_{(i+1)\rightarrow(i-1)}}\) in Equations (7) and (8). \[\widehat{\mathrm{f}}_{\mathrm{i\rightarrow i+1}}=(1-\mathrm{i})^{2}\mathrm{f_ {(i-1)\rightarrow(i+1)}}-\mathrm{i}(1-\mathrm{i})\mathrm{f_{(i+1) \rightarrow(i-1)}} \tag{7}\]  
\[\widehat{\mathrm{f}}_{\mathrm{i\rightarrow i-1}}=-\mathrm{i}(1-\mathrm{i}) \mathrm{f_{(i-1)\rightarrow(i+1)}}+\mathrm{i}^{2}(1-\mathrm{i})\mathrm{f_{( i+1)\rightarrow(i-1)}} \tag{8}\]  
A Gaussian filter [15] is used to solve noised image, then the boundaries of the objects are detected. The Kernel matrix slides across each row and multiply by area of the image. Let \(\mu\), \(\sigma\) be mean, variance of Gaussian distribution, respectively. \(x\) and \(y\) are two variables of Equation (9) and \(A=1/2\pi\sigma^{2}\). \[G(x,y)=Ae^{\frac{-(x-y_{y})}{2\sigma_{x}^{2}}+\frac{-(y-y_{y})^{2}}{2\sigma_{ y}^{2}}} \tag{9}\]  
After filtering the frames, the next step is to reduce the number of dimensions of the image to detect mango position. The RGB images are converted to appropriate binary image depending on the color values. Conversion from original RGB to greyscale uses NTSC method [16]. Next, conversion from grayscale to binary image based on [PERSON]'s method [17]. The threshold \(C\) separates pixels into two classes. The weighted sum of variances of the two classes \(\sigma_{w}^{2}(C)\) is defined by Equation (10). The probabilities are \(\mathrm{q_{1}}\) (Equation (11)) and \(\mathrm{q_{2}}\) (Equation (12)) which are from the \(I\) bins. Variances of the two classes are \(\sigma_{1}^{2}\) and \(\sigma_{2}^{2}\) mean. The means \(\mathrm{\mu_{1}}\) and \(\mathrm{\mu_{2}}\) of probabilities \(\mathrm{q_{1}}\) and \(\mathrm{q_{2}}\) are calculated using the Equations (13) and (14), respectively. \[\sigma_{w}^{2}(t)=q_{1}(t)\sigma_{1}^{2}+q_{2}(t)\sigma_{2}^{2} \tag{10}\]  
Figure 5: The framework of Image Processing.