Method, device, equipment and storage medium for multi-element extraction and vectorization of as-built drawings

Through the improved Mask2Former model and differentiated vectorization strategy, the efficiency and accuracy issues of feature extraction and vectorization in the completion map of high-standard farmland construction projects were solved, and high-precision multi-feature extraction and classification processing were achieved to meet the requirements of geographic information systems.

CN120656201BActive Publication Date: 2025-10-17NORTHWEST A & F UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511156300.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-19
Publication Date
2025-10-17
Estimated Expiration
2045-08-19

AI Technical Summary

Technical Problem

Traditional methods are inefficient and inaccurate in feature extraction and vectorization of completion drawings of high-standard farmland construction projects, making it difficult to meet the requirements of modern geographic information systems for high-precision, integrity, and consistency of data. Especially in complex scenarios, problems such as jagged boundaries, breakpoints, and discontinuities are prone to occur.

Method used

An improved Mask2Former semantic segmentation model is adopted, combined with SwinTransformerV2 and DeformableFPN network, and the segmentation accuracy and robustness of the model are improved through data enhancement strategy. The edge-aware attention module and differential vectorization strategy are combined to generate high-quality vector files.

Benefits of technology

It significantly improves the segmentation accuracy and vectorization quality of complex elements in the as-built drawings, solves problems such as jagged boundaries and breakpoints in existing technologies, and achieves efficient and accurate multi-element extraction and classification processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120656201B_ABST
    Figure CN120656201B_ABST
Patent Text Reader

Abstract

The application provides a completion map multi-element extraction and vectorization method, device, equipment and storage medium. It relates to the technical field of completion map processing. The method comprises: segmenting the completion map to obtain binary mask images of fields, roads, canals, buildings and wellheads; performing opening and closing operations, morphological smoothing, noise removal and / or hole filling operations on each binary mask image to generate optimized single-class masks; dividing the optimized single-class masks into three categories of surface elements, linear elements and point elements according to the element geometric type, and respectively using a vectorization strategy to generate a vector file; and writing the geographic coordinate system and projection parameters of the completion map into the corresponding vector file to generate an independent layer file with geographic coordinate reference. The application significantly improves the completion map element extraction accuracy, complex element processing capability, vectorization quality and efficiency, and enhances the robustness of the model in complex scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of as-built drawing processing, and in particular to a method and device for extracting and vectorizing multiple elements of an as-built drawing, equipment and a storage medium. BACKGROUND

[0002] High-standard farmland construction is an important measure to promote agricultural modernization. After the completion of high-standard farmland construction projects, as-built drawings, as an important carrier of project results, record the accurate information of key geographic elements such as fields, roads, canals, buildings, and wellheads. These information is crucial for understanding the actual situation of farmland construction, evaluating project effectiveness, and subsequent farmland management and utilization.

[0003] Converting the information on as-built drawings into vector data (such as the commonly used ESRIShapefile format) that can be managed, analyzed, and used in GIS (Geographic Information System) software is of great importance in project verification and comparison, post-management and protection, and national spatial planning. In project verification and comparison, vector data can be accurately overlaid with other related data (such as land use status data, planning data, etc.) for analysis, quickly and accurately identifying problems in project construction, such as whether the construction scope is accurate and whether the construction content meets planning requirements, ensuring that project construction meets relevant standards and specifications, and protecting the effective use of national investment in high-standard farmland construction.

[0004] Traditional methods of extracting and vectorizing elements of as-built drawings for high-standard farmland construction projects mainly rely on manual drawing or simple image processing algorithms. Manual drawing is not only inefficient, but also consumes a lot of manpower, resources, and time, and is easily affected by human factors, resulting in low accuracy, information omission or errors, and other problems. Early vectorization methods based on simple image processing algorithms, while improving efficiency to some extent, have poor segmentation accuracy and vectorization accuracy for complex as-built drawings, especially when dealing with elements of different shapes, significant size differences, high background noise interference, and a large number of irregular structures. For example, when extracting field boundaries, it is difficult to accurately capture complex boundary curves, resulting in severe boundary jaggedness; for winding canals and roads, there are problems such as breakpoints, discontinuity, or deviation in centerline extraction; and when identifying point elements such as wellheads, they are easily affected by the surrounding environment and prone to misjudgment or omission. In addition, traditional methods have limited ability to simultaneously extract and classify multiple elements in as-built drawings, making it difficult to meet the requirements of modern geographic information systems for high-precision, completeness, and consistency of data, and unable to efficiently provide reliable data support for project verification, management and protection, and national spatial planning of high-standard farmland construction projects. SUMMARY

[0005] The application provides a completed map multi-element extraction and vectorization method, device, equipment and storage medium to solve the technical problem proposed by the background technology.

[0006] In a first aspect, the application provides a completed map multi-element extraction and vectorization method, comprising:

[0007] Segmenting the completed map to obtain binary mask images of fields, roads, water channels, buildings and wellheads; wherein the completed map is a raster format completed map containing geographic element information;

[0008] Performing open-close operation, morphological smoothing, noise removal and / or hole filling operation on each binary mask image to generate an optimized single-class mask;

[0009] According to the element geometric type, the optimized single-class mask is divided into three categories of planar elements, linear elements and point elements, and the following vectorization strategies are respectively adopted to generate a vector file: for planar elements, a polygon vector is generated after simplifying the mask boundary; for linear elements, a centerline vector is generated by skeleton extraction; for point elements, a point vector is generated by calculating the connected domain centroid of the mask;

[0010] Write the geographic coordinate system and projection parameters of the completed map into the corresponding vector file to generate an independent layer file with geographic coordinate reference.

[0011] In a possible design, segmenting the completed map to obtain binary mask images of fields, roads, water channels, buildings and wellheads comprises: inputting the completed map into a semantic segmentation model to output binary mask images of fields, roads, water channels, buildings and wellheads; wherein the semantic segmentation model is an improved Mask2Former semantic segmentation model;

[0012] In the improved Mask2Former semantic segmentation model, the backbone network part adopts a SwinTransformerV2 structure instead of a ResNet; wherein the SwinTransformerV2 structure performs step-by-step feature extraction on the input image by constructing a hierarchical structure, performs local attention calculation on a fixed-size non-overlapping window inside each level, and realizes information flow across windows by introducing a shift window mechanism;

[0013] In the improved Mask2Former semantic segmentation model, a deformable convolution feature pyramid network is added in the neck structure, and the operation process of the deformable convolution feature pyramid network is represented as:

[0014] ,

[0015] In the formula, represents the output position a response of the query vector, an input feature map, a weight of a convolution kernel, k a position of the weight, a standard sampling offset, a variable offset learned through convolution, a position number;

[0016] In the improved Mask2Former semantic segmentation model, when initializing the query vector, the feature mean and variance are extracted to generate a code by the statistical element space distribution heat map, which is spliced or added to the basic query vector to form a class-guided query vector.

[0017] In the improved Mask2Former semantic segmentation model, an edge-aware attention module is integrated into the decoder, which guides attention by explicitly introducing an edge map. In the interaction process between each mask feature and the input feature, an edge response map extracted by a Sobel operator is introduced, and the attention map is modulated with the edge response map as the weight.

[0018] When training the improved Mask2Former semantic segmentation model, the weighted combination of boundary IoU loss and class-sensitive mask loss is used as the loss function.

[0019] In a possible design, before inputting the completion map into the semantic segmentation model, a step of performing data enhancement on the completion map is further included; wherein the data enhancement step includes Gaussian filtering, non-local mean denoising, image contrast enhancement, and interference enhancement.

[0020] The processing process of the Gaussian filtering is represented as:

[0021] ,

[0022] In the formula, sigma is the control of blur intensity, x and y are the symmetric coordinates of the kernel center, exp is the exponential function, is the kernel function;

[0023] The processing process of the non-local mean denoising is represented as:

[0024] ,

[0025] In the formula, is the pixel value after denoising, is a weight function, is a filtering scale factor, is a normalization factor, is a search window, For the original pixel value of the noisy image at pixel position , For the original pixel value of the noisy image at pixel position , For the pixel position;

[0026] The processing procedure of the image contrast enhancement is represented as:

[0027] ,

[0028] In the formula, α is the disturbance intensity, and is a two-dimensional random displacement field after Gaussian kernel smoothing, is the pixel coordinate after contrast enhancement;

[0029] The interference enhancement includes:

[0030] The pseudo-text noise block with superimposed random position, font and size is taken as an occlusion to simulate the non-structural information of paper annotations and / or seals, and the image brightness and hue are disturbed in a HSV color space shaking mode, and a small amplitude fluctuation is added to the hue, saturation and brightness channels respectively to construct a light distribution difference scene.

[0031] In a possible design, an open-close operation, morphological smoothing, noise removal and / or hole filling operation are performed on each binary mask image to generate an optimized single-class mask, including:

[0032] For the building binary mask image, a morphological closing operation is performed by using a seven-by-seven cross-shaped structural element to fill the gaps and improve the mask connectivity by closing the broken edges; wherein the calculation process of the morphological closing operation is represented as:

[0033] ,

[0034] In the formula, represents a binary mask image, is a seven-by-seven cross-shaped structural element, is an expansion operation, is an erosion operation;

[0035] For the binary mask image of the water channel, an area threshold filtering operation is performed to remove isolated noise spots: the area of each connected domain is calculated and a minimum reserved area threshold is set, and the noise region with an area smaller than the minimum reserved area threshold is set as the background; wherein the calculation formula of the area of the connected region is:

[0036] ,

[0037] In the formula, represents thei The area of ​​the connected region, is a set of pixels;

[0038] For the binary mask image of the field, the morphological gradient of the original mask is calculated, and the mask reconstruction operation is performed to fuse the original image structure and smooth contour. The repair process is guided by the marker map to eliminate isolated jagged edges and small-scale edge offsets, and generate a field mask image with continuous structure and regular boundaries.

[0039] In a possible design, the vectorization strategy adopted by the planar element specifically includes:

[0040] Perform morphological closing operation on the optimized single-category mask of the area feature to fill the internal pores and boundary gaps;

[0041] According to the gradient magnitude and gradient direction of the binary mask image, the continuous edges in the binary mask image are determined to form a closed boundary contour; wherein the calculation formulas for the gradient magnitude and gradient direction are:

[0042] ,

[0043] Where, is the gradient amplitude, I x and I y is the gradient of the image in the horizontal and vertical directions, is the gradient direction;

[0044] Compress the boundary point sequence, use the farthest point distance error as the simplification criterion, and output the approximate polygon represented by the point sequence. The last item of the point sequence returns to the starting point to ensure topological closure, and generate a polygon vector. The point sequence is expressed as:

[0045] ,

[0046] Where, P Represents the sequence of field outer contour points, 、 and Represents the coordinates of different contour points.

[0047] In one possible design, the vectorization strategy adopted for the linear features and point features specifically includes:

[0048] For linear elements, the optimized single-class mask of linear elements is subjected to central axis transformation to generate a one-pixel-wide skeleton structure, and local maximum points are extracted by distance transformation to form a skeleton path; the Freeman chain code is used to describe the direction change of the skeleton line segment in an eight-neighborhood pattern, discontinuous segments are identified and connected by linear interpolation, and the zigzag path is smoothed to generate a centerline vector represented by an ordered point list;

[0049] For point elements, independent entity regions are identified based on 8-adjacent relationship and assigned with unique labels; for each connected region The geometric center is calculated as the entity position coordinate, and the calculation formula is:

[0050] ,

[0051] In the formula, is the pixel number of the i-th region, i is the centroid coordinate of the i-th region, is the coordinate belonging to the connected region .

[0052] In one possible design, the geographic coordinate system and projection parameters of the as-built map are written into the corresponding vector file to generate an independent layer file with geographic coordinate reference, including:

[0053] Key geographic information is extracted from the image header file of the original as-built map, including the GeoTransform parameter describing the linear mapping relationship between image coordinates and geographic spatial coordinates, and the projection information determining the projection coordinate system to which the TIFF image belongs;

[0054] The CreateLayer function in the GDAL library is called to generate corresponding point, line or face layers for each type of vectorized element result, and the CreateLayer function receives parameters such as layer name, drive type, spatial reference object and geometric type to ensure that the output file format and geometric structure meet the set standards;

[0055] For each layer generated, the SetSpatialRef function is called to inject the projection information extracted from the original as-built map into the layer to establish the spatial reference system of the layer;

[0056] The SetGeoTransform function is called to bind the extracted GeoTransform parameter to the output layer, so that the coordinate position of the spatial element in the vector layer is mapped from the pixel index to the actual geographic coordinate, generating an independent layer file with real geographic position attribute.

[0057] In a second aspect, the present application provides a as-built map multi-element extraction and vectorization device, the device comprising:​

[0058] an image segmentation module configured to segment the as-built map to obtain binary mask images of the field, the road, the water channel, the building, and the wellhead; wherein the as-built map is a raster format as-built map containing geographic element information;

[0059] a mask optimization module configured to perform an open-close operation, morphological smoothing, noise removal, and / or hole filling operation on each binary mask image to generate an optimized single-class mask;

[0060] an element coding module configured to divide the optimized single-class mask into three categories of surface elements, linear elements, and point elements according to element geometric types, and respectively adopt the following vectorization strategies to generate a vector file: for the surface elements, generating a polygon vector after simplifying the mask boundary; for the linear elements, generating a centerline vector through skeleton extraction; and for the point elements, generating a point vector by calculating the connected domain centroid of the mask;

[0061] a layer file generation module configured to write geographic coordinate systems and projection parameters of the as-built map into corresponding vector files to generate independent layer files with geographic coordinate references.

[0062] In a third aspect, an electronic device is provided, including at least one processor and a memory; the memory stores computer-executable instructions; the at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the as-built map multi-element extraction and vectorization method according to the first aspect and various possible designs of the first aspect.

[0063] In a fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the as-built map multi-element extraction and vectorization method according to the first aspect and various possible designs of the first aspect is implemented.

[0064] In a fifth aspect, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the as-built map multi-element extraction and vectorization method according to the first aspect and various possible designs of the first aspect is implemented.

[0065] The as-built map multi-element extraction and vectorization method, device, equipment, and storage medium provided by the present application have at least the following beneficial effects:

[0066] 1) In terms of element extraction accuracy, the application improves the Backbone and Neck structure of the Mask2Former model, replaces the traditional ResNet with SwinTransformerV2, uses its hierarchical window attention mechanism and cross-window connection strategy to significantly improve the model's global modeling ability and position sensitivity for elements of different shapes and significant size differences in high-resolution completion maps; At the same time, a deformable convolution feature pyramid network (DeformableFPN) is introduced in the Neck structure, which dynamically adjusts the sampling position to enhance the expression ability of irregular structures such as field boundaries and canal curved segments, effectively solving the problem of low segmentation accuracy and serious boundary sawtooth in the prior art.

[0067] 2) For complex element processing capability, the application introduces element geometric prior position coding, encodes the geometric distribution characteristics of various elements into vector embedding query initialization process, combines the edge-aware attention module in the decoder, extracts the edge response graph through the Sobel operator to guide the attention weight to focus on the semantic boundary, reduces the overlap of adjacent class masks and the boundary ambiguity, so that the model's perception ability for wellheads, buildings and other spatially distributed regular elements, as well as winding canals and broken roads, is significantly enhanced, overcoming the limitations of the prior art in simultaneous extraction and classification of multiple elements.

[0068] 3) In terms of vectorization processing efficiency and quality, the application adopts a differentiated vectorization strategy based on the geometric type of elements (point, line, and surface): surface elements are simplified by the Douglas-Peucker algorithm to generate polygon vectors, linear elements use the Zhang-Suen skeleton extraction algorithm to generate centerlines, and point elements calculate the connected domain centroid to generate point vectors. Compared with the single vectorization method in the prior art, the accuracy and continuity of vectorization of different types of elements are significantly improved, avoiding problems such as breakpoints and centerline deviations.

[0069] 4) In terms of model robustness improvement, the application introduces various data enhancement strategies such as Gaussian filtering, non-local mean denoising, CLAHE contrast enhancement, elastic deformation field simulation, pseudo-text noise superposition, and HSV color space jitter during training, effectively simulating noise, deformation, and lighting differences in completion map scanning, making the model still maintain high-precision segmentation in complex scenarios, solving the problem of poor adaptability to paper noise and diversity in the prior art. BRIEF DESCRIPTION OF DRAWINGS

[0070] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0071] Figure 1 A flowchart of a method for extracting and vectorizing multiple elements from an as-built drawing provided in an embodiment of the present application;

[0072] Figure 2 An architectural diagram of the improved Mask2Former semantic segmentation model provided in an embodiment of the present application;

[0073] Figure 3 Flowchart of element vectorization processing provided in the embodiment of the present application;

[0074] Figure 4 Another flowchart of a method for extracting and vectorizing multiple elements from an as-built drawing provided in an embodiment of the present application;

[0075] Figure 5 This is a structural diagram of the device for extracting and vectorizing multiple elements of as-built drawings provided in an embodiment of the present application.

[0076] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0077] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0078] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0079] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned. They should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0080] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0081] Embodiment 1

[0082] The embodiment of the present application provides a method for extracting and vectorizing multiple elements of a completion map. It should be noted that the completion map described herein includes but is not limited to a high-standard farmland construction project completion map, such as Figure 1 As shown in the figure, the overall flowchart of the method for extracting and vectorizing multiple elements of a completion map provided by the embodiment of the present application. The method for extracting and vectorizing multiple elements of a completion map includes the following steps S100-S400.

[0083] S100: The completion map is segmented to obtain binary mask images of fields, roads, canals, buildings and wellheads; wherein the completion map is a raster format completion map containing geographic meta-information.

[0084] In some embodiments, the TIFF raster format completion map containing geographic meta-information is input into an improved Mask2Former semantic segmentation model to segment and output binary mask images of fields, roads, canals, buildings and wellheads.

[0085] As shown in the figure, the architecture diagram of the improved Mask2Former semantic segmentation model provided by the embodiment of the present application. In the process of extracting multiple elements of a completion map, in order to improve the recognition ability of the model to fine-grained boundary structure and the semantic segmentation accuracy of complex graph elements, the Mask2Former model is systematically improved in multiple key modules. Figure 2

[0086] Firstly, the Backbone (backbone network) part adopts SwinTransformerV2 structure instead of traditional ResNet, which uses its hierarchical window attention mechanism and cross-window connection strategy to make the model have stronger global modeling ability and position sensitivity while maintaining computing efficiency, especially suitable for processing graph spot information with different shapes and significant scale differences in high-resolution completion maps.

[0087] The SwinTransformerV2 structure extracts features from the input image step by step by constructing a hierarchical structure, uses a fixed-size non-overlapping window for local attention calculation inside each level, and realizes information flow across windows by introducing a shift window mechanism, thereby building global dependency relationships at low computational cost. The window attention calculation process can be represented as:

[0088] ,

[0089] ​where Q, K, V are the linear mapping results of query, key, value respectively, d is the dimension of key vector, B is the relative position bias, which is used to enhance the model's perception ability of spatial structure. In cross-layer connection, the output of each layer not only participates in the attention calculation within the current layer window, but also is sent to the lower layer through the residual path, so as to retain the synergistic information of high-level semantic features and low-level detail features. In order to adapt to the targets with complex shape and large scale span such as field block, road, canal and wellhead in the as-built drawing, the hierarchical output of SwinTransformerV2 is sent into the feature pyramid structure for multi-scale fusion.

[0090] Secondly, a deformable convolution feature pyramid network (DeformableFPN) is added in the Neck structure to dynamically adjust the sampling position during the fusion of features at different scales, and to enhance the expression ability of irregular structures such as field block boundaries and canal curved segments.

[0091] The deformable convolution feature pyramid network is extended based on the multi-scale feature fusion mechanism of the original FPN, and a deformable convolution module is applied to each scale feature map to realize adaptive sampling of key spatial positions, thereby improving the sensitivity to elements with complex boundaries and distorted shapes. In standard convolution, the sampling position is a fixed integer grid, while deformable convolution introduces a learnable offset to dynamically select the position with the strongest response from the input feature map for aggregation, and the operation process is represented as:

[0092] ,

[0093] wherein represents the response of the output position , x is the input feature map, is the weight of the kth position of the convolution kernel, is the standard sampling offset, is the deformable offset learned by convolution. This mechanism allows the network to focus on the key response area of irregular morphological structures in space, significantly improving the perception ability of targets such as winding canals, broken roads and boundary ambiguous field blocks. In order to consider the multi-scale context information, DeformableFPN adopts a layer-by-layer upsampling and horizontal connection strategy to fuse the edge details of the bottom layer with the high-level semantic abstraction to form a feature pyramid, and the fusion feature map generated by the cross-layer superposition between scales participates in the subsequent mask prediction process, thereby improving the segmentation consistency and edge positioning accuracy of the overall model for multi-morphology and multi-scale elements.

[0094] For the query mechanism, the position encoding of element geometric prior is introduced, which encodes the geometric distribution features of each type of element in the image into a vector embedding into the query initialization process, improving the perception ability of Decoder for elements with significant spatial distribution rules such as wellheads and buildings.

[0095] Specifically, in the model initialization query vector, instead of using uniform random embedding or pure position coding, a location prior vector with category distinction is constructed according to the geometric distribution characteristics of elements such as fields, buildings, roads, ditches, wellheads, etc. in the completion map. The prior is generated by coding the feature mean and variance extracted from the statistical element spatial distribution heat map, and is spliced or added to the basic query vector to form a more recognizable category-guided query vector. The position prior coding process can be expressed as:

[0096] ,

[0097] Wherein is the horizontal and vertical distribution mean of the c-th element, is the standard deviation of the corresponding direction, and MLP is a multi-layer perception coding function, and finally generates a geometric position embedding specific to each type of element. After the position coding embedding query process, the decoding stage guides the attention to focus more on the expected area, improving the extraction accuracy of local structures such as wellheads.

[0098] In order to enhance the model's attention to the edge contour, an edge-aware attention module is integrated into the decoder, which guides the attention weight to focus on the semantic boundary area, reducing the mask overlap and boundary ambiguity between adjacent classes.

[0099] The edge-aware attention module guides attention by explicitly introducing an edge map. In the interaction process between each mask feature and input feature, an edge response map G extracted by the Sobel operator is introduced, and the attention map is modulated with it as the weight. The specific adjustment method is as follows:

[0100] ,

[0101] Wherein is the dot product result of the query key, d is the dimension scaling factor, G is the standardized output of the edge response map, represents element-level multiplication. This mechanism makes the attention mechanism explicitly aware of the importance of the boundary area, thereby forming a clear separation between adjacent element categories, significantly reducing the mask boundary ambiguity and category overlap phenomenon, and improving the continuity of roads and ditches and the clarity of building boundaries.

[0102] In terms of loss function, the weighted combination of boundary IoU loss (Boundary IoU Loss) and class-aware mask loss (Class-aware Mask Loss) is used. The boundary IoU loss is defined by comparing the matching degree of the predicted mask and the real mask boundary area as follows:

[0103] ,

[0104] wherein and denote the boundary set of predicted and ground truth masks respectively. The class-sensitive mask loss is composed of a multi-class mask cross-entropy loss and a region IoU weighted term:

[0105] ,

[0106] wherein and are the ground truth label and predicted probability of the c-th class respectively, is the class weight, denotes the region IoU value of this class, and λ is the balance coefficient. The final joint loss function is defined as:

[0107] ,

[0108] wherein , is the loss weight hyper-parameter. Through the above module-level optimization, the model significantly improves the extraction accuracy and boundary clarity of multiple geographic elements in high-standard farmland completion maps while ensuring computational efficiency, providing high-quality input for subsequent element vectorization and geographic information fusion.

[0109] In some embodiments, to improve the robustness of the Mask2Former model to the diversity and noise interference of real completion maps, various targeted data augmentation strategies are introduced during the training process. By applying Gaussian filtering and non-local mean denoising to the input drawings, the optical blurring and detail degradation caused by drawing aging that may exist in the scanned copies are simulated. The Gaussian filtering adopts a two-dimensional convolution kernel to control the overall blurring degree of the image, and its expression is:

[0110] ,

[0111] wherein σ controls the blurring intensity, and x, y are the symmetric coordinates of the kernel center. The non-local mean denoising preserves structural details while reducing background noise by searching for similar blocks in the image and performing weighted averaging. The core is the weighted function based on the similarity between pixel blocks:

[0112] ,

[0113] wherein is the denoised pixel value, w(p, q) is the weight function, h is the filtering scale factor, Z(p) is the normalization factor, and Ω is the search window.

[0114] Secondly, the contrast-limited adaptive histogram equalization (CLAHE) algorithm is used to enhance the contrast of the image, highlight the gray gradient features of linear elements such as roads and canals, and prevent edge breakage caused by overexposure or underexposure of the region. CLAHE improves the texture structure definition by dividing the image into blocks and performing histogram equalization on each block, and limiting the local contrast gain.

[0115] To simulate the displacement distortion caused by physical deformation of the drawing, an elastic deformation field is randomly generated in the training set to cause spatial nonlinear disturbance in the local region of the image. Elastic deformation is achieved by adding smooth Gaussian noise disturbance to the original coordinates, which is commonly expressed as follows:

[0116]

[0117] where α is the disturbance intensity, and are the two-dimensional random displacement fields after Gaussian kernel smoothing.

[0118] In terms of interference enhancement, to enable the trained model to distinguish between real lines and background information such as printing, text, and labels, pseudo-text noise blocks with random positions, fonts, and sizes are superimposed as obstructions to simulate non-structural information such as drawing annotations and seals, and to enhance the model's ability to distinguish linear continuity and semantic context.

[0119] Finally, to enhance the model's adaptability to scanning light conditions, the HSV color space is used to perturb the image brightness and hue. By adding small fluctuations to the Hue (hue), Saturation (saturation), and Value (brightness) channels, a light distribution difference field is constructed to enable the model to learn robust semantic feature extraction capabilities under different exposure, reflection, and scanning skew conditions. These enhancement strategies are dynamically applied to the original drawing samples during the training phase, effectively improving the model's generalization performance and ensuring high-precision segmentation output in the presence of complex element structures and interference factors in high-standard farmland completion maps.

[0120] S200: Perform open-close operation, morphological smoothing, noise removal, and / or hole filling operation on each binary mask image to generate an optimized single-class mask.

[0121] In this embodiment, step S200 is a step of post-processing the mask image. By performing open-close operation, morphological smoothing, noise removal, and hole filling operation on each element mask image, an optimized single-class mask is generated.

[0122] ​In some embodiments, to improve the geometric integrity and vectorizability of the element mask images generated by the Mask2Former model, different post-processing strategies are adopted for different categories. For building masks, due to the problems of scanning discontinuity, edge missing, etc., morphological closing operation with a seven-by-seven cross-shaped structuring element is performed to fill the gaps. The closing operation consists of an inflation operation followed by an erosion operation, which is defined as:

[0123] ,

[0124] where A represents the binary mask image, B is a seven-by-seven cross-shaped structuring element, and is an inflation operation, is an erosion operation. This structural feature matches the linear edge direction of the building, and improves the connectivity of the mask by closing the broken edges.

[0125] For water channel masks, they are characterized by being thin and curved, and are prone to generate a large number of isolated noise patches due to false detection. To remove such false responses, an area threshold filtering operation is applied to calculate the area of each connected domain and set a minimum reserved area threshold , and the noise regions with an area less than the threshold are set as background. The area calculation is based on pixel counting:

[0126] ,

[0127] where represents the area of the i-th connected region, and is its pixel set. This operation effectively preserves continuous linear structures while removing isolated fragments, improving the reliability of water channel element extraction.

[0128] For field mask, to solve the problems of boundary sawtooth and discontinuous contour in the segmentation result, a mask reconstruction operation based on morphological gradient is performed to smooth the edges. First, the morphological gradient of the original mask is calculated:

[0129] ,

[0130] where G represents the gradient image, A is the field mask, and B is the structuring element. The subtraction operation reflects the edge pixel gradient. Then, the mask reconstruction operation is performed to fuse the original structure and smooth contour, guided by the marker map to eliminate isolated sawtooth and small-scale edge offset, and finally generate a field mask image with continuous structure and regular boundary, providing an accurate boundary basis for subsequent polygon vectorization. The above post-processing steps are optimized according to the type of elements, which improves the expression effect of the model segmentation result in terms of spatial coherence, shape integrity, and boundary quality, etc.

[0131] S300: According to the element geometry type, the optimized single-class mask is divided into three categories: planar elements, linear elements and point elements, and the following vectorization strategies are used to generate vector files respectively: for planar elements, the mask boundary is simplified to generate a polygon vector; for linear elements, the center line vector is generated by skeleton extraction; for point elements, the point vector is generated by calculating the centroid of the mask connected domain.

[0132] In this embodiment, step S300 is a step of element-specific vectorization. According to the element geometry type, the mask is divided into three categories: point, line and surface, and different vectorization strategies are used respectively. In some embodiments, in order to realize accurate vectorization representation of multiple types of elements such as field blocks, water channels, buildings and wellheads in the as-built drawing, the mask is divided into three categories: planar, linear and point, and specific processing procedures are performed respectively according to the geometry properties of the mask. For example, as shown in the following figure, the element vectorization processing flowchart provided by the embodiment of the application is shown. Figure 3

[0133] Specifically, for a planar element mask, first, the internal pores and boundary gaps are filled by morphological closing operation to ensure the topological closure of the polygon, and the operation is defined as first expanding and then eroding the mask image:

[0134] ,

[0135] where M is the original mask image, B is the structure element, and M' is the closing operation result. This step fills the non-structural holes caused by segmentation errors or scanning interference. Then, the Canny edge detection algorithm is applied to obtain the continuous edges with gradient mutation in the binary mask image, forming a closed boundary contour for subsequent polygon construction. The algorithm first calculates the gradient amplitude G(x, y) and direction :

[0136] ,

[0137] where is the gradient of the image in the horizontal and vertical directions. After edge extraction, the Douglas-Peucker algorithm is used to compress the boundary point sequence, reducing the number of vertices and preserving the contour features. This algorithm uses the farthest point distance error as the simplification criterion, outputs an approximate polygon with fewer nodes, and realizes the compactness and stability of vector representation.

[0138] ​For linear feature mask, in order to accurately restore the center path of the slender feature, the skeleton structure of one pixel width is generated by the medial axis transformation, and the local maximum points are connected to form the skeleton path by distance transformation. After the skeleton is generated, the direction change is described by Freeman chain code, and the skeleton line segment is coded as a digital sequence in the eight neighborhood pattern. The discontinuous segments are identified and connected by linear interpolation, and the zigzag path is further smoothed to improve the geometric continuity and readability of the vectorized line feature.

[0139] For point feature mask, first, the connected component labeling algorithm is used to identify each independent entity region in the image based on 8-adjacent relationship and assign a unique label to each region. Then, for multiple adjacent point targets, the accurate separation is realized. The geometric center is calculated as the position coordinate of the entity, and the calculation formula is:

[0140] ,

[0141] Among them is the number of pixels in the i-th region, is the centroid coordinate. This method avoids the problem of point position deviation caused by mask boundary blur, and the generated vector point accurately reflects the position attribute of the actual point feature such as wellhead. Through the above process, the mask graph output by the model is converted into a vector layer with reasonable structure and reliable precision through special geometric processing, providing high-quality basic data for subsequent spatial analysis and layer overlay.

[0142] To ensure that the structured expression of various elements in the completed map meets the standards of geographic information systems, each category of elements is output as an independent ESRI Shapefile file after completing the mask vectorization, and the corresponding layer type is specified according to its geometric properties. The field block element is defined as a polygon layer after the mask boundary extraction and polygon construction, and each field block is constructed as a polygon element with a closed point sequence. The boundary coordinate set after compression by the Douglas-Peucker algorithm is represented as:

[0143] ,

[0144] The set P represents the point sequence of the field block contour, and the last item returns to the starting point to ensure topological closure. It is stored in the Shapefile as a polygon type and can be attached with attribute fields such as field block number, area, classification code, etc.

[0145] For road and canal elements, after completing the skeleton extraction and path smoothing, the result is represented as a continuous line segment set, and each line segment is composed of an ordered point sequence, output as a polyline type layer. Each line element is represented as:

[0146] ,

[0147] The point column L is a path sequence of the skeleton line, does not form a closed loop, and is used to record the water channel direction and road track. In an attribute table, width, material, or function classification information can be associated.

[0148] The building element, like the field block, belongs to a planar structure. After a closed operation process and boundary extraction, a profile is formed, a closed polygon is constructed, and a polygon type layer is output. The processing logic is consistent with that of the field block, but fields such as building purpose, height level, and number can be added, which are used for subsequent layer query and statistical analysis.

[0149] The wellhead element belongs to a point object. After a connected domain centroid calculation, a spatial point is generated. Each wellhead is represented by two-dimensional coordinates (x, y), and a point type layer is output. Each point element can be associated with well number, water source type, and function attribute information. To ensure the consistency of the coordinate system, all layers are constructed by calling the OGR interface of the GDAL library, and the geographic reference information extracted from the original TIFF raster image is written into the projection definition file PRJ of each Shapefile file. Therefore, all output layers have a unified spatial reference, support subsequent map overlay, spatial analysis, and attribute query operations. This process completes the standardized conversion from semantic segmentation mask to structured vector layer, which is a key step in the information modeling and management of the as-built drawing.

[0150] S400: Write the geographic coordinate system and projection parameters of the as-built drawing into the corresponding vector file to generate an independent layer file with geographic coordinate reference.

[0151] In this embodiment, step S300 is the step of geographic information fusion output. The geographic coordinate system and projection parameters of the original TIFF image are written into the corresponding ESRIShapefile vector file to generate an independent layer file with geographic coordinate reference.

[0152] In some embodiments, to realize the conversion from the vectorization result of the mask image to the standard GIS layer with geographic reference, first, the key geographic information is extracted from the image header file of the original TIFF format as-built drawing, including the GeoTransform parameter and the Projection definition. GeoTransform is a set of six floating-point numbers that describes the linear mapping relationship between the image coordinates and the geographic spatial coordinates, which contains the geographic coordinates of the upper left corner of the image, the pixel resolution, and the rotation information, and is the basis for aligning the raster data with the geographic space. The Projection field defines the projection coordinate system to which the TIFF image belongs, such as WGS84, UTM, or national geodetic coordinate system, which is used to ensure the consistency and superimposability of the subsequent vector layer in spatial positioning.

[0153] In the vector layer creation stage, a corresponding point, line or face layer is generated for each class of vectorized feature result by calling the CreateLayer function in the GDAL library. This function accepts parameters such as layer name, drive type, spatial reference object and geometry type, ensuring that the output file format and geometry structure meet the ESRIShapefile standard. For each layer, the SetSpatialRef function is further called to inject the projection information extracted from the original TIFF into the layer, establishing the spatial reference system of the layer and ensuring that it has the correct geospatial definition.

[0154] Finally, the SetGeoTransform function is called to bind the aforementioned GeoTransform parameter to the output layer, so that the coordinate position of each spatial feature in the vector layer is accurately mapped from pixel index to actual geographic coordinates. This process completes the spatial conversion from the image domain to the map domain, so that the output point, line and face Shapefile files have real geographic location properties and can be used for spatial overlay analysis with other geographic data. This fusion process is the key link to realize the conversion of the completed map multi-element to GIS data, ensuring the accuracy and spatial consistency of the data output, and providing a stable foundation for the subsequent construction of high-standard farmland information systems.

[0155] Embodiment 2

[0156] The embodiment of the present application provides a kind of completed map multi-element extraction and vectorization method, this method is applied to the multi-element extraction and vectorization of high-standard farmland construction project completed map, for example, as shown in Figure Figure 4 The method comprises the following steps S1-S4.

[0157] S1, completion map segmentation processing: prepare a TIFF raster format completion map containing geographic meta-information as input data, ensure that the image resolution meets the model processing requirements, and the resolution is not less than 300 dpi. The completion map is input into the improved Mask2Former semantic segmentation model, and the model related parameters are set as follows: the initial value of the learning rate is set to 0.0001, the cosine annealing learning rate scheduling strategy is adopted to gradually adjust the learning rate and optimize the model training process; the batch size is set to 16, and in the case of memory permission, appropriately increasing the batch size is helpful to improve the training efficiency and model stability; the training rounds are set to 100 rounds, and through multiple rounds of training, the model is fully learned the feature mode in the completion map. During the model training process, NVIDIA GPU is used for acceleration calculation to improve the processing speed. The model is based on the improved Mask2Former architecture, the SwinTransformerV2 structure is used in the Backbone part, the deformable convolution feature pyramid network (DeformableFPN) is added in the Neck structure, and the position encoding of element geometric prior and edge perception attention module are introduced, the query mechanism and loss function are optimized to improve the segmentation accuracy of the elements such as field block, road, canal, building and well mouth in the completion map. The model outputs binary mask images of field block, road, canal, building and well mouth, each element corresponds to an independent mask image, and the foreground (element) is white (pixel value is 255) and the background is black (pixel value is 0).

[0158] S2, mask image post-processing: for field block mask image, perform mask reconstruction operation based on morphological gradient. First, select a three-by-three square structural element to calculate the morphological gradient of the original mask. Then perform mask reconstruction operation, use label map to guide repair process, eliminate isolated sawtooth and small scale edge offset, the specific operation is based on morphological reconstruction algorithm, through continuous iteration, the boundary of the mask image is gradually smoothed, and finally the field block mask image with continuous structure and regular boundary is generated. For building mask, because of the common linear interruption problem, perform morphological closing operation with seven-by-seven cross-shaped structural element. The closing operation is composed of dilation operation followed by erosion operation. The shape and size of the structural element match the linear edge direction of the building, and through the dilation operation, the edge of the broken part is expanded outward, and then through the erosion operation, the expanded edge is contracted back, thereby filling the gap and improving the mask connectivity. For water channel mask, because it is long and curved, it is easy to produce isolated noise spots, so area threshold filtering operation is applied. Set the minimum reserved area threshold to 100 pixels, calculate the area of each connected domain based on pixel counting. Set the noise area with an area less than the threshold as the background, effectively retain the continuous linear structure and remove isolated fragments, and improve the reliability of water channel element extraction.

[0159] S3, Element-specific vectorization: When vectorizing planar elements such as fields and buildings, first perform a morphological closing operation on the mask to fill in internal pores and boundary gaps. Select a five-by-five square structuring element, and define the closing operation as first dilating and then eroding the mask image. Fill in non-structural holes caused by segmentation errors or scanning interference through this operation to ensure the topological closure of the polygon. Then apply the Canny edge detection algorithm to obtain the continuous edges with gradient mutations in the binary mask image, forming a closed boundary contour. In the Canny edge detection process, set the low threshold to 50 and the high threshold to 150 to accurately detect the edges. Use the Douglas-Peucker algorithm to compress the boundary point sequence, reduce the number of vertices, and retain the contour features. This algorithm uses a distance error of 0.5 for the farthest point as the simplification criterion to output an approximate polygon with fewer nodes, achieving compactness and stability in vector representation. For linear elements such as roads, ditches, and masks, first perform a centerline transformation to generate a one-pixel-wide skeleton structure, and then extract the local maximum points through distance transformation to form a skeleton path. Use Freeman chain code to describe the direction changes, and encode the skeleton line segments into digital sequences in an eight-neighborhood pattern. Identify discontinuous segments and connect the breakpoints through linear interpolation. For jagged paths, use a cubic spline interpolation algorithm for smoothing, improving the geometric continuity and readability of the vectorized line elements. For point-like element masks such as wellheads, use the connected component labeling algorithm to identify each independent entity region in the image based on 8-adjacent relationships and assign a unique label to each connected region Calculate its geometric center as the position coordinates of the entity, the formula is where is the number of pixels in the ith region, is its centroid coordinates. This method avoids the problem of point position deviation caused by mask boundary ambiguity, and the generated vector points accurately reflect the position properties of actual point-like elements such as wellheads.

[0160] S4, geographic information fusion output: extract key geographic information from the image header file of the original TIFF format completion map, read the image header file using the related functions in the GDAL library, and obtain the GeoTransform parameter and Projection definition. GeoTransform is a set of six floating-point numbers describing the linear mapping relationship between image coordinates and geographic spatial coordinates, which contains the geographic coordinates of the upper left corner of the image, pixel resolution and rotation information. The Projection field defines the projection coordinate system to which the TIFF image belongs, such as WGS84, UTM or national geodetic coordinate system. In the vector layer creation stage, by calling the CreateLayer function in the GDAL library, a corresponding point, line or face layer is generated for each type of vectorized element result. For example, for field elements, create a polygon layer, and the function parameter settings are as follows: the layer name is set to "Field", the driving type is selected as ESRI Shapefile, the spatial reference object is set according to the extracted Projection definition, and the geometry type is set to polygon. For each layer, further call the SetSpatialRef function to inject the projection information extracted from the original TIFF into the layer to establish the spatial reference system of the layer. Finally, call the SetGeoTransform function to bind the GeoTransform parameter to the output layer, so that the coordinate position of each spatial element in the vector layer is accurately mapped from the pixel index to the actual geographic coordinate. For example, for the field layer, the vertex coordinates of the field polygon are converted from the pixel coordinate system to the geographic coordinate system, ensuring that the output vector file has real geographic location properties and can be used for spatial overlay analysis with other geographic data.

[0161] Based on the above steps S1-S4, taking a project completion map covering an area of 2000 mu of farmland as an example, which contains various types of fields, crisscross roads and water channels, several buildings and wellheads distributed everywhere. First, the TIFF raster format completion map of the project is input into the improved Mask2Former semantic segmentation model for processing. In the model training stage, a dataset containing the high-standard farmland completion maps of the region and the surrounding areas is used for training and optimizing the model. After model segmentation processing, binary mask images of fields, roads, water channels, buildings and wellheads are obtained. From the field mask image, the originally complex and fuzzy boundary of the field is clearly segmented, even the field with irregular shape and zigzag boundary can be accurately outlined, which is highly consistent with the actual field shape. After performing mask reconstruction operation based on morphological gradient on the field mask in the mask image post-processing link, the sawtooth of the field boundary is significantly reduced, becoming smoother and more continuous, greatly improving the quality of the field boundary. For the building mask, after performing mathematical morphological closing operation with a seven-by-seventy cross-shaped structural element, the linear discontinuity caused by scanning problems is filled, the outline of the building is more complete, and the connectivity is significantly improved. In the element-specific vectorization stage, for the planar field element, after morphological closing operation, Canny edge detection and Douglas-Peucker algorithm processing, the generated polygon vector can accurately represent the shape and range of the field, and the number of polygon vertices in the vector file is reasonable, which not only retains the key shape features of the field, but also realizes the compact storage of data. For the linear water channel element, after the center axis transformation, Freeman chain code description and path smoothing processing, the center line vector obtained by vectorization can accurately reflect the trend of the water channel, and the center line is continuous and smooth without breakpoints or obvious deviations. Finally, in the geographic information fusion output stage, the geographic coordinate system and projection parameters of the original TIFF image are written into the ESRI Shapefile vector file of the corresponding element using the GDAL library. The generated element vector layers are displayed and analyzed in ArcGIS software, and the distribution of field, road, water channel, building and wellhead elements in geographic space can be clearly seen. By superimposing and analyzing the land use status data and topographic data of the region, the rationality of land use, the adaptability of facility layout to terrain and other aspects of the high-standard farmland construction project can be intuitively found. For example, through superimposed analysis, it is found that the construction position of part of the road is well adapted to the terrain slope, which is convenient for the passage of agricultural machinery; at the same time, it is found that there is optimization space for the connection of individual fields and the surrounding water system, which provides data support for subsequent farmland optimization and reconstruction.

[0162] Example 3:

[0163] The embodiments of the present application also provide a completion map multi-element extraction and vectorization device, which comprises a data input unit, a model processing unit, a mask image post-processing unit, an element-specific vectorization unit and a geographic information fusion output unit.Figure 5 As shown, the as-built map multi-element extraction and vectorization device includes:

[0164] The image segmentation module 501 is configured to segment the as-built map to obtain binary mask images of fields, roads, ditches, buildings and wellheads; wherein the as-built map is a raster format as-built map containing geographic element information;

[0165] The mask optimization module 502 is configured to perform opening and closing operations, morphological smoothing, noise removal and / or hole filling operations on each binary mask image to generate an optimized single-class mask;

[0166] The element coding module 503 is configured to divide the optimized single-class mask into three categories of surface elements, linear elements and point elements according to the element geometric type, and respectively adopt the following vectorization strategies to generate a vector file: for surface elements, a polygon vector is generated after simplifying the mask boundary; for linear elements, a centerline vector is generated by skeleton extraction; for point elements, a point vector is generated by calculating the connected domain centroid of the mask;

[0167] The layer file generation module 504 is configured to write the geographic coordinate system and projection parameters of the as-built map into the corresponding vector file to generate an independent layer file with geographic coordinate reference.

[0168] Embodiments of the present application provide an electronic device. The electronic device can include a processor, a memory, wherein the processor and the memory can communicate; for example, the processor and the memory communicate through a communication bus.

[0169] The processor executes computer execution instructions stored in the memory, so that the processor executes the scheme in the above embodiments. The processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0170] The communication bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries and read-only libraries). The memory can include random access memory (RAM) and can also include non-volatile memory.

[0171] The electronic device provided by the embodiment of the present application can be the terminal device of the above embodiment.

[0172] The embodiment of the present application further provides a computer readable storage medium, which stores computer instructions, and when the computer instructions are run on a computer, the computer executes the technical solution of the as-built drawing multi-element extraction and vectorization method of the above embodiment.

[0173] The embodiment of the present application further provides a computer program product, which includes a computer program stored in a computer readable storage medium, at least one processor can read the computer program from the computer readable storage medium, and when the at least one processor executes the computer program, the technical solution of the as-built drawing multi-element extraction and vectorization method in the above embodiment can be realized.

[0174] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed modules can be indirect coupling or communication connection through some interfaces, devices or modules, and can be electrical, mechanical or other forms.

[0175] The modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, some or all of the modules can be selected to realize the embodiment scheme.

[0176] In addition, each functional module in the various embodiments of the present application can be integrated in one processing unit, or each module can be physically present alone, or two or more modules can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a hardware and software function unit.

[0177] The integrated module realized in the form of a software function module can be stored in a computer readable storage medium. The software function module stored in the storage medium includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute part of the steps of the various embodiments of the method of the present application.

[0178] It should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the disclosed method can be directly embodied in the form of hardware processor execution, or a combination of hardware and software modules in the processor.

[0179] The memory can include a high-speed RAM memory, and can also include a non-volatile storage NVM, such as at least one disk memory, and can also be a U disk, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0180] The bus can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc.

[0181] The aforementioned storage medium can be realized by any type of volatile or nonvolatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0182] An exemplary storage medium is coupled to the processor so that the processor can read information from, and write information to, the storage medium. Of course, the storage medium can be a part of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can be located in a remote terminal or a host computer.

[0183] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware. The aforementioned program can be stored in a computer readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes ROM, RAM, magnetic disk or optical disk and various storage media that can store program codes.

[0184] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for extracting and vectorizing multiple elements of as-built drawings, characterized by: The method comprises: Segmenting the as-built map to obtain binary mask images of fields, roads, canals, buildings, and wellheads; wherein the as-built map is a raster format as-built map containing geographic metadata; Performing opening and closing operations, morphological smoothing, noise removal, and / or hole filling operations on each binary mask image to generate an optimized single-class mask; The optimized single-category mask is divided into three categories according to the feature geometry type: area features, linear features, and point features. The following vectorization strategies are used to generate vector files: for area features, the mask boundary is simplified to generate polygon vectors; for linear features, the centerline vector is generated by skeleton extraction; for point features, the centroid of the connected domain of the mask is calculated to generate a point vector; Writing the geographic coordinate system and projection parameters of the as-built drawing into a corresponding vector file to generate an independent layer file with a geographic coordinate reference; Segmenting the as-built map to obtain binary mask images of fields, roads, canals, buildings, and wellheads, including: inputting the as-built map into a semantic segmentation model and outputting binary mask images of the fields, roads, canals, buildings, and wellheads; wherein the semantic segmentation model is an improved Mask2Former semantic segmentation model; In the improved Mask2Former semantic segmentation model, the backbone network uses the SwinTransformerV2 structure to replace ResNet. The SwinTransformerV2 structure extracts features from the input image step by step by constructing a hierarchical structure. Within each layer, fixed-size non-overlapping windows are used for local attention calculation. A shifting window mechanism is introduced to enable cross-window information flow. In the improved Mask2Former semantic segmentation model, a deformable convolutional feature pyramid network is added to the neck structure. The operation process of the deformable convolutional feature pyramid network is expressed as follows: , Where, Indicates the output location The response, is the input feature map, is the convolution kernel k The weight of the position, is the standard sampling offset, is the variable offset learned through convolution, is the number of locations; In the improved Mask2Former semantic segmentation model, when initializing the query vector, the feature mean and variance are extracted from the statistically obtained element spatial distribution heat map to generate an encoding, which is then concatenated or added to the basic query vector to form a category-guided query vector. In the improved Mask2Former semantic segmentation model, the decoder integrates an edge-aware attention module, which guides attention by explicitly introducing an edge map. During the interaction between each mask feature and the input feature, an edge response map extracted by the Sobel operator is introduced, and the attention map is modulated using the edge response map as a weight. When training the improved Mask2Former semantic segmentation model, a weighted combination of boundary IoU loss and category-sensitive mask loss is used as the loss function.

2. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1, characterized in that: Before inputting the as-built image into the semantic segmentation model, the method further includes performing data enhancement on the as-built image; wherein the data enhancement step includes Gaussian filtering, non-local mean denoising, image contrast enhancement, and interference enhancement; The processing process of the Gaussian filter is expressed as follows: , Where σ is the control blur intensity, x, y are the symmetric coordinates of the kernel center, exp is the exponential function, is the kernel function; The processing process of the non-local means denoising is expressed as follows: , Where, is the pixel value after denoising, is the weight function, is the filter scale factor, is the normalization factor, For the search window, is the noisy image at pixel position The original pixel value at is the noisy image at pixel position The original pixel value at is the pixel position; The image contrast enhancement process is expressed as follows: , Where α is the disturbance intensity, and is the two-dimensional random displacement field after Gaussian kernel smoothing, is the pixel coordinate after contrast enhancement; The interference enhancement includes: Pseudo-text noise blocks with random positions, fonts, and sizes are superimposed as occlusions to simulate the non-structural information of drawing annotations and / or seals. The brightness and hue of the image are perturbed using HSV color space dithering. By adding small fluctuations to the hue, saturation, and brightness channels, a scene with different lighting distribution is constructed.

3. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1 is characterized in that: Perform opening and closing operations, morphological smoothing, noise removal, and / or hole filling operations on each binary mask image to generate an optimized single-class mask, including: For the binary mask image of the building, a morphological closing operation is performed using a seven-by-seven cross-shaped structuring element to bridge the gaps and improve the mask connectivity by closing the broken edges. The calculation process of the morphological closing operation is expressed as: , Where, represents a binary mask image, is a seven-by-seven cross-shaped structural element, For the expansion operation, For corrosion operations; For the canal binary mask image, an area threshold filtering operation is performed to remove isolated noise patches: the area of ​​each connected domain is calculated and a minimum retained area threshold is set. Noise regions with an area smaller than the minimum retained area threshold are set as background. The calculation formula for the area of ​​the connected region is: , Where, Indicates the i The area of ​​the connected region, is a set of pixels; For the binary mask image of the field, the morphological gradient of the original mask is calculated, and the mask reconstruction operation is performed to fuse the original image structure and smooth contour. The repair process is guided by the marker map to eliminate isolated jagged edges and small-scale edge offsets, and generate a field mask image with continuous structure and regular boundaries.

4. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1, characterized in that: The vectorization strategy adopted by the surface elements specifically includes: Perform morphological closing operation on the optimized single-category mask of the area feature to fill the internal pores and boundary gaps; According to the gradient magnitude and gradient direction of the binary mask image, the continuous edges in the binary mask image are determined to form a closed boundary contour; wherein the calculation formulas for the gradient magnitude and gradient direction are: , Where, is the gradient amplitude, I x and I y is the gradient of the image in the horizontal and vertical directions, is the gradient direction; Compress the boundary point sequence, use the farthest point distance error as the simplification criterion, and output the approximate polygon represented by the point sequence. The last item of the point sequence returns to the starting point to ensure topological closure, and generate a polygon vector. The point sequence is expressed as: , Where, P Represents the sequence of field outer contour points, 、 and Represents the coordinates of different contour points.

5. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1 is characterized in that: The vectorization strategies used for the linear elements and point elements specifically include: For linear features, the optimized single-category mask of the linear feature is transformed into a one-pixel-width skeleton structure. The local maximum points are extracted through distance transformation and connected to form a skeleton path. The Freeman chain code is used to describe the direction changes of the skeleton line segments in an eight-neighborhood pattern. Discontinuous segments are identified and connected through linear interpolation. The jagged path is smoothed to generate a centerline vector represented by an ordered point sequence. For point features, independent entity areas are identified based on the 8-adjacency relationship and assigned unique labels; for each connected area Calculate the geometric center as the entity position coordinates, the calculation formula is: , Where, For the i The number of pixels in the area, is the centroid coordinate of the ith region, Belong to the connected area 's coordinates.

6. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1, characterized in that: Write the geographic coordinate system and projection parameters of the as-built drawing into the corresponding vector file to generate an independent layer file with geographic coordinate reference, including: Extract key geographic information from the image header file of the original as-built drawing, including GeoTransform parameters that describe the linear mapping relationship between image coordinates and geographic space coordinates, and projection information that determines the projection coordinate system to which the TIFF image belongs; Call the CreateLayer function in the GDAL library to generate corresponding point, line or surface layers for each type of vectorized feature result. The CreateLayer function receives parameters such as layer name, driver type, spatial reference object and geometry type to ensure that the output file format and geometry structure meet the set standards; For each generated layer, call the SetSpatialRef function to inject the projection information extracted from the original as-built drawing into the layer and establish the spatial reference system of the layer; Call the SetGeoTransform function and bind the extracted GeoTransform parameters to the output layer, so that the coordinate positions of the spatial features in the vector layer are mapped from pixel indexes to actual geographic coordinates, generating an independent layer file with real geographic location attributes.

7. A device for extracting and vectorizing multiple elements of a completed drawing, characterized in that: The device comprises: an image segmentation module configured to segment the as-built map to obtain binary mask images of fields, roads, canals, buildings, and wellheads; wherein the as-built map is a raster format as-built map containing geographic metadata; a mask optimization module configured to perform opening and closing operations, morphological smoothing, noise removal, and / or hole filling operations on each binary mask image to generate an optimized single-class mask; The feature encoding module is configured to classify the optimized single-category mask into three categories according to feature geometry types: area features, linear features, and point features, and adopt the following vectorization strategies to generate vector files: for area features, simplifying the mask boundary to generate polygon vectors; for linear features, generating centerline vectors through skeleton extraction; and for point features, calculating the centroid of the connected domain of the mask to generate point vectors. a layer file generation module configured to write the geographic coordinate system and projection parameters of the as-built drawing into a corresponding vector file to generate an independent layer file with a geographic coordinate reference; The image segmentation module is further configured to input the as-built drawing into a semantic segmentation model and output binary mask images of fields, roads, canals, buildings, and wellheads; wherein the semantic segmentation model is an improved Mask2Former semantic segmentation model; In the improved Mask2Former semantic segmentation model, the backbone network uses the SwinTransformerV2 structure to replace ResNet. The SwinTransformerV2 structure extracts features from the input image step by step by constructing a hierarchical structure. Within each layer, fixed-size non-overlapping windows are used for local attention calculation. A shifting window mechanism is introduced to enable cross-window information flow. In the improved Mask2Former semantic segmentation model, a deformable convolutional feature pyramid network is added to the neck structure. The operation process of the deformable convolutional feature pyramid network is expressed as follows: , Where, Indicates the output location The response, is the input feature map, is the convolution kernel k The weight of the position, is the standard sampling offset, is the variable offset learned through convolution, is the number of locations; In the improved Mask2Former semantic segmentation model, when initializing the query vector, the feature mean and variance are extracted from the statistically obtained element spatial distribution heat map to generate an encoding, which is then concatenated or added to the basic query vector to form a category-guided query vector. In the improved Mask2Former semantic segmentation model, the decoder integrates an edge-aware attention module, which guides attention by explicitly introducing an edge map. During the interaction between each mask feature and the input feature, an edge response map extracted by the Sobel operator is introduced, and the attention map is modulated using the edge response map as a weight. When training the improved Mask2Former semantic segmentation model, a weighted combination of boundary IoU loss and category-sensitive mask loss is used as the loss function.

8. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method for extracting and vectorizing multiple elements of a completion drawing according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method for extracting and vectorizing multiple elements from a completion drawing according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Remote sensing semantic segmentation method fusing optical image and laser radar point cloud

    CN116246074A

  • Map generation method and deep learning model training method and device

    CN117593712A