# 2D In Situ Method for Measuring Plant Leaf Area with Camera Correction and Background Color Calibration

Authors: Li-fen Tu; Qi Peng; Chun-sheng Li; Aiqun Zhang
Journal: Scientific Programming
 (2021)

---

## Abstract

In order to measure the plant leaf area conveniently and quickly in an indoor laboratory and outdoor field, a set of scaffold leaf area measurement systems was designed and manufactured. A 2D in situ method for measuring plant leaf area with camera correction and background color calibration was proposed. The method integrates three subalgorithms: fast calibration and distortion correction algorithm, background color calibration algorithm, and edge error correction algorithm. At the same time, the Visual Studio 2015 and OpenCV 3.4.0 were used to develop and test the algorithm. In order to verify the measurement speed and environmental adaptability of the system, the test was carried out in the complex light disturbance outdoors, and the results were consistent with those in the room. In order to verify the measurement accuracy of the system, this method was used to measure the standard rectangular gauge block of known area and the real leaf area, respectively, and its data were compared with the data measured by Wanshen LA-S plant image analyzer. The results show that both methods have a good stability, and the algorithm proposed in this paper performs better in measurement accuracy and environmental adaptability.


---

## Body

## 1. Introduction

The leaf is the main organ of plant photosynthesis, and leaf area is an important factor in measuring plant photosynthesis and other plant mechanisms. Accurate measurement of leaf area for plant growth and the interaction between the plant and the growing environment have an important significance. The measurement accuracy and reliability of plant leaf area have been greatly improved from the original traditional method to the computer image processing technology.The method of using computer technology to measure leaf area can be roughly divided into photoelectric scanning method [1–3], three-dimensional point cloud method [4–7], and image measurement method [8, 9]. Using optoelectronic devices, such as scanners to scan the leaf, the quality of the acquired image data is high; especially when the image background is pure white, high-precision measurement results can be obtained with a relatively simple algorithm. However, this type of equipment is relatively large and suitable for use in the laboratory. Moreover, it is difficult to preserve the leaves in the way of picking and transporting them back to the laboratory. The loss of water causes the leaves to shrink and curl, resulting in measurement errors. Therefore, the photoelectric scanning method is difficult to measure leaf area in outdoor farmland. Using TOF equipment such as Kinect, Lidar, and other equipment to obtain the three-dimensional point cloud information of plants and then analyzing the phenotype information is a relatively professional leaf area measurement method at present. In literature [4], ground-based Lidar equipment was used to obtain three-dimensional point clouds of deciduous trees, and then image segmentation technology was used to segment dense overlapping leaves and calculate the morphology of leaves. The difficulty of this method lies in accurately segmenting a single leaf. Literature [5] conducted a detailed study on leaf segmentation technology and proposed a segmentation algorithm for plant point clouds to remove overlapping leaves, which achieved a good segmentation effect. Moreover, the parameter adaptability of this method was general, and the algorithm complexity was high. The multiview [6] method can effectively overcome the problem of leaf overlap, and its cost is lower compared with that of professional Lidar. Such a method has a better measurement performance for indoor small-volume plants, but it is more difficult to use outdoors. The use of Kinect combined with robot technology can obtain plant phenotype information in outdoor farmland [7], which can conveniently and quickly estimate the leaf area of corn plants. However, compared with image measurement method, the construction and operation of the overall robot platform are more complicated and costly. The traditional image measurement method is a relatively convenient method. The hardware equipment is low in cost and easy to promote, but it is easily affected by environmental factors. For example, a method of using a mobile phone to measure leaf area [10, 11] can obtain leaf area in real time in the field, but the whole system does not carry out high-precision calibration, resulting in large distortion and easy introduction of measurement error. In literature [12, 13], Hough transform was used to carry out geometric correction on the image and improve the measurement accuracy, but the elimination of ambient light interference was not carried out. When used in outdoor farmland, especially under the interference of complex environmental illumination, the color of the leaf itself is deviated during the image acquisition process, resulting in measurement errors in color model processing algorithms such as RGB [14]. Literature [15] studied the sensitivity of the color components of the HIS, HSV, and RGB models of the Nicotiana tabacum leaf image to the light intensity under different light intensities. It can be seen that it is feasible to further study and improve the processing algorithm based on the color model. Literature [16] proposed a classic color correction method, which used histogram to correct the color difference between two images in panoramic image stitching, thus improving the detection accuracy. In addition, the outdoor environment light intensity is different, which will cause shadow interference [17, 18], resulting in inaccurate leaf edge extraction and segmentation, which will result in measurement errors.In this paper, it is necessary to measure the plant leaf area with high precision in real-time and on-site in a farmland environment. Due to the limitation of hardware cost, this paper improves both the hardware and software of the traditional image measurement method and designs and produces a set of scaffold leaf area measurement system. Firs, Zhang’s calibration method [19] is introduced, and the system is quickly calibrated using a small, high-precision aluminum checkerboard. At the same time, the distortion correction algorithm [20] is used to correct the image of the pincushion distortion. Then, the color calibration algorithm proposed in this paper is used to compensate the background image of the measurement area disturbed by complex illumination and restore it to an ideal all-white background. Next, the image is converted to HSV color space, the saturation S is used as the color feature vector of the leaf, and the S channel is extracted to obtain the leaf area. Finally, in order to overcome the influence of edge blur on high-precision leaf area measurement, the relationship between leaf edge contour length and area is studied, and a leaf area measurement error correction algorithm is proposed to further improve the measurement accuracy of leaf area.In order to verify the effectiveness of this method, three groups of experiments were set up: the first group of experiments verified the system's measurement speed and environmental adaptability. The method was used to measure the leaf area outdoors in real time and compared it with the test results in the laboratory. The second and third groups of experiments were used to verify the accuracy and stability of the algorithm. The second group of experiments used standard gauge blocks as the measurement objects, and the third group of experiments usedPlatanus orientalis leaves, Ligustrum lucidum leaves, and Ligustrum quihoui leaves as measurement objects. The method presented in this paper and Wanshen LA-S plant image analyzer were used to measure the leaf area, respectively, and the measurement errors of the two methods were compared and analyzed. The experimental results show that both of the two methods have good stability, and the algorithm proposed in this paper has better performance in measurement accuracy and environmental adaptability.


## 2. Materials and Methods

### 2.1. Image Acquisition

#### 2.1.1. Hardware Device

In order to collect the required plant leaf image, a prototype leaf area measuring instrument was made to capture the leaf image and calculate the leaf area, as shown in Figure1. Figure 1(a) is the structural diagram of the leaf area measuring instrument, and Figure 1(b) is the physical diagram of the leaf area measuring instrument.Figure 1
Leaf area measuring instrument. (a) Structure diagram. (b) Physical diagram.
(a)(b)The measuring instrument device consists of two fixed plates A, one of which is a wooden base plate, a transparent plate that can slide up and down; two sliding shafts B for fixing the transparent plate on the left and right; a diamond-shaped hollow spotlight bracket C. The plate slot ① is used to fix the wooden bottom plate, on which a piece of A4 white paper is pasted as the background of the measured leaf, and the leaf to be measured is placed on the white paper. During transportation or use, if the camera moves, it needs to be recalibrated. The calibration board can be placed directly on the white paper. The transparent acrylic plate ② can slide up and down, is used to flatten the leaf and improve measurement accuracy, and has a strong light transmission. Four illuminating devices are fixed around the diamond ③. This system adopts LED supplementary light with built-in lithium battery, which is convenient for the equipment to collect leaf images normally even in dimly lit places. The four lights are arranged diagonally to reduce shadows. The middle hollow part ④ is used to place the image acquisition equipment. The Hikvision DS-2CD2401FD-IW network camera is selected. The camera is inexpensive and can be connected to an external lithium battery. The collected leaf images are transmitted to the notebook computer via WIFI, avoiding the inconvenience caused by excessive cables.


#### 2.1.2. Measurement Software

In order to verify the effectiveness of the method, an experimental platform was built, a self-made leaf area measuring instrument was developed, and measurement software was written, and the research results were applied to production practice, as shown in Figure2. Figure 2(a) is the software function structure diagram, and Figure 2(b) is the software interface diagram.Figure 2
Measuring software. (a) Functional structure diagram. (b) Interface diagram.
(a)(b)The software was developed on the basis of the four-rotor-based farmland image information acquisition software V1.0 (software copyright registration number: 2017SR506238), written by the author of this article, and the leaf area measurement function is added. The software contains Hikvision web camera login module, used to connect web camera. The image can be collected in real time after successful connection, including real-time display, video recording, and capture. After successfully capturing the image, the image will be saved to the specified folder. By loading several continuous images for image stitching, a large-scale farmland image can be synthesized. Leaf area can be measured by loading a single leaf image.For the measurement of leaf area, first place the calibration plate, and use the capture function to collect 20 calibration plate images with different orientations, and the software will automatically save them into the corresponding folder. Click the “distortion calibration” button to automatically calculate the camera calibration parameters and distortion correction parameters. Then, click the “parameter setting” button to make the parameter setting dialog box pop up, and fill in the camera calibration and distortion correction parameters, the upper left corner coordinates and length and width values of the measurement area drawn by the white paper, and the real area value of the measurement area. Under the current measurement environment, click the “capture” button to collect an image of a blank background and click the “color calibration” button. The software will calculate the lighting parameters and color parameters under the current environment. Finally, the “capture” button is used to collect the leaf image, and the “load picture” button is used to load the image, and the “measure” button is used to complete the measurement of leaf area.


### 2.2. Measurement Method

#### 2.2.1. Overall Flow of the Measurement Algorithm

In order to accurately measure the plant leaf area using a low-cost network camera, the calibration technique in the fixed area is studied to correct the distortion of the network camera. In order to overcome the complex outdoor light interference, the background color calibration technology is mainly studied, so that the high-precision leaf area measurement can be performed both indoors and outdoors. The influence of S-channel properties on leaf image segmentation in HSV color model and the influence of edge blur on high-precision leaf area measurement are studied in detail. The overall algorithm flow is shown in Figure3.Figure 3
The overall algorithm flowchart.The whole algorithm consists of four modules. The first is the main process module of leaf area measurement. First, the Hikvision network camera SDK development kit related function is called to collect the image and save it as jpg format. Then, use the calibration parameters for distortion correction. Next, the measurement area is cut; that is, the ROI area is extracted. According to the difference matrix obtained by color calibration, the current region image and the difference matrix are merged. Then, RGB is converted into the HSV color model, and the S channel is extracted, and then the Gaussian filtering is performed to eliminate the noise. The nonbackground pixels are judged according to the threshold parameters, and the number is calculated. The leaf area is calculated according to preset parameters. Finally, error correction is performed.The second is the distortion correction module, which can choose offline or online calibration by using Zhang Zhengyou calibration method. The calculated calibration parameters are written into the configuration file for the distortion correction module to call. The third is the color calibration module. Before preparing to start measuring the leaf area, first collect a blank background image under the current illumination state, correct it with the distortion correction module, and extract the ROI area. Then, analyze the brightness and RGB values of the area. Next, make a difference with the ideal all-white background, save the difference parameters, and construct the difference matrix for the image fusion module to use. The fourth is the error correction module. After Gaussian filtering, the contour of the circumscribed rectangle of the measured leaf in the image is obtained, the relationship between the edge and the area is analyzed, and the error correction parameter is calculated for use by the error correction module.


#### 2.2.2. Distortion Correction Algorithm

The low-cost network camera image distortion is large, and high-precision distortion correction is needed. In this paper, Zhang Zhengyou calibration method is used to calibrate the camera internal parameter matrix and distortion coefficient. The network camera model is described using(1)sm=AR,tM,where s is the scale factor, m is the image two-dimensional coordinate vector, A is the internal parameter matrix of the camera to be obtained, R,t is the external parameter matrix of the camera, which is the rotation matrix R and the translation matrix t, respectively, and M is the three-dimensional coordinate vector of the object. The expansion is shown as(2)suv1=Ar1r2r3tXYZ1=Ar1r2tXY1=∝ru00βv0001r1r2tXY1.Since the leaf area measuring instrument studied in this paper measures the leaf on one plane,Z = 0 can be set to simplify the above formula (2). Find the parameter matrix A in the camera; that is, find the five parameters in the matrix. In order to obtain high-precision calibration parameters, the calibration plate is placed on the leaf measurement plane, and 20 pictures of different rotation angles and translation positions are collected arbitrarily. The constraint conditions are used to solve the problem according to Zhang Zhengyou’s calibration method.Next, using the above 20 calibration plate pictures, the distortion equation (3) is selected to solve the radial distortion parameter k1,k2,k3 and the tangential distortion parameter p1,p2:(3)x,y,=1+k1r2+k2r4+k3r6xy+2p1xy+p2r2+2x22p1r2+2y2+2p2xy,r2=x2+y2.In the formula,x,y, is the position after distortion, and xy is an ideal position where no distortion occurs.Since the positions of the corner points of the checkerboard calibration plate are known, a set of equations can be constructed according to (3) to solve the five distortion parameters. According to the aforementioned algorithm, the software introduced in Section 2.1.2 automatically solves the parameter matrix A and the five distortion parameters in the camera and writes them into the parameter file. After collecting the leaf image to be measured, the image is corrected according to the stored parameters.


#### 2.2.3. Color Calibration Algorithm

By comparing the mobile phone type and photoelectric scanning type leaf area measuring instrument, it is found that the high measurement accuracy of the photoelectric scanning type device is largely due to the simple background without complex light interference, and the obtained background image of the leaf image has a gray value of 255 pure white image. Inspired by this, this paper proposes a color calibration algorithm to compensate the background by light interference and restore it to a pure white background image with a gray value of 255.First, collect a blank background image in the current measurement environment and use it as the image to be measured for distortion correction and measurement area extraction. The distortion correction adopts the method in Section2.2.2, as shown in Figure 2(b). The measurement area is a rectangular area drawn by a pencil. The coordinates of the upper left corner of the area and the length and width values are obtained manually, and then the parameters are entered to set the dialog box. Assuming that the acquired blank background image is matrix BR, the matrix can be decomposed into BR=BI+N, where BI is an ideal all-white background image with a gray value of 255 and N is the illumination interference parameter matrix under the current environment. After distortion correction and measurement region extraction, a new image matrix BR, is obtained; that is BR,=HBR. Perform RGB color and brightness analysis on equation BR,, which can be decomposed into(4)BR,=BI,+ND,⟹RRGRBRVR=M255M255M255M255−RDGDBDVD,where ND, is the corrected illumination interference matrix in the measurement region, which can be equivalent to the difference matrix D, calculated by (5)D=RDGDBDVD=M255M255M255M255−RRGRBRVR.Next, the difference matrixD is merged with the leaf image to be measured, collected under the current environment. The image of the leaf to be measured can be described as(6)MR=MI+N⟹BR∪LR=BI+NB∪LI+NL,where MI is the ideal image matrix, N is the light interference matrix, the leaf image matrix MR to be measured can be decomposed into the union of the background image matrix BR and the leaf image matrix LR, NB is the interference of light on the background, NL is the interference of light on the leaves, and BI and LI are the matrices under ideal conditions.After applying the same distortion correction and region extraction forMR, MR, is obtained. The difference matrix D is fused into the matrix MR,, as follows:(7)MRf=MR,+D=BR,+DB∪LR+DL=BI,∪LR+DL=M255M255M255M255∪LI+NL+DL,BR, is a set of background pixels after distortion correction and region extraction, fusion of background difference matrix DB, and substituting formula (5) to restore the set of background pixels to an ideal all-white background BI,, the gray value is 255. The set of leaf pixels to be tested is LI+NL+DL, where LI is the ideal set of leaf pixels not disturbed by light, NL is the light interference matrix, and DL is the difference matrix.The aforementioned color image is converted from RGB to HSV space. As can be seen from the HSV and RGB conversion tables, for whiteH∈0,180S∈0,30V∈221,255, other nonblack and gray color S channel values range from 43,255. For the leaves, most of them are green, and some are red, yellow, and so on. There are very few black and gray colors. Regardless of the rare case, the algorithm in this paper selects the S channel. MRf in (7) is filtered by (8), and (9) can be obtained:(8)HM=0,S∈0,30sRf,S∈31,255,(9)Mf=HMRf=HBI,∪LI+NL+DL=M0∪sRf.Equation (8) indicates that when the saturation S value is less than 30, it can be considered as a white background, and the pixel value is assigned to 0. When the S value is greater than 30, the S value of the original pixel sRf is retained. After the fusion matrix MRf in (7) is filtered by (8), the restored ideal all-white background set BI, has a pixel value of 255, so it is assigned as an all-zero matrix M0. The set pixel value of the leaf is the original S value sRf, and the range is [31, 255]. In this way, the leaf is separated from the background by overcoming the illumination interference.Next, in order to eliminate the influence of discrete noise points, Gaussian filtering with 3 × 3 template is used for image smoothing. Then, the nonbackground pixels in the image are judged and counted. Finally, the leaf area is calculated in the traditional way.


#### 2.2.4. Edge Error Correction Algorithm

By measuring the standard rectangular measuring block, it is found that the measuring block with a smaller area has a higher accuracy, and the larger the area, the greater the deviation of the measured value. Zoom in and observe the leaf image after Gaussian blurring, as shown in Figure4.Figure 4
Leaf edge blur.It can be seen that the edge of the leaf is blurred due to optical diffusion. The longer the circumference is (when the leaf is larger), the more the pixels are blurred by optical diffusion. It affects the judgment of nonbackground pixels, so that the background pixels close to the edge of the leaf are also included in the nonbackground pixels, thus resulting in a large statistical error in the number of pixels on the leaf. Aiming to solve this problem, this paper proposes an edge error correction algorithm.Assuming that the pixels of the image sensor are square, the side length of each pixel is first calculated using(10)Lpixel=SW×H,where S is the area of the entire measurement area obtained by manual measurement, and the unit is mm2. W and H are the width and height of the measurement area in the image respectively, and the unit is pixel.Calculate the circumscribed rectangle of the leaf image after Gaussian filtering. Assuming that the blurred pixels caused by optical diffusion are uniformly distributed around the periphery of the real edge of the leaf, the circumference of the circumscribed rectangle can be set toC, and the increased area of the outer edge of the leaf is ΔS, and the following can be obtained:(11)ΔS=N×Lpixel2=N×Lpixel×Lpixel=a×C×Lpixel,where N is the number of pixels distributed around the true edge of the leaf in one circle, Lpixel2 is the area of a single pixel, and a is the relation coefficient between the perimeter of the leaf edge N×Lpixel and the perimeter of the circumscribed rectangle C.The extraction of the leaf edge is greatly affected by the color saturationS value, the target background gradient value, and different algorithms. Therefore, the algorithm in this paper selects a relatively stable circumscribed rectangular frame to describe the leaf boundary, which is effective for most leaf shapes. However, for the leaves with approximately hollow shapes in the middle, such as the leaves of Liriodendron chinense, the error is large. Considering that there is a certain difference between the edge circumference of the leaf and the circumference of the circumscribed rectangle, the relational coefficient a is set to obtain the empirical value based on several standard rectangular block measurement experiments:(12)a=0.25,l1≤10mml2≤50mm,0.80,l1≤20mml2≤50mm,1.50,other.The final area of the leaf after error correction can be obtained by subtracting the increased area of the leaf periphery calculated according to formulas (11) and (12) from the area of the leaf calculated according to Section 2.2.3.


## 2.1. Image Acquisition

### 2.1.1. Hardware Device

In order to collect the required plant leaf image, a prototype leaf area measuring instrument was made to capture the leaf image and calculate the leaf area, as shown in Figure1. Figure 1(a) is the structural diagram of the leaf area measuring instrument, and Figure 1(b) is the physical diagram of the leaf area measuring instrument.Figure 1
Leaf area measuring instrument. (a) Structure diagram. (b) Physical diagram.
(a)(b)The measuring instrument device consists of two fixed plates A, one of which is a wooden base plate, a transparent plate that can slide up and down; two sliding shafts B for fixing the transparent plate on the left and right; a diamond-shaped hollow spotlight bracket C. The plate slot ① is used to fix the wooden bottom plate, on which a piece of A4 white paper is pasted as the background of the measured leaf, and the leaf to be measured is placed on the white paper. During transportation or use, if the camera moves, it needs to be recalibrated. The calibration board can be placed directly on the white paper. The transparent acrylic plate ② can slide up and down, is used to flatten the leaf and improve measurement accuracy, and has a strong light transmission. Four illuminating devices are fixed around the diamond ③. This system adopts LED supplementary light with built-in lithium battery, which is convenient for the equipment to collect leaf images normally even in dimly lit places. The four lights are arranged diagonally to reduce shadows. The middle hollow part ④ is used to place the image acquisition equipment. The Hikvision DS-2CD2401FD-IW network camera is selected. The camera is inexpensive and can be connected to an external lithium battery. The collected leaf images are transmitted to the notebook computer via WIFI, avoiding the inconvenience caused by excessive cables.


### 2.1.2. Measurement Software

In order to verify the effectiveness of the method, an experimental platform was built, a self-made leaf area measuring instrument was developed, and measurement software was written, and the research results were applied to production practice, as shown in Figure2. Figure 2(a) is the software function structure diagram, and Figure 2(b) is the software interface diagram.Figure 2
Measuring software. (a) Functional structure diagram. (b) Interface diagram.
(a)(b)The software was developed on the basis of the four-rotor-based farmland image information acquisition software V1.0 (software copyright registration number: 2017SR506238), written by the author of this article, and the leaf area measurement function is added. The software contains Hikvision web camera login module, used to connect web camera. The image can be collected in real time after successful connection, including real-time display, video recording, and capture. After successfully capturing the image, the image will be saved to the specified folder. By loading several continuous images for image stitching, a large-scale farmland image can be synthesized. Leaf area can be measured by loading a single leaf image.For the measurement of leaf area, first place the calibration plate, and use the capture function to collect 20 calibration plate images with different orientations, and the software will automatically save them into the corresponding folder. Click the “distortion calibration” button to automatically calculate the camera calibration parameters and distortion correction parameters. Then, click the “parameter setting” button to make the parameter setting dialog box pop up, and fill in the camera calibration and distortion correction parameters, the upper left corner coordinates and length and width values of the measurement area drawn by the white paper, and the real area value of the measurement area. Under the current measurement environment, click the “capture” button to collect an image of a blank background and click the “color calibration” button. The software will calculate the lighting parameters and color parameters under the current environment. Finally, the “capture” button is used to collect the leaf image, and the “load picture” button is used to load the image, and the “measure” button is used to complete the measurement of leaf area.


## 2.1.1. Hardware Device

In order to collect the required plant leaf image, a prototype leaf area measuring instrument was made to capture the leaf image and calculate the leaf area, as shown in Figure1. Figure 1(a) is the structural diagram of the leaf area measuring instrument, and Figure 1(b) is the physical diagram of the leaf area measuring instrument.Figure 1
Leaf area measuring instrument. (a) Structure diagram. (b) Physical diagram.
(a)(b)The measuring instrument device consists of two fixed plates A, one of which is a wooden base plate, a transparent plate that can slide up and down; two sliding shafts B for fixing the transparent plate on the left and right; a diamond-shaped hollow spotlight bracket C. The plate slot ① is used to fix the wooden bottom plate, on which a piece of A4 white paper is pasted as the background of the measured leaf, and the leaf to be measured is placed on the white paper. During transportation or use, if the camera moves, it needs to be recalibrated. The calibration board can be placed directly on the white paper. The transparent acrylic plate ② can slide up and down, is used to flatten the leaf and improve measurement accuracy, and has a strong light transmission. Four illuminating devices are fixed around the diamond ③. This system adopts LED supplementary light with built-in lithium battery, which is convenient for the equipment to collect leaf images normally even in dimly lit places. The four lights are arranged diagonally to reduce shadows. The middle hollow part ④ is used to place the image acquisition equipment. The Hikvision DS-2CD2401FD-IW network camera is selected. The camera is inexpensive and can be connected to an external lithium battery. The collected leaf images are transmitted to the notebook computer via WIFI, avoiding the inconvenience caused by excessive cables.


## 2.1.2. Measurement Software

In order to verify the effectiveness of the method, an experimental platform was built, a self-made leaf area measuring instrument was developed, and measurement software was written, and the research results were applied to production practice, as shown in Figure2. Figure 2(a) is the software function structure diagram, and Figure 2(b) is the software interface diagram.Figure 2
Measuring software. (a) Functional structure diagram. (b) Interface diagram.
(a)(b)The software was developed on the basis of the four-rotor-based farmland image information acquisition software V1.0 (software copyright registration number: 2017SR506238), written by the author of this article, and the leaf area measurement function is added. The software contains Hikvision web camera login module, used to connect web camera. The image can be collected in real time after successful connection, including real-time display, video recording, and capture. After successfully capturing the image, the image will be saved to the specified folder. By loading several continuous images for image stitching, a large-scale farmland image can be synthesized. Leaf area can be measured by loading a single leaf image.For the measurement of leaf area, first place the calibration plate, and use the capture function to collect 20 calibration plate images with different orientations, and the software will automatically save them into the corresponding folder. Click the “distortion calibration” button to automatically calculate the camera calibration parameters and distortion correction parameters. Then, click the “parameter setting” button to make the parameter setting dialog box pop up, and fill in the camera calibration and distortion correction parameters, the upper left corner coordinates and length and width values of the measurement area drawn by the white paper, and the real area value of the measurement area. Under the current measurement environment, click the “capture” button to collect an image of a blank background and click the “color calibration” button. The software will calculate the lighting parameters and color parameters under the current environment. Finally, the “capture” button is used to collect the leaf image, and the “load picture” button is used to load the image, and the “measure” button is used to complete the measurement of leaf area.


## 2.2. Measurement Method

### 2.2.1. Overall Flow of the Measurement Algorithm

In order to accurately measure the plant leaf area using a low-cost network camera, the calibration technique in the fixed area is studied to correct the distortion of the network camera. In order to overcome the complex outdoor light interference, the background color calibration technology is mainly studied, so that the high-precision leaf area measurement can be performed both indoors and outdoors. The influence of S-channel properties on leaf image segmentation in HSV color model and the influence of edge blur on high-precision leaf area measurement are studied in detail. The overall algorithm flow is shown in Figure3.Figure 3
The overall algorithm flowchart.The whole algorithm consists of four modules. The first is the main process module of leaf area measurement. First, the Hikvision network camera SDK development kit related function is called to collect the image and save it as jpg format. Then, use the calibration parameters for distortion correction. Next, the measurement area is cut; that is, the ROI area is extracted. According to the difference matrix obtained by color calibration, the current region image and the difference matrix are merged. Then, RGB is converted into the HSV color model, and the S channel is extracted, and then the Gaussian filtering is performed to eliminate the noise. The nonbackground pixels are judged according to the threshold parameters, and the number is calculated. The leaf area is calculated according to preset parameters. Finally, error correction is performed.The second is the distortion correction module, which can choose offline or online calibration by using Zhang Zhengyou calibration method. The calculated calibration parameters are written into the configuration file for the distortion correction module to call. The third is the color calibration module. Before preparing to start measuring the leaf area, first collect a blank background image under the current illumination state, correct it with the distortion correction module, and extract the ROI area. Then, analyze the brightness and RGB values of the area. Next, make a difference with the ideal all-white background, save the difference parameters, and construct the difference matrix for the image fusion module to use. The fourth is the error correction module. After Gaussian filtering, the contour of the circumscribed rectangle of the measured leaf in the image is obtained, the relationship between the edge and the area is analyzed, and the error correction parameter is calculated for use by the error correction module.


### 2.2.2. Distortion Correction Algorithm

The low-cost network camera image distortion is large, and high-precision distortion correction is needed. In this paper, Zhang Zhengyou calibration method is used to calibrate the camera internal parameter matrix and distortion coefficient. The network camera model is described using(1)sm=AR,tM,where s is the scale factor, m is the image two-dimensional coordinate vector, A is the internal parameter matrix of the camera to be obtained, R,t is the external parameter matrix of the camera, which is the rotation matrix R and the translation matrix t, respectively, and M is the three-dimensional coordinate vector of the object. The expansion is shown as(2)suv1=Ar1r2r3tXYZ1=Ar1r2tXY1=∝ru00βv0001r1r2tXY1.Since the leaf area measuring instrument studied in this paper measures the leaf on one plane,Z = 0 can be set to simplify the above formula (2). Find the parameter matrix A in the camera; that is, find the five parameters in the matrix. In order to obtain high-precision calibration parameters, the calibration plate is placed on the leaf measurement plane, and 20 pictures of different rotation angles and translation positions are collected arbitrarily. The constraint conditions are used to solve the problem according to Zhang Zhengyou’s calibration method.Next, using the above 20 calibration plate pictures, the distortion equation (3) is selected to solve the radial distortion parameter k1,k2,k3 and the tangential distortion parameter p1,p2:(3)x,y,=1+k1r2+k2r4+k3r6xy+2p1xy+p2r2+2x22p1r2+2y2+2p2xy,r2=x2+y2.In the formula,x,y, is the position after distortion, and xy is an ideal position where no distortion occurs.Since the positions of the corner points of the checkerboard calibration plate are known, a set of equations can be constructed according to (3) to solve the five distortion parameters. According to the aforementioned algorithm, the software introduced in Section 2.1.2 automatically solves the parameter matrix A and the five distortion parameters in the camera and writes them into the parameter file. After collecting the leaf image to be measured, the image is corrected according to the stored parameters.


### 2.2.3. Color Calibration Algorithm

By comparing the mobile phone type and photoelectric scanning type leaf area measuring instrument, it is found that the high measurement accuracy of the photoelectric scanning type device is largely due to the simple background without complex light interference, and the obtained background image of the leaf image has a gray value of 255 pure white image. Inspired by this, this paper proposes a color calibration algorithm to compensate the background by light interference and restore it to a pure white background image with a gray value of 255.First, collect a blank background image in the current measurement environment and use it as the image to be measured for distortion correction and measurement area extraction. The distortion correction adopts the method in Section2.2.2, as shown in Figure 2(b). The measurement area is a rectangular area drawn by a pencil. The coordinates of the upper left corner of the area and the length and width values are obtained manually, and then the parameters are entered to set the dialog box. Assuming that the acquired blank background image is matrix BR, the matrix can be decomposed into BR=BI+N, where BI is an ideal all-white background image with a gray value of 255 and N is the illumination interference parameter matrix under the current environment. After distortion correction and measurement region extraction, a new image matrix BR, is obtained; that is BR,=HBR. Perform RGB color and brightness analysis on equation BR,, which can be decomposed into(4)BR,=BI,+ND,⟹RRGRBRVR=M255M255M255M255−RDGDBDVD,where ND, is the corrected illumination interference matrix in the measurement region, which can be equivalent to the difference matrix D, calculated by (5)D=RDGDBDVD=M255M255M255M255−RRGRBRVR.Next, the difference matrixD is merged with the leaf image to be measured, collected under the current environment. The image of the leaf to be measured can be described as(6)MR=MI+N⟹BR∪LR=BI+NB∪LI+NL,where MI is the ideal image matrix, N is the light interference matrix, the leaf image matrix MR to be measured can be decomposed into the union of the background image matrix BR and the leaf image matrix LR, NB is the interference of light on the background, NL is the interference of light on the leaves, and BI and LI are the matrices under ideal conditions.After applying the same distortion correction and region extraction forMR, MR, is obtained. The difference matrix D is fused into the matrix MR,, as follows:(7)MRf=MR,+D=BR,+DB∪LR+DL=BI,∪LR+DL=M255M255M255M255∪LI+NL+DL,BR, is a set of background pixels after distortion correction and region extraction, fusion of background difference matrix DB, and substituting formula (5) to restore the set of background pixels to an ideal all-white background BI,, the gray value is 255. The set of leaf pixels to be tested is LI+NL+DL, where LI is the ideal set of leaf pixels not disturbed by light, NL is the light interference matrix, and DL is the difference matrix.The aforementioned color image is converted from RGB to HSV space. As can be seen from the HSV and RGB conversion tables, for whiteH∈0,180S∈0,30V∈221,255, other nonblack and gray color S channel values range from 43,255. For the leaves, most of them are green, and some are red, yellow, and so on. There are very few black and gray colors. Regardless of the rare case, the algorithm in this paper selects the S channel. MRf in (7) is filtered by (8), and (9) can be obtained:(8)HM=0,S∈0,30sRf,S∈31,255,(9)Mf=HMRf=HBI,∪LI+NL+DL=M0∪sRf.Equation (8) indicates that when the saturation S value is less than 30, it can be considered as a white background, and the pixel value is assigned to 0. When the S value is greater than 30, the S value of the original pixel sRf is retained. After the fusion matrix MRf in (7) is filtered by (8), the restored ideal all-white background set BI, has a pixel value of 255, so it is assigned as an all-zero matrix M0. The set pixel value of the leaf is the original S value sRf, and the range is [31, 255]. In this way, the leaf is separated from the background by overcoming the illumination interference.Next, in order to eliminate the influence of discrete noise points, Gaussian filtering with 3 × 3 template is used for image smoothing. Then, the nonbackground pixels in the image are judged and counted. Finally, the leaf area is calculated in the traditional way.


### 2.2.4. Edge Error Correction Algorithm

By measuring the standard rectangular measuring block, it is found that the measuring block with a smaller area has a higher accuracy, and the larger the area, the greater the deviation of the measured value. Zoom in and observe the leaf image after Gaussian blurring, as shown in Figure4.Figure 4
Leaf edge blur.It can be seen that the edge of the leaf is blurred due to optical diffusion. The longer the circumference is (when the leaf is larger), the more the pixels are blurred by optical diffusion. It affects the judgment of nonbackground pixels, so that the background pixels close to the edge of the leaf are also included in the nonbackground pixels, thus resulting in a large statistical error in the number of pixels on the leaf. Aiming to solve this problem, this paper proposes an edge error correction algorithm.Assuming that the pixels of the image sensor are square, the side length of each pixel is first calculated using(10)Lpixel=SW×H,where S is the area of the entire measurement area obtained by manual measurement, and the unit is mm2. W and H are the width and height of the measurement area in the image respectively, and the unit is pixel.Calculate the circumscribed rectangle of the leaf image after Gaussian filtering. Assuming that the blurred pixels caused by optical diffusion are uniformly distributed around the periphery of the real edge of the leaf, the circumference of the circumscribed rectangle can be set toC, and the increased area of the outer edge of the leaf is ΔS, and the following can be obtained:(11)ΔS=N×Lpixel2=N×Lpixel×Lpixel=a×C×Lpixel,where N is the number of pixels distributed around the true edge of the leaf in one circle, Lpixel2 is the area of a single pixel, and a is the relation coefficient between the perimeter of the leaf edge N×Lpixel and the perimeter of the circumscribed rectangle C.The extraction of the leaf edge is greatly affected by the color saturationS value, the target background gradient value, and different algorithms. Therefore, the algorithm in this paper selects a relatively stable circumscribed rectangular frame to describe the leaf boundary, which is effective for most leaf shapes. However, for the leaves with approximately hollow shapes in the middle, such as the leaves of Liriodendron chinense, the error is large. Considering that there is a certain difference between the edge circumference of the leaf and the circumference of the circumscribed rectangle, the relational coefficient a is set to obtain the empirical value based on several standard rectangular block measurement experiments:(12)a=0.25,l1≤10mml2≤50mm,0.80,l1≤20mml2≤50mm,1.50,other.The final area of the leaf after error correction can be obtained by subtracting the increased area of the leaf periphery calculated according to formulas (11) and (12) from the area of the leaf calculated according to Section 2.2.3.


## 2.2.1. Overall Flow of the Measurement Algorithm

In order to accurately measure the plant leaf area using a low-cost network camera, the calibration technique in the fixed area is studied to correct the distortion of the network camera. In order to overcome the complex outdoor light interference, the background color calibration technology is mainly studied, so that the high-precision leaf area measurement can be performed both indoors and outdoors. The influence of S-channel properties on leaf image segmentation in HSV color model and the influence of edge blur on high-precision leaf area measurement are studied in detail. The overall algorithm flow is shown in Figure3.Figure 3
The overall algorithm flowchart.The whole algorithm consists of four modules. The first is the main process module of leaf area measurement. First, the Hikvision network camera SDK development kit related function is called to collect the image and save it as jpg format. Then, use the calibration parameters for distortion correction. Next, the measurement area is cut; that is, the ROI area is extracted. According to the difference matrix obtained by color calibration, the current region image and the difference matrix are merged. Then, RGB is converted into the HSV color model, and the S channel is extracted, and then the Gaussian filtering is performed to eliminate the noise. The nonbackground pixels are judged according to the threshold parameters, and the number is calculated. The leaf area is calculated according to preset parameters. Finally, error correction is performed.The second is the distortion correction module, which can choose offline or online calibration by using Zhang Zhengyou calibration method. The calculated calibration parameters are written into the configuration file for the distortion correction module to call. The third is the color calibration module. Before preparing to start measuring the leaf area, first collect a blank background image under the current illumination state, correct it with the distortion correction module, and extract the ROI area. Then, analyze the brightness and RGB values of the area. Next, make a difference with the ideal all-white background, save the difference parameters, and construct the difference matrix for the image fusion module to use. The fourth is the error correction module. After Gaussian filtering, the contour of the circumscribed rectangle of the measured leaf in the image is obtained, the relationship between the edge and the area is analyzed, and the error correction parameter is calculated for use by the error correction module.


## 2.2.2. Distortion Correction Algorithm

The low-cost network camera image distortion is large, and high-precision distortion correction is needed. In this paper, Zhang Zhengyou calibration method is used to calibrate the camera internal parameter matrix and distortion coefficient. The network camera model is described using(1)sm=AR,tM,where s is the scale factor, m is the image two-dimensional coordinate vector, A is the internal parameter matrix of the camera to be obtained, R,t is the external parameter matrix of the camera, which is the rotation matrix R and the translation matrix t, respectively, and M is the three-dimensional coordinate vector of the object. The expansion is shown as(2)suv1=Ar1r2r3tXYZ1=Ar1r2tXY1=∝ru00βv0001r1r2tXY1.Since the leaf area measuring instrument studied in this paper measures the leaf on one plane,Z = 0 can be set to simplify the above formula (2). Find the parameter matrix A in the camera; that is, find the five parameters in the matrix. In order to obtain high-precision calibration parameters, the calibration plate is placed on the leaf measurement plane, and 20 pictures of different rotation angles and translation positions are collected arbitrarily. The constraint conditions are used to solve the problem according to Zhang Zhengyou’s calibration method.Next, using the above 20 calibration plate pictures, the distortion equation (3) is selected to solve the radial distortion parameter k1,k2,k3 and the tangential distortion parameter p1,p2:(3)x,y,=1+k1r2+k2r4+k3r6xy+2p1xy+p2r2+2x22p1r2+2y2+2p2xy,r2=x2+y2.In the formula,x,y, is the position after distortion, and xy is an ideal position where no distortion occurs.Since the positions of the corner points of the checkerboard calibration plate are known, a set of equations can be constructed according to (3) to solve the five distortion parameters. According to the aforementioned algorithm, the software introduced in Section 2.1.2 automatically solves the parameter matrix A and the five distortion parameters in the camera and writes them into the parameter file. After collecting the leaf image to be measured, the image is corrected according to the stored parameters.


## 2.2.3. Color Calibration Algorithm

By comparing the mobile phone type and photoelectric scanning type leaf area measuring instrument, it is found that the high measurement accuracy of the photoelectric scanning type device is largely due to the simple background without complex light interference, and the obtained background image of the leaf image has a gray value of 255 pure white image. Inspired by this, this paper proposes a color calibration algorithm to compensate the background by light interference and restore it to a pure white background image with a gray value of 255.First, collect a blank background image in the current measurement environment and use it as the image to be measured for distortion correction and measurement area extraction. The distortion correction adopts the method in Section2.2.2, as shown in Figure 2(b). The measurement area is a rectangular area drawn by a pencil. The coordinates of the upper left corner of the area and the length and width values are obtained manually, and then the parameters are entered to set the dialog box. Assuming that the acquired blank background image is matrix BR, the matrix can be decomposed into BR=BI+N, where BI is an ideal all-white background image with a gray value of 255 and N is the illumination interference parameter matrix under the current environment. After distortion correction and measurement region extraction, a new image matrix BR, is obtained; that is BR,=HBR. Perform RGB color and brightness analysis on equation BR,, which can be decomposed into(4)BR,=BI,+ND,⟹RRGRBRVR=M255M255M255M255−RDGDBDVD,where ND, is the corrected illumination interference matrix in the measurement region, which can be equivalent to the difference matrix D, calculated by (5)D=RDGDBDVD=M255M255M255M255−RRGRBRVR.Next, the difference matrixD is merged with the leaf image to be measured, collected under the current environment. The image of the leaf to be measured can be described as(6)MR=MI+N⟹BR∪LR=BI+NB∪LI+NL,where MI is the ideal image matrix, N is the light interference matrix, the leaf image matrix MR to be measured can be decomposed into the union of the background image matrix BR and the leaf image matrix LR, NB is the interference of light on the background, NL is the interference of light on the leaves, and BI and LI are the matrices under ideal conditions.After applying the same distortion correction and region extraction forMR, MR, is obtained. The difference matrix D is fused into the matrix MR,, as follows:(7)MRf=MR,+D=BR,+DB∪LR+DL=BI,∪LR+DL=M255M255M255M255∪LI+NL+DL,BR, is a set of background pixels after distortion correction and region extraction, fusion of background difference matrix DB, and substituting formula (5) to restore the set of background pixels to an ideal all-white background BI,, the gray value is 255. The set of leaf pixels to be tested is LI+NL+DL, where LI is the ideal set of leaf pixels not disturbed by light, NL is the light interference matrix, and DL is the difference matrix.The aforementioned color image is converted from RGB to HSV space. As can be seen from the HSV and RGB conversion tables, for whiteH∈0,180S∈0,30V∈221,255, other nonblack and gray color S channel values range from 43,255. For the leaves, most of them are green, and some are red, yellow, and so on. There are very few black and gray colors. Regardless of the rare case, the algorithm in this paper selects the S channel. MRf in (7) is filtered by (8), and (9) can be obtained:(8)HM=0,S∈0,30sRf,S∈31,255,(9)Mf=HMRf=HBI,∪LI+NL+DL=M0∪sRf.Equation (8) indicates that when the saturation S value is less than 30, it can be considered as a white background, and the pixel value is assigned to 0. When the S value is greater than 30, the S value of the original pixel sRf is retained. After the fusion matrix MRf in (7) is filtered by (8), the restored ideal all-white background set BI, has a pixel value of 255, so it is assigned as an all-zero matrix M0. The set pixel value of the leaf is the original S value sRf, and the range is [31, 255]. In this way, the leaf is separated from the background by overcoming the illumination interference.Next, in order to eliminate the influence of discrete noise points, Gaussian filtering with 3 × 3 template is used for image smoothing. Then, the nonbackground pixels in the image are judged and counted. Finally, the leaf area is calculated in the traditional way.


## 2.2.4. Edge Error Correction Algorithm

By measuring the standard rectangular measuring block, it is found that the measuring block with a smaller area has a higher accuracy, and the larger the area, the greater the deviation of the measured value. Zoom in and observe the leaf image after Gaussian blurring, as shown in Figure4.Figure 4
Leaf edge blur.It can be seen that the edge of the leaf is blurred due to optical diffusion. The longer the circumference is (when the leaf is larger), the more the pixels are blurred by optical diffusion. It affects the judgment of nonbackground pixels, so that the background pixels close to the edge of the leaf are also included in the nonbackground pixels, thus resulting in a large statistical error in the number of pixels on the leaf. Aiming to solve this problem, this paper proposes an edge error correction algorithm.Assuming that the pixels of the image sensor are square, the side length of each pixel is first calculated using(10)Lpixel=SW×H,where S is the area of the entire measurement area obtained by manual measurement, and the unit is mm2. W and H are the width and height of the measurement area in the image respectively, and the unit is pixel.Calculate the circumscribed rectangle of the leaf image after Gaussian filtering. Assuming that the blurred pixels caused by optical diffusion are uniformly distributed around the periphery of the real edge of the leaf, the circumference of the circumscribed rectangle can be set toC, and the increased area of the outer edge of the leaf is ΔS, and the following can be obtained:(11)ΔS=N×Lpixel2=N×Lpixel×Lpixel=a×C×Lpixel,where N is the number of pixels distributed around the true edge of the leaf in one circle, Lpixel2 is the area of a single pixel, and a is the relation coefficient between the perimeter of the leaf edge N×Lpixel and the perimeter of the circumscribed rectangle C.The extraction of the leaf edge is greatly affected by the color saturationS value, the target background gradient value, and different algorithms. Therefore, the algorithm in this paper selects a relatively stable circumscribed rectangular frame to describe the leaf boundary, which is effective for most leaf shapes. However, for the leaves with approximately hollow shapes in the middle, such as the leaves of Liriodendron chinense, the error is large. Considering that there is a certain difference between the edge circumference of the leaf and the circumference of the circumscribed rectangle, the relational coefficient a is set to obtain the empirical value based on several standard rectangular block measurement experiments:(12)a=0.25,l1≤10mml2≤50mm,0.80,l1≤20mml2≤50mm,1.50,other.The final area of the leaf after error correction can be obtained by subtracting the increased area of the leaf periphery calculated according to formulas (11) and (12) from the area of the leaf calculated according to Section 2.2.3.


## 3. Result and Analysis of Experiment

The entire test process operating system is Windows 10, 64 bits, and the development software is Visual Studio 2015 and OpenCV 3.4.0. The computer is equipped with Intel(R) Core(TM) i3-8100CPU @ CPU 3.60 GHz processor with eight GB of memory.In order to verify the environmental adaptability of the algorithm in this paper, the system was tested on the same leaf both indoors and outdoors. In order to verify the accuracy of this algorithm in leaf area measurement, two groups of objects were tested, and the results were compared with those measured by Wan Shen LA-S plant image analyzer. The first group is a standard rectangular gauge block made of green cardboard, with a thickness of 0.5 mm, length and width from 10 mm × 10 mm to 50 mm × 90 mm, and a total of 18 green rectangular blocks with various shapes. The second group consisted ofPlatanus orientalis leaves, Ligustrum lucidum leaves, and Ligustrum quihoui leaves, which were naturally air-dried and flattened and were measured later after two days.


### 3.1. Outdoor Leaf Area Measurement Experiment

In the green belt next to the school's boulevard, aLigustrum lucidum leaf is picked, and the area of the leaf is measured in an outdoor environment.First, 20 different calibration plate images are collected, and the system camera parameters are calculated, mainly internal parameters and distortion parameters, and then the distortion correction is performed, as shown in Figure5, where Figure 5(a) is the image before distortion correction and Figure 5(b) is the image after distortion correction.Figure 5
Distortion correction effect. (a) Before correction. (b) After correction.
(a)(b)Then, collect a blank background image and do a color calibration. Next, put theLigustrum lucidum leaf picked on-site into the measurement field, as shown in Figure 6(a), and start the measurement. The algorithm proposed in this paper is used to extract ROI measurement areas, as shown in Figure 6(b). According to the preset parameters, the area in the rectangular frame drawn by pencil in Figure 6(a) is segmented and extracted. Then, the S channel extraction is performed as shown in Figure 6(c). It can be seen that, due to the intervention of color calibration algorithm, the light interference in Figure 6(b) has been completely eliminated in Figure 6(c). In order to further eliminate noise interference, Gaussian filtering is used, as shown in Figure 6(d). It can be seen that, after using the 3 × 3 template to perform Gaussian filtering, the leaf image becomes more uniform. Finally, the leaf area is calculated, and the error correction is performed using the edge error correction algorithm. The final leaf area calculation value is displayed in the form of a dialog box, as shown in Figure 6(e).Figure 6
The leaf area measurement process. (a) Placement in the measurement field. (b) Measurement area extraction. (c) S channel extraction. (d) Gaussian filtering. (e) Display area measurement value.
(a)(b)(c)(d)(e)The leaf area meter designed in this paper is a portable system. The whole system is taken to the indoor laboratory for measurement again, and the obtained leaf area value is consistent with that in the outdoor light interference environment. The Wanshen leaf area analyzer is based on the scanner structure and requires an external 220 V AC power supply, which is not convenient for outdoor use, so it was not tested in this experiment.


### 3.2. Comparative Measurement Experiment with Standard Gauge Block

This group of experiments is implemented with standard gauge blocks. The green standard A4 printing paper with the color similar to the real leaves is selected and cut into 18 standard rectangles with a known area. These standard rectangular blocks are regarded as leaves and placed in different leaf area measuring instruments for area measurement. In order to verify the effectiveness of the proposed algorithm, the Wanshen LA-S plant image analyzer is selected to measure the leaf area for comparative measurement experiment. The results are shown in Table1. The method proposed in this paper is named BCC, and the Wanshen LA-S plant image analyzer is named LAS.Table 1
Measurement results for green standard rectangular gauge blocks of known area in the leaf area measuring instrument.
Gauge block size (mm)True area (mm2)Measurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS10 × 10100100.6049100.72450.60490.72450.60%0.72%10 × 30300299.8115300.7694−0.18850.7694−0.063%0.26%10 × 50500499.9739498.9632−0.0261−1.0368−0.01%−0.21%10 × 70700704.8353704.63754.83534.63750.69%0.66%20 × 20400402.8942403.23122.89423.23120.72%0.81%20 × 40800799.1554800.3269−0.84460.3269−0.11%0.04%20 × 6012001179.52571178.3601−20.4743−21.6399−1.71−1.80%20 × 8016001580.05751579.3269−19.9425−20.6731−1.25%−1.29%30 × 30900912.4805913.356212.480513.35621.39%1.48%30 × 5015001529.12161528.368729.121628.36871.94%1.89%30 × 7021002101.26112098.63561.2611−1.36440.06%−0.06%30 × 9027002693.73982694.3265−6.2602−5.6735−0.23%−0.21%40 × 4016001630.48141631.256930.481431.25691.91%1.95%40 × 6024002392.28762390.3265−7.7124−9.6735−0.32%−0.40%40 × 8032003195.19113195.3621−4.8089−4.6379−0.15%−0.14%40 × 10040004026.28944036.469326.289436.46930.66%0.91%50 × 5025002497.26112496.3643−2.7389−3.6357−0.11%−0.15%50 × 9045004505.12124498.36575.1212−1.63430.11%−0.04%As shown in Table1, the measurement results of the two methods are relatively stable, and the relative error is less than 2%. For the convenience of comparison, the results with better absolute and relative errors are marked with dark colors. On the whole, the method proposed in this paper performs better.


### 3.3. Contrast Measurement Experiment with Wanshen LA-S Plant Image Analyzer

The aforementioned standard rectangular block is a regular-shaped object, and the measurement accuracy of the algorithm in this paper is higher, but the leaf is a nonregular-shaped object. In this group of experiments, we usedPlatanus orientalis leaves, Ligustrum lucidum leaves, and Ligustrum quihoui leaves to carry out three sets of experiments. In each experiment, a leaf was repeatedly measured at nine different angles. The real area of the leaf was measured manually with the help of a coordinate paper, which was used as a reference for experimental comparison. The leaf areas used in this study are Platanus orientalis leaf 5946.6864 mm2, Ligustrum lucidum leaf 1520.3236 mm2, and Ligustrum quihoui leaf 1459.3528 mm2. The method presented in this paper and the Wanshen leaf area meter were used for measurement, respectively. The measurement results are as follows: Table 2 is the measurement of Platanus orientalis leaves, Table 3 is the measurement of Ligustrum lucidum leaves, and Table 4 is the measurement of Ligustrum quihoui leaves. The method proposed in this paper is named BCC, and the Wanshen LA-S plant image analyzer is named LAS.Table 2
Comparison of leaf area measurement forPlatanus orientalis.
AngleMeasurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS0°5933.52016095.6936−13.1663149.0072−0.22%2.51%45°5889.67956082.6137−57.0069135.9273−0.96%2.29%90°5890.31956053.2305−56.3669106.5441−0.95%1.79%135°5869.99936057.6393−76.6871110.9529−1.29%1.87%180°5921.84006047.7561−24.8464101.0697−0.42%1.70%225°5874.95936058.8115−71.7271112.1251−1.21%1.89%270°5849.03906065.6844−97.6474118.998−1.64%2.00%315°5877.67946065.6045−69.007118.9181−1.16%2.00%360°5900.87976065.8443−45.8067119.1579−0.77%2.00%Average value5889.76846065.8753−56.918119.1889−0.96%2.00%Table 3
Comparison of leaf area measurement forLigustrum lucidum.
AngleMeasurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS0°1530.02131506.09439.6977−14.22930.64%−0.94%45°1528.26121508.67837.9376−11.64530.52%−0.77%90°1517.38111508.3453−2.9425−11.9783−0.19%−0.79%135°1486.50071513.9928−33.8229−6.3308−2.22%−0.42%180°1521.54121525.39451.21765.07090.08%0.33%225°1546.98171521.638326.65811.31471.75%0.09%270°1531.62131516.856611.2977−3.4670.74%−0.23%315°1483.94071513.6598−36.3829−6.6638−2.39%−0.44%360°1519.30111514.9119−1.0225−5.4117−0.067%−0.36%Average value1518.39451514.3969−1.9291−5.9267−0.13%−0.39%Table 4
Comparison of leaf area measurement forLigustrum quihoui.
AngleMeasurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS0°1463.30041450.49803.9476−8.85480.27%−0.61%45°1477.54061446.129118.1878−13.22371.25%−0.91%90°1466.18041458.99596.8276−0.35690.47%−0.02%135°1456.74031463.6977−2.61254.3449−0.18%0.30%180°1457.54031469.7848−1.812510.432−0.12%0.71%225°1462.66041468.07993.30768.72710.23%0.60%270°1439.30011466.1086−20.05276.7558−1.37%0.46%315°1443.94011463.5512−15.41274.1984−1.06%0.29%360°1466.34041465.98876.98766.63590.48%0.45%Average value1459.28261461.426−0.07022.0732−0.01%0.14%For the convenience of comparison, the results with better absolute and relative errors are marked with dark colors. By comparing the measurement results of Tables2–4, it is found that (1) the algorithm proposed in this paper has a significantly better measurement effect on Platanus orientalis leaves than the Wanshen leaf area meter. The main reason is that the algorithm of Wanshen leaf area meter extracts the edge contour of the leaf during operation and calculates the leaf area according to the area enclosed by the contour. The measurement result is interfered by the concave shape of the Platanus orientalis leaf, and the edge profile does not closely fit the real edge of the leaf in some parts, so the measured value is larger. The algorithm proposed in this paper does not depend on the edge contour, so the accuracy is high. (2) The surfaces of Ligustrum lucidum and Ligustrum quihoui leaves are relatively flat. The performance of both methods is good, and the absolute error is less than 2%. The measurement result of Wanshen leaf area meter is more stable. The main reason for this is that, due to cost limitation, our system uses a simple LED supplementary light as the light source, and the uneven lighting can easily produce shadows and introduce errors. However, the average value of multiple measurements in this paper is closer to the true value, so when using this method to measure the leaf area, the average value of multiple measurements can be considered to improve the measurement accuracy.


## 3.1. Outdoor Leaf Area Measurement Experiment

In the green belt next to the school's boulevard, aLigustrum lucidum leaf is picked, and the area of the leaf is measured in an outdoor environment.First, 20 different calibration plate images are collected, and the system camera parameters are calculated, mainly internal parameters and distortion parameters, and then the distortion correction is performed, as shown in Figure5, where Figure 5(a) is the image before distortion correction and Figure 5(b) is the image after distortion correction.Figure 5
Distortion correction effect. (a) Before correction. (b) After correction.
(a)(b)Then, collect a blank background image and do a color calibration. Next, put theLigustrum lucidum leaf picked on-site into the measurement field, as shown in Figure 6(a), and start the measurement. The algorithm proposed in this paper is used to extract ROI measurement areas, as shown in Figure 6(b). According to the preset parameters, the area in the rectangular frame drawn by pencil in Figure 6(a) is segmented and extracted. Then, the S channel extraction is performed as shown in Figure 6(c). It can be seen that, due to the intervention of color calibration algorithm, the light interference in Figure 6(b) has been completely eliminated in Figure 6(c). In order to further eliminate noise interference, Gaussian filtering is used, as shown in Figure 6(d). It can be seen that, after using the 3 × 3 template to perform Gaussian filtering, the leaf image becomes more uniform. Finally, the leaf area is calculated, and the error correction is performed using the edge error correction algorithm. The final leaf area calculation value is displayed in the form of a dialog box, as shown in Figure 6(e).Figure 6
The leaf area measurement process. (a) Placement in the measurement field. (b) Measurement area extraction. (c) S channel extraction. (d) Gaussian filtering. (e) Display area measurement value.
(a)(b)(c)(d)(e)The leaf area meter designed in this paper is a portable system. The whole system is taken to the indoor laboratory for measurement again, and the obtained leaf area value is consistent with that in the outdoor light interference environment. The Wanshen leaf area analyzer is based on the scanner structure and requires an external 220 V AC power supply, which is not convenient for outdoor use, so it was not tested in this experiment.


## 3.2. Comparative Measurement Experiment with Standard Gauge Block

This group of experiments is implemented with standard gauge blocks. The green standard A4 printing paper with the color similar to the real leaves is selected and cut into 18 standard rectangles with a known area. These standard rectangular blocks are regarded as leaves and placed in different leaf area measuring instruments for area measurement. In order to verify the effectiveness of the proposed algorithm, the Wanshen LA-S plant image analyzer is selected to measure the leaf area for comparative measurement experiment. The results are shown in Table1. The method proposed in this paper is named BCC, and the Wanshen LA-S plant image analyzer is named LAS.Table 1
Measurement results for green standard rectangular gauge blocks of known area in the leaf area measuring instrument.
Gauge block size (mm)True area (mm2)Measurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS10 × 10100100.6049100.72450.60490.72450.60%0.72%10 × 30300299.8115300.7694−0.18850.7694−0.063%0.26%10 × 50500499.9739498.9632−0.0261−1.0368−0.01%−0.21%10 × 70700704.8353704.63754.83534.63750.69%0.66%20 × 20400402.8942403.23122.89423.23120.72%0.81%20 × 40800799.1554800.3269−0.84460.3269−0.11%0.04%20 × 6012001179.52571178.3601−20.4743−21.6399−1.71−1.80%20 × 8016001580.05751579.3269−19.9425−20.6731−1.25%−1.29%30 × 30900912.4805913.356212.480513.35621.39%1.48%30 × 5015001529.12161528.368729.121628.36871.94%1.89%30 × 7021002101.26112098.63561.2611−1.36440.06%−0.06%30 × 9027002693.73982694.3265−6.2602−5.6735−0.23%−0.21%40 × 4016001630.48141631.256930.481431.25691.91%1.95%40 × 6024002392.28762390.3265−7.7124−9.6735−0.32%−0.40%40 × 8032003195.19113195.3621−4.8089−4.6379−0.15%−0.14%40 × 10040004026.28944036.469326.289436.46930.66%0.91%50 × 5025002497.26112496.3643−2.7389−3.6357−0.11%−0.15%50 × 9045004505.12124498.36575.1212−1.63430.11%−0.04%As shown in Table1, the measurement results of the two methods are relatively stable, and the relative error is less than 2%. For the convenience of comparison, the results with better absolute and relative errors are marked with dark colors. On the whole, the method proposed in this paper performs better.


## 3.3. Contrast Measurement Experiment with Wanshen LA-S Plant Image Analyzer

The aforementioned standard rectangular block is a regular-shaped object, and the measurement accuracy of the algorithm in this paper is higher, but the leaf is a nonregular-shaped object. In this group of experiments, we usedPlatanus orientalis leaves, Ligustrum lucidum leaves, and Ligustrum quihoui leaves to carry out three sets of experiments. In each experiment, a leaf was repeatedly measured at nine different angles. The real area of the leaf was measured manually with the help of a coordinate paper, which was used as a reference for experimental comparison. The leaf areas used in this study are Platanus orientalis leaf 5946.6864 mm2, Ligustrum lucidum leaf 1520.3236 mm2, and Ligustrum quihoui leaf 1459.3528 mm2. The method presented in this paper and the Wanshen leaf area meter were used for measurement, respectively. The measurement results are as follows: Table 2 is the measurement of Platanus orientalis leaves, Table 3 is the measurement of Ligustrum lucidum leaves, and Table 4 is the measurement of Ligustrum quihoui leaves. The method proposed in this paper is named BCC, and the Wanshen LA-S plant image analyzer is named LAS.Table 2
Comparison of leaf area measurement forPlatanus orientalis.
AngleMeasurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS0°5933.52016095.6936−13.1663149.0072−0.22%2.51%45°5889.67956082.6137−57.0069135.9273−0.96%2.29%90°5890.31956053.2305−56.3669106.5441−0.95%1.79%135°5869.99936057.6393−76.6871110.9529−1.29%1.87%180°5921.84006047.7561−24.8464101.0697−0.42%1.70%225°5874.95936058.8115−71.7271112.1251−1.21%1.89%270°5849.03906065.6844−97.6474118.998−1.64%2.00%315°5877.67946065.6045−69.007118.9181−1.16%2.00%360°5900.87976065.8443−45.8067119.1579−0.77%2.00%Average value5889.76846065.8753−56.918119.1889−0.96%2.00%Table 3
Comparison of leaf area measurement forLigustrum lucidum.
AngleMeasurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS0°1530.02131506.09439.6977−14.22930.64%−0.94%45°1528.26121508.67837.9376−11.64530.52%−0.77%90°1517.38111508.3453−2.9425−11.9783−0.19%−0.79%135°1486.50071513.9928−33.8229−6.3308−2.22%−0.42%180°1521.54121525.39451.21765.07090.08%0.33%225°1546.98171521.638326.65811.31471.75%0.09%270°1531.62131516.856611.2977−3.4670.74%−0.23%315°1483.94071513.6598−36.3829−6.6638−2.39%−0.44%360°1519.30111514.9119−1.0225−5.4117−0.067%−0.36%Average value1518.39451514.3969−1.9291−5.9267−0.13%−0.39%Table 4
Comparison of leaf area measurement forLigustrum quihoui.
AngleMeasurement area (mm2)Absolute errors (mm2)Relative errors (%)BCCLASBCCLASBCCLAS0°1463.30041450.49803.9476−8.85480.27%−0.61%45°1477.54061446.129118.1878−13.22371.25%−0.91%90°1466.18041458.99596.8276−0.35690.47%−0.02%135°1456.74031463.6977−2.61254.3449−0.18%0.30%180°1457.54031469.7848−1.812510.432−0.12%0.71%225°1462.66041468.07993.30768.72710.23%0.60%270°1439.30011466.1086−20.05276.7558−1.37%0.46%315°1443.94011463.5512−15.41274.1984−1.06%0.29%360°1466.34041465.98876.98766.63590.48%0.45%Average value1459.28261461.426−0.07022.0732−0.01%0.14%For the convenience of comparison, the results with better absolute and relative errors are marked with dark colors. By comparing the measurement results of Tables2–4, it is found that (1) the algorithm proposed in this paper has a significantly better measurement effect on Platanus orientalis leaves than the Wanshen leaf area meter. The main reason is that the algorithm of Wanshen leaf area meter extracts the edge contour of the leaf during operation and calculates the leaf area according to the area enclosed by the contour. The measurement result is interfered by the concave shape of the Platanus orientalis leaf, and the edge profile does not closely fit the real edge of the leaf in some parts, so the measured value is larger. The algorithm proposed in this paper does not depend on the edge contour, so the accuracy is high. (2) The surfaces of Ligustrum lucidum and Ligustrum quihoui leaves are relatively flat. The performance of both methods is good, and the absolute error is less than 2%. The measurement result of Wanshen leaf area meter is more stable. The main reason for this is that, due to cost limitation, our system uses a simple LED supplementary light as the light source, and the uneven lighting can easily produce shadows and introduce errors. However, the average value of multiple measurements in this paper is closer to the true value, so when using this method to measure the leaf area, the average value of multiple measurements can be considered to improve the measurement accuracy.


## 4. Discussion

This paper constructed a set of leaf area measurement systems and developed a plant leaf area measurement method based on background color calibration. This method has a good environmental adaptability, high measurement accuracy, and good stability. Compared with the traditional leaf area measurement method, it has the following advantages.(1)
The leaf area measuring instrument designed in this paper has a simple structure. The camera is connected to an external lithium battery, and the collected leaf images are transmitted to the notebook computer via WIFI, avoiding the inconvenience caused by excessive cables. It can be used directly in outdoor farmland, which is more convenient and quicker, and prevents measurement errors caused by removing the leaves.(2)
A flattening device is designed for the leaf area measuring instrument in this paper, which can reduce the measurement error. In addition, distortion correction can be carried out by calibrating camera parameters online, the color calibration algorithm can compensate the interference caused by background light changes, and the edge error correction algorithm can repair the errors around the leaf caused by optical diffusion to further improve the measurement accuracy.(3)
This method is limited by a simple light source device, and therefore its stability is slightly worse than that of existing equipment. However, the experiments show that the average results of multiple measurements are significantly better than the existing device. In actual use, the leaf area can be obtained from multiple angles, and the mean value can be taken as the final result.The hardware of the leaf area measuring instrument made for the first time is relatively rough, and the resolution of the network camera is not high. When the cost is controllable, it can be replaced with a camera with a higher resolution and better lens imaging quality, which can effectively improve the measurement accuracy. In addition, the LED supplementary light can also be upgraded to provide more uniform lighting conditions and overcome the influence of shadows. In terms of software, the histogram equalization method [21] can be combined to have a good illumination and device invariant and further improve the robustness and reliability of the algorithm. Of course, it is necessary to ensure that the rank ordering of sensor responses is preserved across a change in imaging conditions.



---

*Source: 6650099-2021-03-11.xml*