A trunk centerline extraction and three-dimensional reconstruction volume estimation method and system based on SegFormer segmentation and multi-scale curvature adaptive modeling
Patent Information
- Application Number
- CN202511089198.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-05
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2045-08-05
AI Technical Summary
[0005]为了解决现有树木体积计算时没有对树木进行分段计算或者分段时采用固定阈值分段导致的树木体积计算准确率低的问题,本发明提供一种基于SegFormer分割与多尺度曲率自适应建模的树干中线提取与三维重建体积估算方法和系统
[0040]本发明借助SegFormer模型实现树干区域的自动提取,通过多尺度曲率极值融合自适应分段算法,动态识别树干中线的几何变化拐点,构建树干每一分段的三维结构,再通过控制上下底面及分段高度在三维空间中对齐,逐段堆叠以还原完整树干结构并完成体积测算,提高了树木体积计算的准确率。
Smart Images

Figure CN121033264B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of tree volume calculation technology, and in particular to a method and system for extracting the trunk centerline and estimating the volume of three-dimensional reconstruction based on SegFormer segmentation and multi-scale curvature adaptive modeling. Background Technology
[0002] In the field of tree volume estimation, accurate calculation of individual tree trunk volume is a core component of forestry resource management, timber processing planning, and ecological carbon sequestration assessment. Currently, significant technical limitations remain in related practices.
[0003] On the one hand, some volume estimation methods do not perform segmented calculations of the tree trunk. Currently, China's basic forestry departments and timber processing enterprises still use the traditional volume table method to determine the trunk volume based on the diameter at breast height (DBH). Due to the complex shape of the tree trunk and the frequent changes in curvature, this neglect of segmentation directly leads to geometric fitting distortion, causing local structural distortions in the trunk, and consequently resulting in a significant deviation between the volume estimation results and the actual situation.
[0004] On the other hand, even with segmentation, existing technologies often employ fixed thresholds. However, this method performs poorly when dealing with trees of diverse shapes. Traditional fixed-threshold curvature analysis methods are ineffective for single-tree segmentation in complex natural forests, with accuracy dropping by approximately 50%. Fixed thresholds cannot adapt to dynamic changes in trunk curvature, making it difficult to accurately capture the true structural features of the trunk when dealing with complex natural forests or trees with unique shapes. This leads to a significant reduction in the accuracy of single-tree segmentation and trunk extraction, ultimately affecting the accuracy of tree volume estimation. Therefore, existing tree volume estimation techniques that do not segment or use fixed-threshold segmentation are no longer sufficient to meet the demands of accurate measurement, becoming a major bottleneck restricting the improvement of tree volume estimation accuracy. New technical solutions are urgently needed to address these issues. Summary of the Invention
[0005] To address the low accuracy of existing tree volume calculation methods, which either fail to segment the tree or use fixed thresholds for segmentation, this invention provides a method and system for extracting the trunk centerline and estimating 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling. This invention performs secondary processing on the initial trunk centerline using cubic B-spline curves, then dynamically segments the trunk centerline using an adaptive algorithm that fuses multi-scale curvature extrema, calculates the volume of each segment, and sums them to obtain the final tree volume. By processing the initial trunk centerline to obtain an accurate centerline and dynamically segmenting it, this invention ensures that the segment positions more closely match the actual shape of the tree, thus improving the accuracy of tree volume calculation.
[0006] To achieve the above objectives, the technical solution of the present invention is as follows:
[0007] The first aspect of this invention proposes a method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling, comprising:
[0008] Step 1: Collect image data of the target tree and preprocess it to facilitate subsequent calculation of tree volume;
[0009] Step 2: Perform tree trunk segmentation on the preprocessed image data based on the SegFormer semantic segmentation network to obtain a single-channel mask image of the tree trunk, which facilitates the determination of the tree trunk centerline;
[0010] Step 3: Obtain the trunk centerline based on the single-channel mask image of the trunk, which is used to extract the trunk skeleton;
[0011] Step 4: The trunk centerline is processed by an adaptive algorithm based on multi-scale curvature extremum fusion to obtain the trunk segment positions, and the target tree volume is estimated based on the trunk segment positions.
[0012] Furthermore, step three includes:
[0013] Extract the left and right edge coordinates of the tree trunk region boundary from each row of pixels in the single-channel mask image of the tree trunk, calculate the midpoint coordinates of the left and right edge coordinates, and construct the initial tree trunk centerline based on all the midpoint coordinates;
[0014] The initial trunk centerline is processed using cubic B-spline curves to obtain the trunk centerline, which is used to supplement the local missing parts of the initial trunk centerline and improve its continuity and smoothness.
[0015] Furthermore, the adaptive algorithm based on multi-scale curvature extremum fusion processes the tree trunk midline, specifically including:
[0016] Collect a two-dimensional point sequence that forms the midline of the tree trunk;
[0017] Calculate the first and second derivatives of each point in the two-dimensional point sequence, and obtain the curvature corresponding to the point based on the first and second derivatives. Construct a curvature sequence based on the curvature of all points.
[0018] By using a Gaussian smoothing kernel function and setting multiple scale parameters, the curvature sequence is processed under each scale parameter to obtain a smooth curvature sequence, which is used to enhance the ability to identify bending features at different scales.
[0019] The peak curvature points for each scale parameter are obtained from the smoothed curvature sequence;
[0020] By counting the number of times each point is a curvature peak point under different scale parameters, the position corresponding to the point that is the most frequent curvature peak point is taken as the trunk segment position, which helps to improve the accuracy of volume calculation.
[0021] Furthermore, the peak curvature point for each scale parameter is expressed by the following formula:
[0022]
[0023] in, scale parameter The curvature at the i-th point, scale parameter The curvature at the next ik-th point, scale parameter The curvature at the (i+k)th point is given by max, which is the maximum value.
[0024] Furthermore, the estimation of the target tree volume based on the segmented location of the trunk specifically includes:
[0025] Convert the image pixel length to the actual physical length;
[0026] The trunk is divided into multiple trunk units along the centerline of the trunk according to the segment positions of the trunk. The volume of each trunk unit is calculated according to the volume of a frustum whose upper and lower bases are not parallel, which helps to improve the accuracy of volume calculation.
[0027] The volume of the target trunk is obtained by adding the volumes of all the trunk units together.
[0028] Furthermore, the volume of the frustum whose upper and lower bases are not parallel is expressed by the following formula:
[0029]
[0030]
[0031] in, Let V be the volume of the frustum. For the first The actual distance from the midpoint of the upper base to the midpoint of the lower base of each trunk unit, where n is the total number of trunk units. The radius of the upper base is 1. Let be the radius of the bottom surface. The angle between the normal vectors of the upper and lower base surfaces is denoted as . For the first The projected height from the top surface to the bottom surface of each tree trunk unit. This represents the actual length corresponding to a unit pixel.
[0032] The second aspect of this invention proposes a system for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling, comprising:
[0033] The collection module is used to collect image data of the target trees and preprocess them to facilitate subsequent calculation of tree volume;
[0034] The segmentation module is used to segment the preprocessed image data into tree trunks based on the SegFormer semantic segmentation network, and obtain a single-channel mask image of the tree trunk, which facilitates the determination of the tree trunk midline.
[0035] The trunk centerline module is used to obtain the trunk centerline based on the single-channel mask image of the trunk, and is used to extract the trunk skeleton;
[0036] The volume estimation module is used to process the trunk centerline based on an adaptive algorithm that integrates multi-scale curvature extrema to obtain the trunk segment positions and estimate the target tree volume based on the trunk segment positions.
[0037] A third aspect of the present invention provides an electronic device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements a method for trunk midline extraction and 3D reconstruction volume estimation based on SegFormer segmentation and multi-scale curvature adaptive modeling as described in the first aspect above.
[0038] A fourth aspect of the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device on which the storage medium is located to perform a method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling as described in the first aspect above.
[0039] The beneficial effects of this invention are:
[0040] This invention utilizes the SegFormer model to automatically extract the tree trunk region. Through a multi-scale curvature extremum fusion adaptive segmentation algorithm, it dynamically identifies the geometric change inflection points of the tree trunk centerline, constructs the three-dimensional structure of each segment of the tree trunk, and then controls the alignment of the upper and lower bottom surfaces and segment heights in three-dimensional space to stack the segments one by one to restore the complete tree trunk structure and complete the volume calculation, thereby improving the accuracy of tree volume calculation.
[0041] This invention achieves 3D structural parameter estimation of trees based on a single image, filling a research gap in current single-image photogrammetry methods that cannot handle 3D parameters such as volume. Compared to 3D modeling methods based on multi-view images or LiDAR, this invention significantly simplifies the data acquisition and processing process, reduces costs and equipment dependence, expands the methodological path of photogrammetry in deriving 2D to 3D parameters, and improves the applicability of this field in resource-constrained environments. Attached Figure Description
[0042] Figure 1 The flowchart illustrates a method for extracting the trunk midline and estimating the 3D reconstruction volume based on SegFormer segmentation and multi-scale curvature adaptive modeling, provided in an embodiment of the present invention.
[0043] Figure 2 This is a schematic diagram of the segmentation results of different tree species provided in an embodiment of the present invention.
[0044] Figure 3 This is a schematic diagram illustrating the determination results of inflection points in curvature analysis using different thresholds provided in this embodiment of the invention.
[0045] Figure 4 This is a schematic diagram illustrating the result of misjudging the location of the multi-scale curvature extremum fusion adaptive algorithm provided in this embodiment of the invention when using a fixed threshold curvature segmentation method.
[0046] Figure 5 This is a schematic diagram illustrating the 3D reconstruction effect of the traditional fixed threshold curvature segmentation method and the adaptive algorithm for multi-scale curvature extremum fusion provided in this embodiment of the invention.
[0047] Figure 6 This is an architecture diagram of a tree trunk midline extraction and 3D reconstruction volume estimation system based on SegFormer segmentation and multi-scale curvature adaptive modeling, provided for an embodiment of the present invention. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0049] Example 1
[0050] like Figure 1 As shown, a method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling includes:
[0051] S101: Collect image data of the target trees and perform preprocessing.
[0052] Specifically, the images of the target trees were captured by a mobile phone camera (e.g., 50-megapixel, supporting 5x optical zoom, with focal lengths of 24 mm, 13 mm, and 125 mm). A tripod and laser rangefinder were used during shooting to ensure the phone was parallel to the tree trunk, capturing clear photos of a single tree trunk. Target trees with upright trunks, few branches, and nearly circular cross-sections were preferred.
[0053] In image processing, lens distortion significantly degrades image quality and measurement accuracy. This distortion is primarily caused by the curvature of the camera lens. Distortion not only affects the visual quality of the image but also introduces errors in the transformation from pixel coordinates to real-world spatial coordinates, thus reducing measurement accuracy.
[0054] To address this issue, this invention employs standard camera calibration techniques. Using calibration patterns such as checkerboards, along with specialized calibration software, the camera's internal parameter matrix (including focal length and principal point position) and lens distortion coefficients are estimated.
[0055] By capturing a series of checkerboard images and processing them using MATLAB's Camera Calibration Toolbox, the camera's intrinsic parameters and distortion coefficients were obtained.
[0056] Based on the standard radial and tangential distortion models, the distortion-corrected coordinates are calculated. The specific conversion formula is as follows:
[0057]
[0058]
[0059] in, and These are the x-axis and y-axis coordinates before distortion correction. and These are the x-axis and y-axis coordinates after distortion correction. and These are the equivalent focal lengths of the camera in the x and y directions, respectively. and These are the coordinates of the principal points in the x and y directions, respectively.
[0060] The above transformation is applied to all pixels of the image to generate a corrected image. Batch processing using the OpenCV library ultimately yields a set of geometrically accurate images.
[0061] After lens distortion correction, the images are further orthorectified for subsequent calculations. The orthorectification process utilizes internal camera parameters obtained during calibration, combined with external parameters such as camera shooting posture recorded by the smartphone's built-in inertial measurement unit (IMU). By combining internal and external parameters, each image is resampled and orthorectified to generate a high-precision orthorectified image suitable for subsequent analysis.
[0062] Preferably, during training, to construct the training dataset for the semantic segmentation model, the dataset is divided into training set, validation set, and test set according to 60%, 20%, and 20% of the number of images for each tree species, respectively. Pixel-level manual annotation is performed on the training set images, and the Labelimg tool in Python is used to perform fine annotation on each tree trunk region.
[0063] S102: Based on the SegFormer semantic segmentation network, the preprocessed image data is segmented into a tree trunk to obtain a single-channel mask image of the tree trunk.
[0064] Specifically, the SegFormer semantic segmentation network is used for trunk segmentation. SegFormer is an efficient semantic segmentation model that combines a Transformer encoder and a lightweight multilayer perceptron (MLP) decoder. It can significantly reduce computational overhead while maintaining high accuracy, and is suitable for processing large-scale remote sensing images and natural scene images.
[0065] During training data preparation, the original images and their corresponding tree trunk masks were divided into training, validation, and test sets in an 8:1:1 ratio. All images were uniformly scaled to 1024×1024 pixels and normalized. To improve the model's generalization ability, data augmentation strategies such as random rotation, horizontal flipping, and color perturbation were introduced.
[0066] The SegFormer semantic segmentation network uses the cross-entropy loss function as its optimization objective, which takes the following form:
[0067]
[0068] in, Let cross-entropy be the loss function. Total number of pixels For the number of categories, Indicates the first The pixel in the first The true label of the class, This represents the probability predicted by the model. The Adam optimizer is used during training, with an initial learning rate set to [value missing]. The batch size is 16, and the maximum number of iterations is 100.
[0069] S103: Obtain the trunk centerline based on the single-channel mask image of the trunk.
[0070] Specifically, based on the obtained single-channel mask image of the tree trunk, this invention extracts the tree trunk centerline, i.e., the tree trunk skeleton. The purpose of this process is to obtain the main axis of the tree trunk region for subsequent processing such as curvature analysis, structural reconstruction, and morphological parameter estimation.
[0071] After obtaining a single-channel mask image of the tree trunk using semantic segmentation, the left and right edge coordinates of the tree trunk region boundary are extracted from each row of pixels, and the coordinates of its center point are calculated as the corresponding midline point of that row. However, due to potential edge breaks and mask discontinuities in real images, the directly extracted midline exhibits local missing points. To eliminate the discrete interference caused by image segmentation errors and jagged edges, and to improve the continuity and smoothness of the midline, this invention employs B-spline interpolation to fit the initially extracted center points. Let the center point sequence be... The fitted cubic B-spline curve can be expressed as:
[0072]
[0073] in, For parameters The lower curve position, For the first One control point, Representation based on node vectors The constructed cubic B-spline basis functions, where n is the total number of control points. Let k be the vector of the kth node. It is the vector of the (n+1)th node.
[0074] The basis functions are defined recursively, exhibiting good local controllability and high smoothness. Compared to traditional interpolation methods, B-spline fitting effectively reduces midline fluctuations caused by image noise or boundary irregularities while ensuring curve continuity.
[0075] S104: An adaptive algorithm based on multi-scale curvature extremum fusion is used to process the trunk centerline to obtain the trunk segment positions, and the target tree volume is estimated based on the trunk segment positions.
[0076] This invention collects images of target trees by capturing pictures with a mobile phone camera. Then, it uses the SegFormer semantic segmentation network to segment the tree trunk, obtaining a single-channel mask image of the trunk. The single-channel mask image is then processed to obtain the trunk centerline. Finally, an adaptive algorithm using multi-scale curvature extremum fusion is employed to segment the trunk, calculate the volume of each segment, and thus obtain the volume of the target tree. This invention can accurately calculate the volume of a tree through segmentation.
[0077] Example 2
[0078] Based on the above embodiments, this invention proposes an adaptive algorithm for multi-scale curvature extremum fusion, specifically including:
[0079] Specifically, in trunk midline curvature analysis, determining the appropriate trunk segmentation positions is a key factor in the accuracy of 3D reconstruction. Most existing studies use a fixed threshold for curvature analysis, but this invention primarily targets the trunk. Different tree trunks exhibit significant differences in curvature degree and structural complexity, making it difficult to balance accuracy and generalization when using a uniform threshold. Therefore, this invention proposes an adaptive algorithm for multi-scale curvature extremum fusion to segment the trunk, enhancing the algorithm's adaptability to different tree species and structural conditions.
[0080] Suppose the tree trunk centerline is composed of two-dimensional points. The composition is defined as a discretized spatial curve. Among them, and Let x and y be the x-axis and y-axis coordinates of the i-th point in the two-dimensional point sequence, respectively, and N be the total number of points in the two-dimensional point sequence. After processing the initial tree trunk centerline through the above spline interpolation, a smooth tree trunk centerline is obtained. Its first and second derivatives are calculated to obtain the curvature sequence. To enhance the ability to identify curvature features at different scales, a Gaussian smoothing kernel function is introduced. Multiple scale parameters are set and fed into the Gaussian smoothing kernel function, and the curvature sequences are filtered at multiple scales to obtain multiple sets of smoothed curvature sequences. .
[0081] At each scale, a local extremum detection algorithm is used to extract the curvature peak points. Specifically, for each point... If it satisfies the following conditions:
[0082]
[0083] in, scale parameter The curvature at the i-th point, scale parameter The curvature at the next ik-th point, scale parameter The curvature at the (i+k)th point is given by max, which is the maximum value.
[0084] This is then considered a local maximum curvature point at that scale. Subsequently, the locations of the extreme points detected at each scale are merged, and the frequency of each point being identified as an extreme point at different scales is counted. Stable curvature peak points (inflection points) are selected based on the frequency and used as the final adaptive trunk segmentation positions.
[0085] Example 3
[0086] Based on the above embodiments, the present invention proposes a method for calculating tree volume, specifically including:
[0087] To achieve scale mapping from image pixel space to actual physical space (i.e., the single-channel mask image of the tree trunk and its pixel-to-actual-size conversion), this invention utilizes the distance D between the camera and the target tree trunk recorded during single-image capture (obtained by a laser rangefinder), combined with the focal length f obtained from camera calibration and the publicly disclosed camera sensor size s, to establish a proportional conversion relationship between pixels and actual unit length, specifically expressed by the following formula:
[0088]
[0089] in, This indicates the actual length corresponding to a unit pixel (unit: mm / pixel). The distance from the camera to the tree trunk (unit: mm). This refers to the actual dimensions (such as width) of the sensor in the corresponding direction. For camera focal length, This represents the number of pixels in the image in that direction.
[0090] After obtaining the single-channel mask image of the tree trunk and its pixel-to-actual-size conversion relationship, the tree trunk is divided into multiple trunk units along the trunk centerline according to the segment positions. Based on the proportional relationship, centerline position, and trunk edges, the trunk units are 3D-rendered in Blender software. Each trunk unit is then stacked sequentially along the trunk centerline to construct the overall tree trunk structure. Each segment is considered a frustum of a cone with its upper and lower surfaces not parallel, and its volume formula is:
[0091]
[0092]
[0093] in, Let V be the volume of the frustum. For the first The actual distance from the midpoint of the upper base to the midpoint of the lower base of each trunk unit, where n is the total number of trunk units. The radius of the upper base is 1. Let be the radius of the bottom surface. The angle between the normal vectors of the upper and lower base surfaces is denoted as . For the first The projected height from the top surface to the bottom surface of each tree trunk unit. This represents the actual length corresponding to a unit pixel.
[0094] Preferably, to ensure spatial alignment, the segmented units are placed sequentially along the trunk centerline, with the direction determined by the tangent direction of the centerline at the corresponding position and the position controlled by the centerline coordinates, thereby ensuring the spatial continuity and curvature consistency of the entire structure.
[0095] Example 4
[0096] Based on the above embodiments, this invention proposes an accuracy verification process for a tree trunk midline extraction and 3D reconstruction volume estimation method based on SegFormer segmentation and multi-scale curvature adaptive modeling, specifically including:
[0097] To verify the accuracy and stability of the method of the present invention in terms of single-tree segmentation performance and trunk parameter estimation, two sets of evaluation index systems were designed.
[0098] The segmentation performance of the SegFormer model was evaluated using image samples from a test set, including 147 JAP (Chinese scholar tree), 146 DAV (Chinese poplar), 158 TAB (Chinese pine), and 151 MON (Chinese oak). Four image segmentation evaluation metrics—Intersection over Union (IoU), Dice Similarity Coefficient, Precision, and Recall—were selected to analyze the segmentation results for different tree species in the test set.
[0099] The trunk parameters of sample trees for which image acquisition, point cloud scanning, and felling measurements were completed were calculated. The sample trees included 37, 42, 40, and 22 trees for the four species: JAP, DAV, TAB, and MON, respectively. After obtaining the results, a multi-dimensional error evaluation index was used to systematically evaluate the accuracy of this invention in structural measurement. Using the felling measurement results as the ground truth, the evaluation indexes employed included: Coefficient of Determination (R²), Relative Error (RE), Bias, Relative Bias (rBias), Root Mean Square Error (RMSE), and Relative RMSE (rRMSE), quantifying the performance and reliability of the measurement method from multiple dimensions.
[0100] Segmentation accuracy evaluation: The SegFormer model's segmentation performance for the four tree species is as follows: Figure 2 As shown, Figure 2 In the image, (a1), (a2), (a3), and (a4) represent MON, TAB, DAV, and JAP, respectively, while (b1), (b2), (b3), and (b4) represent the masking results for different tree species. The model can accurately identify and extract the trunk region, achieving effective separation of the trunk contour and foreground extraction in images of different tree species.
[0101] Table 1 shows the segmentation accuracy of the SegFormer model for the four tree species. Among all tree species, DAV performs best, with an IoU of 85.35%, a Dice coefficient of 92.09%, an overall accuracy of 99.68%, and a recall of 92.44%. Similarly, MON also performs well, with an IoU of 83.10% and a Dice coefficient of 90.77%, and a recall of 90.28%. JAP has slightly lower segmentation accuracy, with an IoU of 79.28% and a recall of 84.74%, but its accuracy remains at a high level of 99.73%. In contrast, TAB performs the weakest, with an IoU of 72.50% and a Dice coefficient of 79.06%.
[0102]
[0103] Adaptive Algorithm for Multi-Scale Curvature Extremum Fusion: This invention compares the inflection point detection effects of segmented methods using fixed curvature threshold segmentation and multi-scale curvature extremum fusion adaptive algorithms, such as... Figure 3 As shown. Figure 3The following images are displayed from left to right: (a1) to (a4) are single-channel mask results after deep learning segmentation for different tree species; (b1) to (b4) are the higher threshold recognition results corresponding to (a1) to (a4), with the marked areas being the minor bends that are ignored; (c1) to (c4) are magnified views of the marked areas corresponding to (b1) to (b4), with blue circles marking the unrecognized areas; (d1) to (d4) are the lower threshold recognition results corresponding to (c1) to (c4), with the marked areas generating a large number of false inflection points; (e1) to (e4) are magnified views of the marked areas corresponding to (d1) to (d4), with red circles marking the false recognition areas.
[0104] When tree trunks have complex shapes or multiple levels of curvature, traditional methods based on fixed curvature thresholds struggle to accurately extract all structural inflection points. While setting the curvature threshold too high can identify inflection points in clearly curved areas of the trunk, it easily overlooks subtle bends in straight sections, such as… Figure 3 The unidentified areas in (c1)-(c4) are shown; however, when the threshold is set too low, the algorithm becomes highly sensitive to small perturbations, which may cause over-segmentation, generating a large number of false inflection points and affecting the accuracy and stability of subsequent modeling, such as... Figure 3 The unidentified areas are shown in (e1)-(e4).
[0105] To verify the effectiveness of the adaptive algorithm for multi-scale curvature extremum fusion in handling complex tree structures, this invention employs an adaptive algorithm to re-detect and optimize the segments at locations where the traditional fixed-threshold curvature segmentation method misjudges the data. For example... Figure 4 As shown in (b1)-(b4) and (d1)-(d4), the adaptive algorithm for multi-scale curvature extremum fusion achieves more reasonable structure recognition and curvature inflection point capture in regions where segmentation omission or over-segmentation occurs in traditional algorithms. Figure 4The diagrams (a1-e1), (a2-e2), (a3-e3), and (a4-e4) represent the centerlines of four tree trunks. From left to right, they show: (a1) to (a4) the pseudo-inflection points detected by the fixed threshold curvature method for different tree trunks, marked as erroneous detection points; (b1) to (b4) the detection results of the adaptive algorithm for multi-scale curvature extremum fusion for different tree trunks; (c1) to (c4) the overall detection results of the adaptive algorithm for multi-scale curvature extremum fusion for the tree trunk centerlines for different tree trunks, marked as the detection positions corresponding to parts a, b, d, and e; (d1) to (d4) the detection results of the adaptive segmented algorithm for multi-scale curvature extremum fusion for different tree trunks (the detection positions are different from (a1) to (a4); and (e1) to (e4) the inflection points not detected by the fixed threshold curvature method for different tree trunks, marked as erroneous detection points.
[0106] Evaluation Criteria: To compare the error performance of the fixed curvature threshold segmentation method and the adaptive algorithm that fuses multi-scale curvature extrema in 3D tree trunk modeling, this invention selects three sample trees with different trunk shapes (significantly curved, slightly curved, and straight) for volume estimation. Figure 5 As shown. Figure 5 Images (a1) to (d1), (a2) to (d2), and (a3) to (d3) represent the images of the three trees. From left to right, the images are shown as follows: (a) is a segmentation diagram of the adaptive algorithm for multi-scale curvature extremum fusion; (b) is an enlarged view of the marked area in image (a); (c) is a segmentation diagram with a fixed curvature threshold; and (d) is an enlarged view of the marked area in image (c).
[0107] The results show that in tree 1, which has the most pronounced curvature, the relative error of the adaptive algorithm is 3.57%, while that of the fixed threshold method is 4.63%, indicating a systematic underestimation. In tree 2, which has a slight curvature, the errors of the two algorithms are 2.85% and 3.54%, respectively, with the fixed threshold method slightly overestimating the error. In tree 3, which is straight, the error of the adaptive algorithm drops to 2.27%, while that of the fixed threshold method is 2.63%.
[0108] In summary, the results of various verifications demonstrate the feasibility of this invention. The SegFormer model exhibits good segmentation capabilities on images of different tree species, with IoU ranging from 72.50% to 85.35%. However, significant differences remain in segmentation performance among different tree species. DAV (Aspen) and MON (Oak) trees are characterized by strong texture contrast and clear trunk outlines, which is beneficial for the model to extract significant boundaries and achieve higher segmentation accuracy. In contrast, JAP (Chinese Scholar Tree) and TAB (Pinus tabuliformis) trees often suffer from branch interference or needle occlusion, resulting in decreased foreground-background differentiation, increased model misclassification rate, and relatively lower segmentation performance.
[0109] This invention employs an adaptive algorithm based on multi-scale curvature extremum fusion to address the problems of poor sensitivity and weak parameter generalization in fixed-threshold curvature segmentation. The segmentation results of the adaptive algorithm based on multi-scale curvature extremum fusion are approximately 23% higher than those based on fixed-threshold curvature. This is because fixed-threshold curvature segmentation deviates from the actual geometric inflection point in each segment unit during 3D reconstruction, resulting in local errors that gradually accumulate and propagate to the overall volume result. Therefore, it is even more crucial to use an adaptive algorithm based on multi-scale curvature extremum fusion to maintain compatibility with different tree trunk structures during trunk segmentation. This invention has promising application prospects, particularly suitable for grassroots forestry surveys, forest carbon sink measurement, and commercial forest resource assessment before timber harvesting and transportation. It can provide efficient and low-cost technical support for precise forestry management and carbon measurement.
[0110] Example 5
[0111] Based on the above embodiments, such as Figure 6 As shown, this invention proposes a tree trunk midline extraction and 3D reconstruction volume estimation system based on SegFormer segmentation and multi-scale curvature adaptive modeling, comprising:
[0112] The collection module is used to collect image data of the target trees and perform preprocessing.
[0113] The segmentation module is used to perform trunk segmentation on the preprocessed image data based on the SegFormer semantic segmentation network to obtain a single-channel mask image of the trunk.
[0114] The trunk centerline module is used to obtain the trunk centerline based on the single-channel mask image of the trunk.
[0115] The volume estimation module is used to process the trunk centerline based on an adaptive algorithm that integrates multi-scale curvature extrema to obtain the trunk segment positions and estimate the target tree volume based on the trunk segment positions.
[0116] It should be noted that the tree trunk midline extraction and 3D reconstruction volume estimation system based on SegFormer segmentation and multi-scale curvature adaptive modeling provided in this embodiment of the invention is to implement the above-mentioned tree trunk midline extraction and 3D reconstruction volume estimation method based on SegFormer segmentation and multi-scale curvature adaptive modeling. Its specific functions can be referred to the above-mentioned method embodiments, and will not be repeated here.
[0117] Example 6
[0118] Based on the above embodiments, the present invention proposes an electronic device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for extracting the trunk midline and estimating the three-dimensional reconstruction volume based on SegFormer segmentation and multi-scale curvature adaptive modeling as described in Embodiment 1 above.
[0119] Example 7
[0120] Based on the above embodiments, the present invention also proposes a computer-readable storage medium, the storage medium including a stored computer program, wherein, when the computer program is running, it controls the device where the storage medium is located to execute a method for extracting the trunk midline and estimating the three-dimensional reconstruction volume based on SegFormer segmentation and multi-scale curvature adaptive modeling as described in Embodiment 1 above.
[0121] In summary, this invention utilizes the SegFormer model to automatically extract the tree trunk region. Through a multi-scale curvature extremum fusion adaptive segmentation algorithm, it dynamically identifies the geometric change inflection points of the tree trunk centerline, constructs the three-dimensional structure of each segment of the tree trunk, and then controls the alignment of the upper and lower bottom surfaces and segment heights in three-dimensional space to stack the segments one by one to restore the complete tree trunk structure and complete the volume calculation.
[0122] This invention achieves 3D structural parameter estimation of trees based on a single image, filling a research gap in current single-image photogrammetry methods that cannot handle 3D parameters such as volume. Compared to 3D modeling methods based on multi-view images or LiDAR, this invention significantly simplifies the data acquisition and processing process, reduces costs and equipment dependence, expands the methodological path of photogrammetry in deriving 2D to 3D parameters, and improves the applicability of this field in resource-constrained environments.
[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling, characterized in that, include: Step 1: Collect image data of the target trees and perform preprocessing; Step 2: Perform trunk segmentation on the preprocessed image data based on the SegFormer semantic segmentation network to obtain a single-channel mask image of the trunk; Step 3: Obtain the trunk centerline based on the single-channel mask image of the trunk; Step 4: Process the trunk centerline using an adaptive algorithm based on multi-scale curvature extremum fusion to obtain the trunk segment positions, and estimate the target tree volume based on the trunk segment positions; Step three includes: Extract the left and right edge coordinates of the tree trunk region boundary from each row of pixels in the single-channel mask image of the tree trunk, calculate the midpoint coordinates of the left and right edge coordinates, and construct the initial tree trunk centerline based on all the midpoint coordinates; The trunk centerline is obtained by processing the initial trunk centerline using a cubic B-spline curve; The adaptive algorithm based on multi-scale curvature extremum fusion processes the tree trunk midline, specifically including: Collect a two-dimensional point sequence that forms the midline of the tree trunk; Calculate the first and second derivatives of each point in the two-dimensional point sequence, and obtain the curvature corresponding to the point based on the first and second derivatives. Construct a curvature sequence based on the curvature of all points. By using the Gaussian smoothing kernel function and setting multiple scale parameters, the curvature sequence is processed under each scale parameter to obtain a smooth curvature sequence; The peak curvature points for each scale parameter are obtained from the smoothed curvature sequence; The number of times each point is a curvature peak point is counted under different scale parameters, and the position corresponding to the point that is the most frequent curvature peak point is taken as the trunk segment position.
2. The method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling according to claim 1, characterized in that, The peak curvature point for each scale parameter is expressed by the following formula: in, scale parameter The curvature at the i-th point, scale parameter The curvature at the next ik-th point, scale parameter The curvature at the (i+k)th point, where max is the maximum value.
3. The method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling according to claim 1, characterized in that, The estimation of the target tree volume based on the segmented location of the trunk specifically includes: Convert the image pixel length to the actual physical length; The trunk is divided into multiple trunk units along the centerline of the trunk according to the segment positions of the trunk. The volume of each trunk unit is calculated based on the volume of a frustum whose upper and lower bases are not parallel. The volume of the target trunk is obtained by adding the volumes of all the trunk units together.
4. The method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling according to claim 3, characterized in that, The volume of the frustum whose upper and lower bases are not parallel is expressed by the following formula: in, Let V be the volume of the frustum. For the first The actual distance from the midpoint of the upper base to the midpoint of the lower base of each trunk unit, where n is the total number of trunk units. Where is the radius of the upper base. Let be the radius of the bottom surface. The angle between the normal vectors of the upper and lower base surfaces is... For the first The projected height from the top surface to the bottom surface of each tree trunk unit. This represents the actual length corresponding to a unit pixel.
5. A system for extracting tree trunk midline and estimating 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling, characterized in that, include: The collection module is used to collect image data of the target trees and perform preprocessing. The segmentation module is used to perform trunk segmentation on the preprocessed image data based on the SegFormer semantic segmentation network to obtain a single-channel mask image of the trunk. The trunk centerline module is used to obtain the trunk centerline based on the single-channel mask image of the trunk; The volume estimation module is used to process the trunk centerline based on an adaptive algorithm that integrates multi-scale curvature extremum fusion, obtain the trunk segment positions, and estimate the target tree volume based on the trunk segment positions. The trunk centerline module includes: Extract the left and right edge coordinates of the tree trunk region boundary from each row of pixels in the single-channel mask image of the tree trunk, calculate the midpoint coordinates of the left and right edge coordinates, and construct the initial tree trunk centerline based on all the midpoint coordinates; The trunk centerline is obtained by processing the initial trunk centerline using a cubic B-spline curve; The adaptive algorithm based on multi-scale curvature extremum fusion processes the tree trunk midline, specifically including: Collect a two-dimensional point sequence that forms the midline of the tree trunk; Calculate the first and second derivatives of each point in the two-dimensional point sequence, and obtain the curvature corresponding to the point based on the first and second derivatives. Construct a curvature sequence based on the curvature of all points. By using the Gaussian smoothing kernel function and setting multiple scale parameters, the curvature sequence is processed under each scale parameter to obtain a smooth curvature sequence; The peak curvature points for each scale parameter are obtained from the smoothed curvature sequence; The number of times each point is a curvature peak point is counted under different scale parameters, and the position corresponding to the point that is the most frequent curvature peak point is taken as the trunk segment position.
6. An electronic device, characterized in that, The method includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements a method for extracting the trunk midline and estimating the 3D reconstructed volume based on SegFormer segmentation and multi-scale curvature adaptive modeling as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The storage medium includes a stored computer program, wherein, when the computer program is running, it controls the device where the storage medium is located to execute a method for extracting the trunk midline and estimating the 3D reconstruction volume based on SegFormer segmentation and multi-scale curvature adaptive modeling as described in any one of claims 1 to 4.