## 6 Estimating Volume and Density  
The estimation of volume and density depends on the shape of the mango, which varies by region and country. Therefore, the shape is extracted before estimating its volume and density. The harvested mangoes from orchards are shown in Figure 7. These mango samples are measured by the vision machine and then weighted to generate the data. The prepared data for training models are structured data converted from image and weight signal. The estimation of volume and density consists of 3 steps. In the first step, length, width, and defect are extracted from the captured image by a camera. In the second step, the length, width, and defect are combined with the weight to create the completed dataset. Finally, the volume and density are predicted approximately based on length and width and then its errors are evaluated. The schematic of the preprocessing procedure for predicting the volume and density is shown in Figure 8.  
Figure 6: Defects of mango’s surface. Figure 7: Images taken from mangoes of one local species. The internal quality of mango is high if its density is higher than the average level. Farmers can use their experience to evaluate the internal quality by feeling the mango in their hands. The mango volume (\(V\)) has many deterministic methods such as modeling, statistical analysis based on size or weight. In this study, the volume of mangoes is calculated based on two-dimensional images because this method not only requires little resources but also has fast processing time. Since the mango has a complex shape that helps it rotate on the roller, the image processing gives images of a mango in a random orientation. In several references, there are three variables to determine the volume of mango. However, other studies [19; 20] have shown that width (_wi_) and length (_le_) are related, therefore, the volume can be determined by _wi_ and _le_ instead of three variables. The processed images allow us to extract the values of the mango length and width. In the extraction of features, the orientations of mangoes are random with \(n\) positions presented in Figure 9a. The mango is detected by a rectangle covering them based on image processing algorithms. During the sampling process, _le_ and _wi_ are extracted \(n\) times at \(n\) positions. The process of detecting mangoes and extracting _le_ and _wi_ are given in Figure 9b. In Figure 9b, two features are determined into \(n\) value pairs (_wi,le_) from _i_th mango at \(n\) positions. Experimental results show that the method is effective in mango in Vietnam. The collected data from images shows the volume depending on two variables as length (_le_), width (_wi_). An actual process to measure reality mango is carried out with variables like _le_, _wi_, and \(V\) in \(m\) samples of mango. The task is to predict the volume with the length and width. So, for the  
Figure 8: The estimation process of volume and density. Figure 9: Extracting the length and width based on directions of mango. (**a**) The mango is detected by a rectangle covering them based on image processing algorithms, (**b**) the process of detecting mangoes and extracting length and width. regression method, _le_ and _wi_ are independent variables and \(\hat{V}\) is a dependent variable that is calculated by Equation (26). \[\hat{V}=b_{0}+b_{1}le+b_{2}wi \tag{26}\]  
When predicting volume, there is always an error \(\varepsilon\). The coefficients of the variables are \(b_{0},b_{1},b_{2}\). The actual volume \(V\) is calculated in Equation (27). \[V=b_{0}+b_{1}le+b_{2}wi+\varepsilon \tag{27}\]  
To evaluate the accuracy of this regression expression, we need to make the sum of squared residuals as small as possible with the sum of squared residuals \(\Delta V\) determined by the Equation (28). \[\Delta V=\sum_{i=1}^{n}\varepsilon_{i}^{2}=\sum_{i=1}^{n}\left(V_{i}-\hat{V}_{ i}\right)^{2}=\sum_{i=1}^{n}(V_{i}-\left(b_{0}+b_{1}le_{i}+b_{2}wi_{i}\right) )^{2} \tag{28}\]  
The density which varies between mangoes is determined from volume and weight.