## 4 Multi-Objective Segmentation and Localization Method for Tomato Plants
### Location of Axillary Bud Removal Points of Tomato Plants
#### 4.2.1 Fine Segmentation of Tomato Plants  
In order to achieve an accurate segmentation of tomato plants, which is crucial for the location of removal points, this study used image processing methods following the coarse identification and segmentation of tomato plants based on VGG16-UNet. The steps involved are outlined below.  
Step 1: Obtain the multi-target coarse segmentation result map of the tomato plant.  
Step 2: Convert the RGB result image obtained from the coarse segmentation to HSV color space and separate the plant region from the background.  
The HSV color space has three components: hue (\(H\)), saturation (\(S\)), and value (\(V\)). Hue represents a specific color, and using only hue can conveniently represent the distribution of colors in an image, making it simpler than the RGB model in directly describing colors [20]. After segmentation by the VGG16-UNet model, different targets of tomato plants have specific colors. By adjusting the threshold range of the HSV channels, specific color regions can be selected relatively easily without considering the complex combination of the red, green, and blue channels in the RGB color space and the weight of each component [21]. In addition, compared to the RGB model, the HSV model is more robust and less sensitive to changes in lighting conditions, which is particularly important in outdoor environments where tomato plants may be exposed to variations in sunlight. Therefore, in this experiment, the segmented mask images obtained from the VGG16-UNet semantic model are transformed from the RGB color space to the HSV color space for the subsequent extraction of the axillary regions and calculation of axillary removal points. The RGB images are separated into channels, and, after separation, each of the \(R\), \(G\), and \(B\) channels is normalized according to Equation (1) to obtain \(r\), \(g\), and \(b\).  
\[r=\frac{R}{255},g=\frac{G}{255},b=\frac{B}{255} \tag{1}\]  
Figure 6: Tomato axillary bud removal point positioning process.  
After the normalized channels (\(r,g,b\)) are obtained, they are utilized to calculate the corresponding HSV channels (\(H,S,V\)). The HSV channels are calculated as follows:  
\[V=\max \tag{2}\]  
\[S=\left\{\begin{array}{ll}\frac{\max-\min}{\max},&\text{if }\max\
eq 0\\ 0^{\circ},&\text{otherwise}\end{array}\right. \tag{3}\]  
\[H=\left\{\begin{array}{ll}0^{\circ},&\text{if }\max=\min\\ 60^{\circ}\times\frac{(g-b)}{(\max-\min)}+0^{\circ},&\text{if }\max=randg\geq b\\ 60^{\circ}\times\frac{(g-b)}{(\max-\min)}+360^{\circ},&\text{if }\max=randg<b\\ 60^{\circ}\times\frac{(b-r)}{(\max-\min)}+120^{\circ},&\text{if }\max=g\\ 60^{\circ}\times\frac{(r-g)}{(\max-\min)}+240^{\circ},&\text{if }\max=b\end{array}\right. \tag{4}\]  
The variables \(H,S\), and \(V\) represent the values of the RGB image after conversion to the HSV color space model. Here, max corresponds to the maximum value among \(r,g,\) and \(b\), while min corresponds to the minimum value among \(r,g,\) and \(b\).  
Step 3: Adjust the threshold range to achieve the separation of axillary buds of the tomato plants. The thresholds values for the three channels of \(H,S,\) and \(V\) are set to [20; 40], [100; 255], and [100; 255], respectively, to achieve axillary bud separation.  
Step 4: Morphological manipulations  
Using a 7 \(\times\) 7 cross-shaped structural element, perform erosion and dilation operations on the binary image of the axillary bud region to remove interfering points and connect adjacent areas belonging to the same shoot, thereby achieving finer segmentation of tomato plants.