# An Algorithm for Obtaining 3D Egg Models from Visual Images
## 4 Results and Discussion  
The change in the basic scheme for determining the morphological characteristics of eggs is related to the use of the mass center of the egg as a starting point for further calculations. The intersection of the long and short axis of the egg does not coincide with its mass center in all cases. This modification is necessitated by the fact that in computer programs for object analysis in images, there are ready-to-use functions for finding the long axis, short axis, and mass center of the object. The adapted 3D model of an egg is:  
\[ \begin{array}{c}x=D\cdot cos\varphi\cdot sin\theta\quad c=1\ldots 22\\ y=d\cdot cos\theta\quad 0\leq\theta\leq\pi\\ z=(d+c\cdot cos\theta)\cdot sin\theta\cdot sin\varphi\quad 0\leq\varphi\leq 2\pi \end{array}  \tag{4}\]  
where \(d\), mm is the short axis of the egg; \(D\), mm--long axis of the egg; \(c\)--correction factor determining the shape of the egg. Figure 2 shows a diagram for obtaining a 3D model of an egg. Two sections were added X-Z and Y-Z, with description of the egg dimensions used in the developed algorithm. The lengths of sections '\(g\)' and '\(h\)' are determined relative to the mass center of the egg. The segment '\(g\)' has a length equal to the distance between the center of mass and the minimum value along the y axis--the point Y\({}_{2}\). In the same way, segment '\(h\)' has a length equal to the distance between the center of mass and the maximum value along the y axis--the point Y\({}_{1}\). The length of section '\(f\)', between the center of mass MC and the intersection of the long and short axes of the egg, is determined. The segment '\(e\)' is the distance between the center of mass MC and the maximum value along the Z axis--the point Z\({}_{1}\) of the egg. According to [PERSON] theorem, the segment '\(f\)' has a length:  
\[f=\sqrt{e^{2}-\left(\frac{d}{2}\right)^{2}} \tag{5}\]  
After determining the lengths of the segments, those of the acute and obtuse end of the egg are determined as:  
\[h_{1}=g-fh_{2}=h+f \tag{6}\]  
Figure 2: 3D egg model and parameters. After preliminary analyses, it was found that the correction factor '\(c\)' in the adapted three-dimensional model has a linear relationship with the ratio between the angles of the egg in the obtuse and its acute end \(c=f(\beta/\alpha)\). The resulting model, describing with sufficient accuracy this relationship, is of the form:  
\[c=159.69\frac{\beta}{\alpha}-157.4;\ R^{2}=0.96 \tag{7}\]  
Using the model to describe the three-dimensional shape of eggs in their basic forms [PERSON] et al. (2017), the correction coefficient assumes values of \(c=1\)-22. The developed algorithm for obtaining three-dimensional egg models from color digital images is linear. Table 1 shows the steps of the algorithm in descriptive form and in pseudocode. The loaded image has been converted to RGB by HSV. The S(HSV) color component was used. After removing the openings and filtering, the coordinates of the egg center, large and small axis, were obtained with the _regionprops_ function. \(H_{1},h_{2}\) were determined and the angles at the acute and obtuse ends of the egg \(\alpha\), \(\beta\) were calculated. Based on the model obtained, the correction factor '\(c\)' was calculated. \(D1\), \(d1\) are the long and short axes of the egg, X, X1 are used for determination of coordinates needed for calculation of \(h1\) and \(h2\). The coordinates of the 3D model of the egg were determined and it was rendered. As a result of the visualization (Figure 3), the influence of coefficient 'c' on the surface formation of egg models was established. The low values of this coefficient result in an elliptical and oval shape. As the values of this coefficient increase, the ovoid shape of the obtained three-dimensional objects is observed.