# An Automatic Tomato Growth Analysis System Using YOLO Transfer Learning
## 3 System Design
### Image Analysis System
#### 3.2.6 Measurement of Stem Diameter in Pixels  
We proposed a novel method for measuring stem diameter. It involves measuring the distance between a line segment on one side edge of the stem and a line segment on the opposite side edge. We use line-to-line distance measurement instead of point-to-point distance measurement. This increases accuracy and reduces the number of inaccurate results. The process aims to obtain a set of pairs of opposite sides suitable for stem diameter measurement. The process for measuring stem diameter in pixels is outlined in the following steps:  
1. Apply a Gaussian filter to the binary image to suppress noise, then detect stem contours using a Laplacian filter. 2. Find the contours of the stem as a continuous line connected in eight neighborhoods and list them in pixels. 3. Divide the contour into two parts on both sides of the stem. 4. Extract feature points using two methods to vectorize the contour. 5. Vectorize feature points as endpoints and obtain contour segments of a certain length or longer as line segments. 6. Calculate the stem diameters by corresponding the stem contour segments with the stem contour segments on the opposite side. 7. Cluster the stem diameters of the corresponding contour segments. 8. Take a weighted average and calculate the stem diameter with the length of the overlap for each cluster. 9. Calculate the correctness score of the stem diameter for each cluster, and the stem diameter of the cluster with the highest score is the measured stem diameter. In step 3, if a single contour is obtained, the contour is divided by the point farthest from the starting point of the list. Additionally, in the case of obtaining two or more contours, the longest two are obtained in terms of length (number of pixels), and the ratio of the length is taken from the one with the larger ratio to the other one when the ratio is greater than 0.7. This is because the lengths of both sides of the stem are generally similar values, and if the ratio is greatly different, there is a possibility of measuring the wrong location and it is necessary to eliminate it. In step 4, feature points are placed at points of high curvature. Specifically, the entire stem contour is scanned, and feature points are assigned when the angle between the  
Figure 8: Image of the ‘target stem’ part (**left**) and contour extraction result by DeepLabv3+ (**right**). midpoint of the interval and the endpoints of the interval is less than a certain angle in a certain short interval. Feature points of the other type are placed at points that divide loose curves longer than a certain length. Specifically, the entire stem contour is scanned, and when the average distance between a point between two points and the line connecting the two points exceeds a certain distance, the point farthest from the line is assigned as the feature point. Together with operation in step 5, the former feature point is used to extract the appropriate stem contour by excluding parts that do not look like the stem contour. The latter feature point is intended to improve the accuracy of stem diameter measurement in the presence of loose curves. In step 5, contour segments of greater than a certain length are vectorized by projecting the endpoints on the line with the smallest sum of the squared distances. In step 6, a distance between the line segments is calculated by a unique method and used as the stem diameter. Two segments of the stem contour are taken from each side and normalized to obtain two direction vectors. From the two direction vectors, we calculate the mean vector and the vector orthogonal to it. The segments of the stem contour are projected onto the mean vector, and when there is overlap and the angle formed by the two original vectors is less than a certain angle (the segments of the two contours are almost parallel), it is considered that the segments of the stem contour correspond to each other.