# An Image Processing Method for Measuring the Surface Area of Rapeseed Pods
## 2 Materials and Methods
### Measurement Principle and Operation
#### 2.3.1 Image Processing Method
The pods should be arranged in parallel on the white cardboard, and their numbers on each whiteboard should be the same as that in principle (e.g., 40), which is convenient for later analysis. The flash function implemented in the mobile phone was used during the shooting process to acquire the image with consistent exposure. (4) Image processing. First, the rapeseed pod photos were preprocessed through image binarization transformation and denoising. The primary purpose was to facilitate the segmentation of the later image. For comparison, gray-scale and super-green transformation can be selected as image transformation, and median filtering can be selected as denoising. Second, the images were segmented to separate the background and pods. The image obtained this time was a white background, and the green of the pods and white of background were significantly different in gray scale. Therefore, the threshold method based on the gray scale was used for segmentation. Repeated comparisons indicated that the Otsu threshold segmentation and the maximum inter-class and intra-class distance  
Figure 4: Diagram of coordinate transformation points. Figure 3: The image acquisition scheme. ratio methods were the best. The intra-class variance (ICV) provided by Nobuyuki Otsu was defined as follows:  
\[ICV=PA\times(MA-M)^{2}+PB\times(MB-M)^{2} \tag{3}\]  
where \(M\) is the average of the image gray value. If any gray value \(t\) is taken, the histogram can be divided into the foreground color \(A\) and background color \(B\). The average values of the two parts were \(MA\) and \(MB\), respectively. The proportion of pixels in \(A\) and \(B\) to the total number of pixels was recorded as \(PA\) and \(PB\), respectively. This optimal threshold \(t\) was the value that maximized the _ICV_. The positions of each pod pixel set and the boundary pixel set were extracted from the pod batch. Using the transformation equation of the position of the pixel points and the actual coordinates described in step 2, the position sets of the pod and the boundary pixel points were transformed into their actual coordinates. The image processing process is shown in Figure 5.  
(5) Surface area calculation. The surface area of each pod was estimated separately, and the steps were as follows:  
A. The actual coordinates of the pod pixel set were fitted using a linear equation. B. Coordinate rotation. The actual coordinates of the pod pixel set and the boundary pixel set were rotated based on the inclination angle of the fitting line, so that the fitting  
Figure 5: Image processing process: (**a**) Image processing system interface; (**b**) Loading the network; (**c**) Image preprocessing; (**d**) Image segmentation; (**e**) Filling and removing impurities. line of the new coordinates of the pod pixel set was parallel to the horizontal line. The new coordinates of the pod pixel set and the boundary pixel set were then obtained. C. Fitting the boundary curve of the pods. The polynomial function was used to fit the pod boundary pixels (Figure 6) and the two pod boundary curves are shown below as follows:  
\[\left\{ \begin{array}{l}elu(x)=\sum\limits_{i=1}^{n}\alpha_{i}x^{i}\\ el(x)=\sum\limits_{i=1}^{n}\beta_{i}x^{i}\end{array} x\in[a,b]\right. \tag{4}\]  
where, \(a,b\) is the value range of \(x\), \(\alpha_{i}\), \(\beta_{i}\) is the corresponding \(i\)-order coefficient, and \(n\) is the maximum number of pod convex parts. The value here is 15. \(\alpha_{i}\), \(\beta_{i}\) is solved by least squares fitting. D. Calculation of the central curve of pods \(cl(x)\). The center curve of pods was calculated according to the two fitted pod boundary curves (Figure 6). The equation used to calculate the pod center curve was as Equation (5). \[cl(x)=(elu(x)+eld(x))/2 \tag{5}\]  
E. Calculation of the cross-section radius curve of the pods.