Applied Science and Innovative Research ISSN 2474-4972 (Print) ISSN 2474-4980 (Online) Vol. 9, No. 1, 2025 www.scholink.org/ojs/index.php/asir 248 Original Paper Extraction of Fruit Tree Canopy Images Based on Machine Vision Xiaodan Lin1, Shaohui Ma1 & Junjie Liu1 1 College of Mechanical and Electrical Engineering, Tarim University, Aral, China Received: October 6, 2024 Accepted: October 27, 2024 Online Published: March 26, 2025 doi:10.22158/asir.v9n1p248 URL: http://doi.org/10.22158/asir.v9n1p248 Abstract With the rapid development of machine vision technology and the help of smart agriculture, machine vision technology has developed from medical, military, national defense and other fields to the agricultural field and achieved remarkable results. Such as: fruit and vegetable picking robot, fruit quality classification, weed pest monitoring and so on. In this paper, machine vision technology is used to complete the segmentation of fruit tree crown image, which is complicated due to the influence of fruit tree shape, planting mode and growth environment. For pear trees in orchards, OpenCV software and image processing method are used in this paper to propose a tree crown image segmentation algorithm to provide reference for the subsequent prediction of fruit tree crown volume and accurate spraying. Keywords machine vision, image processing, Gaussian filter, threshold segmentation 1. Collect Pear Tree Crown Images The research samples of this paper are pear trees, and the samples of pear trees collected from orchards contain the basic growth types of tree crowns. After the sample is determined, the image collection of pear tree crown is carried out. In this paper, Canon R50 camera is used for image collection of pear tree. The distance of 1.5 meters between the pear tree under test and shooting is kept, and the camera is fixed with a tripod to keep the camera perpendicular to the trunk to ensure that all the images of tree crown are displayed in the lens. Reduce the shade between pear trees and the interference of the surrounding environment, and provide high-quality samples for the later image processing. The image processing environment in this paper is based on OpenCV and 64bit Windows10 operating system. www.scholink.org/ojs/index.php/asir Applied Science and Innovative Research Vol. 9, No. 1, 2025 249 Published by SCHOLINK INC. Figure 1. Pear Tree Sample Figure 2. Mage Acquisition Module 3. Pear Tree Crown Image Processing In the process of image acquisition, due to the interference of weather, illumination, environment and other factors, the image will produce noise, which can not be well recognized and detected. Therefore, it is necessary to preprocess the acquired image first to improve the quality of the image. The image preprocessing is mainly noise reduction processing to reduce noise interference. 3.1 Gaussian Filter Commonly used algorithms include mean filter, median filter and Gaussian filter, etc. (Liu, X. et al., 2024). The mean filter is a linear filter, which calculates the average value of all pixels in the template area, and then replaces the gray value of the template center pixel. This method is highly efficient, but it is easy to lose image information. The core of median filter is a nonlinear filter, which calculates the median value of all pixels in the template to replace the gray value of the center pixel of the template, which is easy to cause discontinuity of the image and high time complexity. In contrast, Gaussian filter is a linear smoothing filter, which is widely used in image processing (Zhang, L. et al., 2024). The specific operation of Gaussian filtering is to select a Gaussian template to scan each pixel in the image, and use the weighted average of the pixels in the neighborhood determined by the template to replace the value of the central pixel of the template, so that the high-frequency noise is smoothed out, while the low-frequency components of the image are retained, by discretizing the Gaussian function, the obtained Gaussian function value is used as the parameter of the template (Zhang, Y. J., 2022). Gauss formula: (1) Where (x,y) is the coordinate point, the square of x and the square of y respectively represent the distance between other pixels in the neighborhood and the center pixel in the neighborhood, σ 2 2 22 2 1 ( , ) 2 x y G x y e     www.scholink.org/ojs/index.php/asir Applied Science and Innovative Research Vol. 9, No. 1, 2025 250 Published by SCHOLINK INC. represents the standard deviation and the degree of dispersion of the data, if σ is larger, the Gaussian image will be wider and the filtering effect will be obvious, and vice versa. The commonly used Gaussian template has a size of 3×3 or 5×5. Take the 3×3 template as an example, initialize the coordinates, take the center position of the template as the coordinate origin (0,0), and sample symmetrically up and down, left and right, so that the coordinates of the template at each position can be obtained, and put the coordinates of each position into the Gaussian function, and the obtained value is the coefficient of the template. For a window template size of (2k+1) × (2k+1), the formula for calculating each prime value in the template is as follows: 2 2 2 ( ) ( ) 2 , 2 1 2 i k j k i jH e       (2) Where (i, j) is the coordinate value of a certain point, and k is the template size value. Figure 3. Original Figure Figure 4. Gauss Filtered Figure 3.2 Pear Tree Crown Image Segmentation Image segmentation is the process of dividing the image into target and background and extracting the target area from the background (Feng, J. J., 2017; Fu, R., 2013). At present, the commonly used image segmentation algorithms include edge-based segmentation, threshold-based segmentation, region-based segmentation and segmentation based on specific theories, etc. But none of the segmentation methods are universal, and the use of specific problems need to be analyzed, according to the actual application scenarios and requirements to design and develop. In this paper, the OTSU threshold segmentation method is used to divide the image into two parts, the target and the background, and the inter-class variance between the two is the image segmentation threshold (Zhang, H. et al., 2008). Set an image I, whose gray level is 0~M, the number of pixels whose gray value is i is Ni, and the total pixel number of image I is N. The probability of each pixel value: (3) i i N P N  www.scholink.org/ojs/index.php/asir Applied Science and Innovative Research Vol. 9, No. 1, 2025 251 Published by SCHOLINK INC. According to the requirements of image segmentation, the image is divided into two parts: target image It, that is, foreground image, its gray level is 0~K, background image Ib, gray level is K+1~M, the probability of each part of the image can be obtained as follows: The probability of the target image: 1 1 M i b K i K N N        (4) The probability of the background image: (5) The average pixel value of global image I: (6) The average pixel value of the image It: (7) The average pixel value of image: (8) Global pixel mean: (9) The variance between the target and the background: (10) By bringing the formula (4), (5), (6), (7), (9) into the (10), it was reduced to the following form. (11) According to the threshold segmentation principle of OTSU method, a program was compiled in OpenCV software to perform threshold segmentation on the Gaussian filtered pear tree image. As shown in the figure, it can be seen that the background and trunk of the pear tree were cleared and the crown of the pear tree was segmented. However, it can be seen from the Figure 5 that too much information is extracted from the tree crown, resulting in the segmented tree crown profile being larger than the actual profile. This situation can be repaired by binary image morphology, such as corrosion and expansion, open and 0 0 K K i t i K i i N P N         1 M i i i N N      1 1 / / K K i i i i K t K K K i N i N N N N N             1 1 M i i K K b M K K i N N              t t b b      2 2 2( ) ( ) ( )t t b bk            2 2 ( ) ( ) ( ) ( )[1 ( )] K K K K K          www.scholink.org/ojs/index.php/asir Applied Science and Innovative Research Vol. 9, No. 1, 2025 252 Published by SCHOLINK INC. close operations, etc. (Hui, S. S., 2019). Finally, convolved the binary image with the original image of the pear tree after digital morphology, the complete crown image of the pear tree after restoration can be obtained. After using OpenCV software to add morphological processing and mask operation procedures, the final tree_crown_profile is shown in Figure 6. Figure 5. Tree_crown_profile Figure 6. Final Tree_crown_profile 4. Summarize For processing such as tree feature extraction, tree crown segmentation and 3D modeling, due to different tree types, planting patterns and growth environments, there is no universal algorithm suitable for all trees, and appropriate algorithms should be selected based on application scenarios and actual needs. In this paper, Gaussian filtering and threshold segmentation are used to complete the image processing of pear tree and extract the crown image of pear tree, which provides a basis for the subsequent prediction of crown volume and accurate spraying, etc. However, this method requires no shielding interference between pear trees, otherwise the segmentation effect will be affected, and the future optimization algorithm will be forgotten to improve the segmentation accuracy. Acknowledgement This work was supported by the President’s Fund of Tarim University (No. TDZKSS202121). References Feng, J. J. (2017). Research on single tree crown extraction based on gray gradient image segmentation. Journal of Beijing Forestry University, 2017(3), 16-23. Fu, R. (2013). Research progress of tree crown extraction technology. J. World Forestry Research, 2013(26), 38-42. https://doi.org/10.1002/rwm3.20017 www.scholink.org/ojs/index.php/asir Applied Science and Innovative Research Vol. 9, No. 1, 2025 253 Published by SCHOLINK INC. Hui, S. S. (2019). High-resolution image crown extraction by combining Gabor wavelet and morphology method. Journal of Geo-information Science, 2019(21), 249-258. Liu, X. et al. (2024). EBAPS image adaptive wavelet threshold denoising based on pixel dark noise estimation. J. Acta Optica Sinica., 44(16), 84-95. Zhang, H. et al. (2008). Tree crown extraction method combining color and texture features. J. OPTICAL TECHNIQUE, 2008(34), 613-616. Zhang, L. et al. (2024). Image quality dynamic noise reduction algorithm based on deep learning optimization. Journal of Lanzhou University of Arts and Science (Natural Science), 2024(38), 54-58. Zhang, Y. J. (2022). Image quality dynamic noise reduction algorithm based on deep learning optimization. Electronic Technology & Software Engineering, 2022(13), 190-193.