Completed drawing multi-element extraction and vectorization method, device and equipment and storage medium
Through the improved Mask2Former model and differentiated vectorization strategy, the efficiency and accuracy issues of feature extraction and vectorization in the completion drawings of high-standard farmland construction projects were solved, and high-precision completion drawing data processing was achieved to meet the needs of modern geographic information systems.
Patent Information
- Application Number
- CN202511156300.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-08-19
AI Technical Summary
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 data precision, integrity, and consistency. In particular, there are problems with segmentation accuracy and vectorization accuracy when processing complex features.
The improved Mask2Former semantic segmentation model is used, combined with the SwinTransformerV2 and DeformableFPN structures for as-built image segmentation. The edge-aware attention module and multiple data enhancement strategies are introduced. The vector files of surface, line and point features are generated through a differentiated vectorization strategy, and the geographic coordinate system is written into the vector files.
It significantly improves the segmentation accuracy and vectorization quality of complex elements in the as-built drawings, solves the problems of low segmentation accuracy, severe boundary jaggedness, and limited multi-element classification processing capabilities in existing technologies, and achieves efficient and accurate vectorization processing.
Smart Images

Figure CN120656201A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of as-built drawing processing, and in particular to a method, apparatus, device, and storage medium for extracting and vectorizing multiple elements of an as-built drawing. Background Art
[0002] The construction of high-standard farmland is a key initiative in promoting agricultural modernization. Upon completion, as-built drawings serve as a crucial vehicle for project accomplishments. They document precise information on key geographic features such as fields, roads, canals, buildings, and wellheads. This information is crucial for understanding the actual progress of farmland construction, evaluating project effectiveness, and facilitating subsequent farmland management and utilization.
[0003] Converting the drawing information in as-built drawings into vector data (such as the common ESR Shapefile format) that can be managed, analyzed, and used in GIS (Geographic Information System) software is of irreplaceable importance for project verification and comparison, post-production maintenance, and national land space planning. During project verification and comparison, vector data can be accurately overlaid and analyzed with other relevant data (such as current land use data and planning data), allowing for rapid and accurate identification of project construction issues, such as the accuracy of the construction scope and compliance with planning requirements. This ensures that project construction complies with relevant standards and specifications, and ensures that the country's investment in high-standard farmland construction is effectively utilized.
[0004] Traditional methods for extracting and vectorizing features from as-built drawings of high-standard farmland construction projects primarily rely on manual drawing or simple image processing algorithms. Manual drawing is not only inefficient and consumes significant manpower, material resources, and time, but is also susceptible to human factors, resulting in low accuracy, information omissions, and errors. While earlier vectorization methods based on simple image processing algorithms improved efficiency to a certain extent, their segmentation precision and vectorization accuracy were poor for complex as-built drawings, particularly when faced with elements of varying shapes, significant scale differences, significant background noise, and a large number of irregular structures. For example, when extracting field boundaries, it was difficult to accurately capture complex boundary curves, resulting in severe jagged edges. Winding canals and roads were prone to problems such as breakpoints, discontinuities, and centerline extraction errors. When identifying point features such as wellheads, the surrounding environment interfered with the identification, leading to misjudgments or omissions. In addition, traditional methods have limited capabilities for the simultaneous extraction and classification of multiple elements in as-built drawings, making it difficult to meet the requirements of modern geographic information systems for high data precision, integrity, and consistency, and unable to efficiently provide reliable data support for the verification, maintenance, and land space planning of high-standard farmland construction projects. Summary of the Invention
[0005] The present application provides a method, device, equipment and storage medium for extracting and vectorizing multiple elements of a completion drawing to solve the technical problems raised by the background technology.
[0006] In a first aspect, the present application provides a method for extracting and vectorizing multiple elements from an as-built drawing, comprising: 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; The geographic coordinate system and projection parameters of the as-built drawing are written into the corresponding vector file to generate an independent layer file with geographic coordinate reference.
[0007] In one possible design, the as-built drawing is segmented to obtain binary mask images of fields, roads, canals, buildings, and wellheads, including: inputting the as-built drawing 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.
[0008] In one possible design, 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 means 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.
[0009] In one possible design, opening and closing operations, morphological smoothing, noise removal, and / or hole filling operations are performed on each binary mask image to generate an optimized single-category 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.
[0010] In a possible design, the vectorization strategy adopted by the planar element 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.
[0011] In one possible design, the vectorization strategy adopted for the linear features and point features specifically includes: 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.
[0012] In one possible design, the geographic coordinate system and projection parameters of the as-built drawing are written into a corresponding vector file to generate an independent layer file with a 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.
[0013] In a second aspect, the present application provides a device for extracting and vectorizing multiple elements from an as-built drawing, the device comprising: 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. The layer file generation module is configured to write the geographic coordinate system and projection parameters of the completion drawing into the corresponding vector file to generate an independent layer file with geographic coordinate reference.
[0014] In a third aspect, an embodiment of the present application provides an electronic device comprising: 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 method for extracting and vectorizing multiple elements of the completion drawing as described in the first aspect and various possible designs of the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the method for extracting and vectorizing multiple elements of the completion drawing as described in the first aspect and various possible designs of the first aspect is implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the method for extracting and vectorizing multiple elements of the completion drawing as described in the first aspect and various possible designs of the first aspect.
[0017] The method, apparatus, device, and storage medium for extracting and vectorizing multiple elements from as-built drawings provided in this application have at least the following beneficial effects: 1) In terms of feature extraction accuracy, this application improves the Backbone and Neck structures of the Mask2Former model, adopts SwinTransformerV2 instead of the traditional ResNet, and utilizes its hierarchical window attention mechanism and cross-window connection strategy to significantly improve the model's global modeling ability and position sensitivity for features of various shapes and significant scale differences in high-resolution as-built drawings; at the same time, the deformable convolutional feature pyramid network (DeformableFPN) is introduced into the Neck structure to enhance the expression ability of irregular structures such as field boundaries and curved canal segments by dynamically adjusting the sampling position, effectively solving the problems of low segmentation accuracy and severe boundary jaggedness in existing technologies.
[0018] 2) In order to improve the ability to process complex elements, this application introduces positional encoding of element geometry priors, encodes the geometric distribution characteristics of various elements into vectors for embedding in the query initialization process, and combines the edge-aware attention module in the decoder to extract the edge response map through the Sobel operator to guide the attention weight to focus on semantic boundaries, thereby reducing the overlap of adjacent class masks and boundary blurring. This significantly enhances the model's perception of spatially regularly distributed elements such as wellheads and buildings, as well as complex structures such as winding canals and broken roads, overcoming the shortcomings of existing technologies in their limited ability to simultaneously extract and classify multiple elements.
[0019] 3) In terms of vectorization processing efficiency and quality, this application adopts a differentiated vectorization strategy based on the feature geometry type (point, line, and surface): for surface features, the Douglas-Peucker algorithm is used to simplify the boundaries to generate polygon vectors; for linear features, the Zhang-Suen skeleton extraction algorithm is used to generate center lines; for point features, the centroid of the connected domain is calculated to generate point vectors. Compared with the single vectorization method in the existing technology, this significantly improves the accuracy and continuity of vectorization of different types of features, avoiding problems such as breakpoints and centerline deviations.
[0020] 4) In terms of improving model robustness, this application introduces multiple data augmentation strategies during the training process, including Gaussian filtering, non-local means denoising, CLAHE contrast enhancement, elastic deformation field simulation, pseudo-text noise overlay, and HSV color space jitter. These strategies effectively simulate interference factors such as noise, deformation, and lighting differences in as-built drawing scans, enabling the model to maintain high-precision segmentation in complex scenarios, thus addressing the problem of poor adaptability of existing technologies to drawing noise and diversity. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0022] 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; Figure 2 An architectural diagram of the improved Mask2Former semantic segmentation model provided in an embodiment of the present application; Figure 3 Flowchart of element vectorization processing provided in the embodiment of the present application; 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; 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.
[0023] 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
[0024] 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.
[0025] 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.
[0026] 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.
[0027] 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.
[0028] Example 1: The embodiment of the present application provides a method for extracting and vectorizing multiple elements of a completion drawing. It should be noted that the completion drawings described herein include but are not limited to completion drawings of high-standard farmland construction projects, such as Figure 1 FIG. 1 is an overall flow chart of the method for extracting and vectorizing multiple elements of as-built drawings provided in an embodiment of the present application. The method for extracting and vectorizing multiple elements of as-built drawings includes the following steps S100-S400.
[0029] S100: 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.
[0030] In some embodiments, a TIFF raster format as-built drawing containing geographic metadata is input into an improved Mask2Former semantic segmentation model to segment and output binary mask images of fields, roads, canals, buildings, and wellheads.
[0031] like Figure 2 The figure below shows the architecture of the improved Mask2Former semantic segmentation model provided in the embodiment of this application. In order to improve the model's ability to identify fine-grained boundary structures and the semantic segmentation accuracy of complex primitives during the multi-element extraction process of the as-built drawings, the Mask2Former model has been systematically improved in multiple key modules.
[0032] First, the Backbone network uses the SwinTransformerV2 structure to replace the traditional ResNet. By utilizing its hierarchical window attention mechanism and cross-window connection strategy, the model can obtain stronger global modeling capabilities and position sensitivity while maintaining computational efficiency. It is particularly suitable for processing the patch information with different shapes and significant scale differences in high-resolution as-built drawings.
[0033] The SwinTransformerV2 architecture extracts features from the input image layer by layer by constructing a hierarchical structure. Fixed-size non-overlapping windows are used within each layer for local attention calculations. A shifting window mechanism is introduced to enable cross-window information flow, thereby building global dependencies at a low computational cost. The window attention calculation process can be expressed as: , Where Q, K, and V are the linear mapping results of query, key, and value, respectively. d is the dimension of the key vector, and B is the relative position bias, which is used to enhance the model's perception of spatial structure. In cross-layer connections, the output of each layer not only participates in the attention calculation within the current layer window but is also fed into the next layer via a residual path, thereby preserving the synergistic information between high-level semantic features and underlying detailed features. To accommodate objects with complex shapes and large scale spans in the as-built image, such as fields, roads, canals, and wellheads, the hierarchical outputs of SwinTransformerV2 are fed into a feature pyramid structure for multi-scale fusion.
[0034] Secondly, a deformable convolutional feature pyramid network (DeformableFPN) is added to the Neck structure to dynamically adjust the sampling position during the fusion of features at different scales, thereby enhancing the ability to express irregular structures such as field boundaries and curved canal segments.
[0035] The Deformable Convolutional Feature Pyramid Network (DFC) extends the multi-scale feature fusion mechanism of the original FPN and applies a deformable convolution module to each scale feature map to achieve adaptive sampling of key spatial locations, thereby improving sensitivity to features with complex boundaries and morphological distortions. In standard convolution, the sampling locations are fixed integer grids, while deformable convolution introduces a learnable offset on this basis, dynamically selecting the locations with the strongest response from the input feature map for aggregation. The operation process is expressed as follows: , in Indicates the output location The response of x is the input feature map, is the weight of the k-th position of the convolution kernel, is the standard sampling offset, is a variable offset learned through convolution. This mechanism allows the network to spatially focus on key response areas of irregular morphological structures, significantly improving its perception of objects such as winding canals, broken roads, and fields with blurred boundaries. To account for multi-scale contextual information, DeformableFPN employs a layer-by-layer upsampling and lateral connection strategy, fusing underlying edge details with high-level semantic abstractions to form a feature pyramid. The fused feature map generated through cross-layer stacking between scales participates in the subsequent mask prediction process, thereby improving the overall model's segmentation consistency and edge localization accuracy for multi-morphological and multi-scale features.
[0036] Aiming at the query mechanism, the position encoding of feature geometry prior is introduced. The geometric distribution characteristics of each type of feature in the image are encoded as a vector and embedded into the query initialization process, which improves the decoder's ability to perceive features with significant regularity in spatial distribution, such as wellheads and buildings.
[0037] Specifically, when the model initializes the query vector, it no longer uses a uniform random embedding or pure position encoding. Instead, it constructs a category-discriminative location prior vector based on the geometric distribution characteristics of elements such as fields, buildings, roads, canals, and wellheads in the as-built drawings. This prior is generated by extracting the feature mean and variance from a statistically derived heat map of the spatial distribution of these elements. This is then concatenated or combined with the basic query vector to form a more discernible category-guided query vector. The location prior encoding process can be expressed as: , in is the horizontal and vertical distribution mean of the c-th type element, is the standard deviation of the corresponding direction, MLP is the multi-layer perceptron encoding function, and finally generates the unique geometric position embedding of each type of element After the position code is embedded in the query process, it guides attention to the expected area in the decoding stage, improving the extraction accuracy of local structures such as wellheads.
[0038] To enhance the model's attention to edge contours, an edge-aware attention module is integrated into the decoder to guide the attention weights to focus on semantic boundary areas, thereby reducing mask overlap and boundary blur between adjacent classes.
[0039] The edge-aware attention module guides attention by explicitly introducing an edge map. During the interaction between each mask feature and the input feature, the edge response map G extracted by the Sobel operator is introduced and used as a weight to modulate the attention map. The specific adjustment method is as follows: , in is the dot product result of the query key, d is the dimension scaling factor, G is the normalized output of the edge response map, This mechanism enables the attention mechanism to explicitly perceive the importance of boundary regions, thereby forming a clear separation between adjacent feature categories, significantly reducing mask boundary blur and category overlap, and improving the continuity of roads and canals and the clarity of building boundaries.
[0040] In terms of loss function, a weighted combination of boundary IoU loss (BoundaryIoULoss) and class-aware mask loss (Class-awareMaskLoss) is used. The boundary IoU loss is defined by comparing the matching degree between the predicted mask and the true mask boundary area as follows: , in and Represent the boundary sets of the predicted mask and the true mask respectively. The category-sensitive mask loss is based on the multi-category mask cross entropy loss and the regional IoU weighted term: , in and are the true label and predicted probability of class c, respectively. is the category weight, represents the regional IoU value of the class, and λ is the balance coefficient. The final joint loss function is defined as: , in 、 is a loss weight hyperparameter. Through the above module-level optimization, the model significantly improves the extraction accuracy and boundary clarity of multiple geographic features in the high-standard farmland completion map while maintaining computational efficiency, providing high-quality input for subsequent feature vectorization and geographic information fusion.
[0041] In some embodiments, to improve the robustness of the Mask2Former model to the diversity and noise interference of real-world as-built drawings, various targeted data augmentation strategies are introduced during the training process. By applying Gaussian filtering and non-local means denoising to the input drawings, we simulate the optical blur that may exist in scanned documents and the degradation of details caused by drawing aging. Gaussian filtering uses a two-dimensional convolution kernel to control the overall blur of the image, which is expressed as: , Where σ controls the blur intensity, and x and y are the coordinates symmetrical to the kernel center. Non-local means denoising searches for similar blocks in the image and performs a weighted average to preserve structural details while reducing background noise. Its core is a weighted function based on the similarity between pixel blocks: , in is the pixel value after denoising, w(p,q) is the weight function, h is the filter scale factor, Z(p) is the normalization factor, and Ω is the search window.
[0042] Secondly, the Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm is used to enhance image contrast, highlighting the grayscale gradient characteristics of linear features such as roads and canals, and preventing overexposure or underexposure that can cause edge breakage. CLAHE divides the image into blocks, performs histogram equalization on each block, and limits local contrast gain to improve texture clarity.
[0043] In order to simulate the displacement distortion caused by the physical deformation of the drawing, an elastic deformation field is randomly generated in the training set to produce spatial nonlinear perturbations in the local area of the image. Elastic deformation is achieved by adding smooth Gaussian noise perturbations to the original coordinates, and is often expressed as follows: , Where α is the perturbation intensity, and is the two-dimensional random displacement field after Gaussian kernel smoothing.
[0044] In terms of interference enhancement, in order to train the model to have the ability to distinguish real lines from background information such as printing, text, and labels, pseudo-text noise blocks with random positions, fonts, and sizes are superimposed as cover to simulate non-structural information such as drawing annotations and seals, thereby enhancing the model's ability to discriminate linear continuity and semantic context.
[0045] Finally, to enhance the model's adaptability to scanning lighting conditions, we used HSV color space dithering to perturb image brightness and hue. By adding small fluctuations to the Hue, Saturation, and Value channels, we constructed scenarios with varying lighting distributions. This enabled the model to learn robust semantic feature extraction capabilities under varying exposure, reflections, and scanning skew. These enhancement strategies were dynamically applied to the original drawing samples during training, effectively improving the model's generalization performance and ensuring high-precision segmentation output despite the complex feature structure and interference factors found in high-standard farmland as-built images.
[0046] S200: performing opening and closing operations, morphological smoothing, noise removal and / or hole filling operations on each binary mask image to generate an optimized single-category mask.
[0047] In this embodiment, step S200 is a step of post-processing the mask image, which generates an optimized single-category mask by performing opening and closing operations, morphological smoothing, noise removal, and hole filling operations on each element mask image.
[0048] In some embodiments, to improve the geometric integrity and vectorizability of the various feature mask images generated by the Mask2Former model, differentiated post-processing strategies are used for different categories. For building masks, since they often have linear interruptions in as-built images due to scanning breaks and missed edges, a morphological closing operation of seven by seventy cross-shaped structuring elements is performed in post-processing to bridge the gaps. The closing operation consists of a dilation operation followed by an erosion operation, which is defined as: , Where A represents the binary mask image, B is a seven-by-seven cross-shaped structure element, and ⊕ is the dilation operation. For the erosion operation, the structural features are matched to the linear edge orientation of the building, improving the mask connectivity by closing the broken edges.
[0049] The canal mask is characterized by being long and narrow and curved, which can easily lead to a large number of isolated noise patches due to false detection. To eliminate such false responses, an area threshold filtering operation is applied to calculate the area of each connected domain and set a minimum retained area threshold. , the noise area with an area smaller than the threshold is set as the background. The area calculation is based on pixel count: , in represents the area of the i-th connected region, This operation effectively preserves the continuous linear structure while removing isolated fragments, improving the reliability of canal feature extraction.
[0050] For the field mask, in order to solve the problem of jagged edges and discontinuous contours in the segmentation results, a mask reconstruction operation based on morphological gradient is performed to smooth the edges. First, the morphological gradient of the original mask is calculated: , Here, G represents the gradient image, A is the field mask, and B is the structuring element. The subtraction operation reflects the edge pixel gradient. A mask reconstruction operation is then performed to integrate the original image structure with the smoothed contours. The label map guides the repair process, eliminating isolated jagged edges and small-scale edge offsets. Ultimately, a field mask image with continuous structure and regular boundaries is generated, providing an accurate boundary foundation for subsequent polygon vectorization. These post-processing steps are optimized based on feature type, improving the model segmentation results in terms of spatial coherence, shape integrity, and boundary quality.
[0051] S300: 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.
[0052] In this embodiment, step S300 is a feature-specific vectorization step, in which the mask is divided into three categories: point, line, and surface according to the feature geometry type, and different vectorization strategies are adopted for each. In some embodiments, in order to achieve accurate vectorization representation of multiple types of features such as fields, canals, buildings, and wellheads in the as-built drawings, the mask is divided into three categories: surface, line, and point according to the geometric properties, and a specific processing flow is performed for each type. Figure 3 As shown, it is a flowchart of the element vectorization processing provided by an embodiment of the present application.
[0053] Specifically, for the mask of the area feature, the internal pores and boundary gaps are first filled through the morphological closing operation to ensure the topological closure of the polygon. The operation is defined as the mask image is first expanded and then eroded: , Where M is the original mask image, B is the structural element, and M′ is the result of the closing operation. This step fills the non-structural holes caused by segmentation errors or scanning interference. The Canny edge detection algorithm is then applied to obtain continuous edges with gradient mutations in the binary mask image to form a closed boundary contour for subsequent polygon construction. The algorithm first calculates the gradient magnitude G(x, y) and direction : , in The horizontal and vertical gradients of the image. After edge extraction, the Douglas-Peucker algorithm is used to compress the boundary point sequence, reducing the number of vertices while preserving the contour features. This algorithm uses the distance error of the farthest point as a simplification criterion and outputs an approximate polygon described by fewer nodes, achieving compactness and stability in vector representation.
[0054] For linear feature masks, to accurately restore the central path of slender features, a medial axis transformation is first performed to generate a one-pixel-wide skeleton structure. Local maximum points are then extracted and connected using a distance transformation to form a skeleton path. Once the skeleton is generated, Freeman chain codes are used to describe its directional changes. Skeleton line segments are encoded as digital sequences within an eight-neighborhood pattern. Discontinuous segments are identified and connected through linear interpolation. Further, jagged paths are smoothed to improve geometric continuity and readability after vectorization of line features.
[0055] For point feature masks, we first use the connected domain labeling algorithm to identify each independent entity area in the graph based on the 8-adjacency relationship and assign a unique label to achieve accurate separation of multiple adjacent point targets. Calculate its geometric center as the position coordinate of the entity. The calculation formula is: , in is the number of pixels in the i-th region, The centroid coordinates are used as the coordinates of the mask's center of mass. This method avoids point offsets caused by blurred mask boundaries, and the generated vector points accurately reflect the location attributes of actual point features such as wellheads. Through the above process, the mask output by the model is converted into a well-structured and reliable vector layer through specialized geometric processing, providing high-quality foundational data for subsequent spatial analysis and layer overlay.
[0056] To ensure that the structured representation of various elements in the as-built drawings meets GIS standards, each category of elements is output as a separate ESR File after mask vectorization, and the corresponding layer type is assigned according to its geometric attributes. Field features are defined as polygon layers after mask boundary extraction and polygon construction. Each field is constructed as a polygon feature using a closed sequence of points. The boundary coordinate set of the point sequence, compressed using the Douglas-Peucker algorithm, is represented as: , The set P represents a sequence of field contour points. The last item returns to the starting point to ensure topological closure. It is stored as a polygon type in the Shapefile and can be supplemented with attribute fields such as field number, area, and classification code.
[0057] For road and canal features, after skeleton extraction and path smoothing, the result is represented as a set of continuous line segments. Each line segment consists of an ordered list of points, and the output is a polyline type layer. Each line feature is represented as: , The point sequence L is a path sequence of the skeleton line and does not form a closed loop. It is used to record the direction of the canal and the trajectory of the road. In the attribute table, it can be associated with width, material or functional classification information.
[0058] Building elements, like fields, are surface structures. The segmentation mask is processed by closing operations and boundary extraction to form an outline. After constructing closed polygons, it is output as a polygon type layer. Its processing logic is the same as that of fields, but fields such as building purpose, height level, and number can be added for subsequent layer query and statistical analysis.
[0059] The wellhead feature is a point object. The mask is calculated by the centroid of the connected domain to generate a spatial point. Each wellhead is represented by a two-dimensional coordinate (x, y) and output as a point type layer. Each point feature can be accompanied by information such as the well number, water source type, and functional attributes. To ensure the consistency of the coordinate system, all layers are constructed by calling the OGR interface through the GDAL library, and the geographic reference information extracted from the original TIFF raster map is written into the projection definition file PRJ of each Shapefile file, so that all output layers have a unified spatial benchmark and 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 as-built drawings.
[0060] S400: 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.
[0061] In this embodiment, step S300 is a step of geographic information fusion output, which uses the GDAL library to write the geographic coordinate system and projection parameters of the original TIFF image into the ESR Sharefile vector file of the corresponding element to generate an independent layer file with geographic coordinate reference.
[0062] In some embodiments, in order to achieve the conversion from the mask image vectorization result to a standard GIS layer with a geographic reference, key geographic information is first extracted from the image header file of the original TIFF format as-built drawing, including GeoTransform parameters and Projection definitions. GeoTransform is a set of six floating-point numbers that describes the linear mapping relationship between image coordinates and geographic space coordinates, which includes the geographic coordinates of the upper left corner of the image, pixel resolution and rotation information, and is the basis for aligning raster data with geographic space. The Projection field defines the projection coordinate system to which the TIFF image belongs, such as WGS84, UTM or the National Geodetic Coordinate System, to ensure the consistency and superposition of subsequent vector layers in spatial positioning.
[0063] During the vector layer creation phase, the CreateLayer function in the GDAL library is called to generate a corresponding point, line, or polygon layer for each type of vectorized feature result. This function accepts parameters such as the layer name, driver type, spatial reference object, and geometry type to ensure that the output file format and geometry conform to the ESR Shapefile 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 a correct geographic spatial definition.
[0064] Finally, the SetGeoTransform function is called to bind the aforementioned GeoTransform parameters to the output layer, accurately mapping the coordinate position of each spatial feature in the vector layer from pixel index to actual geographic coordinates. This process completes the spatial transformation from the image domain to the map domain, ensuring that the output point, line, and surface Shapefiles possess true geographic location attributes and can be spatially overlaid with other geographic data for analysis. This fusion process is a key step in converting multiple elements of the as-built drawing into GIS data, ensuring the accuracy and spatial consistency of the data output and providing a stable foundation for the subsequent development of a high-standard farmland information system.
[0065] Example 2: The embodiment of the present application provides a method for extracting and vectorizing multiple elements of a completion drawing. The method is applied to the extraction and vectorization of multiple elements of a completion drawing of a high-standard farmland construction project. For example, a completion drawing of a project covering an area of 2,000 mu of farmland is used. Figure 4 As shown, the method includes the following steps S1 to S4.
[0066] S1. As-built drawing segmentation processing: Prepare as-built drawings in TIFF raster format containing geographic metadata as input data, ensuring that the image resolution meets the model processing requirements and is at least 300 dpi. The as-built drawings are fed into the improved Mask2Former semantic segmentation model with the following model parameters: The initial learning rate is set to 0.0001, and a cosine annealing learning rate scheduling strategy is used to gradually adjust the learning rate and optimize the model training process. The batch size is set to 16; increasing the batch size appropriately, if memory allows, can help improve training efficiency and model stability. The number of training rounds is set to 100, allowing the model to fully learn the characteristic patterns in the as-built drawings through multiple rounds of training. During model training, NVIDIA GPU acceleration is used to increase processing speed. The model is based on an improved Mask2Former architecture. Its backbone utilizes the SwinTransformerV2 structure, while the Neck architecture incorporates a Deformable Convolutional Feature Pyramid Network (DeformableFPN). It also incorporates positional encoding of feature geometry priors and an edge-aware attention module, optimizing the query mechanism and loss function to improve the segmentation accuracy of features such as fields, roads, canals, buildings, and wellheads in as-built images. The model segmentation outputs binary mask images of fields, roads, canals, buildings, and wellheads. Each feature corresponds to a separate mask image, with the foreground (feature) being white (pixel value 255) and the background being black (pixel value 0).
[0067] S2. Mask Image Post-Processing: For the field mask image, a mask reconstruction operation based on morphological gradients is performed. First, a three-by-three square structuring element is selected, and the morphological gradient of the original mask is calculated. Subsequently, a mask reconstruction operation is performed, using a labeled map to guide the inpainting process, removing isolated jagged edges and small-scale edge offsets. This operation is based on a morphological reconstruction algorithm. Through continuous iterations, the mask image's boundaries are gradually smoothed, ultimately generating a field mask image with continuous structure and regular boundaries. For the building mask, due to the frequent occurrence of linear discontinuities, a morphological closing operation is performed using a seven-by-seven cross-shaped structuring element. This closing operation consists of a dilation operation followed by an erosion operation. The shape and size of this structuring element match the linear edge alignment of the building. The dilation operation expands the edges of the discontinuities, and the erosion operation retracts the expanded edges, thus closing the gaps and improving the mask connectivity. For the canal mask, which is long and curved and prone to isolated noise patches, an area threshold filtering operation is applied. The minimum retained area threshold is set to 100 pixels, and the area of each connected domain is calculated based on pixel counts. Noise areas with an area smaller than the threshold are set as background, effectively retaining the continuous linear structure while removing isolated fragments, thereby improving the reliability of canal feature extraction.
[0068] S3. Feature-Specific Vectorization: When vectorizing planar features such as fields and buildings, a morphological closing operation is first performed on the mask to fill internal pores and boundary gaps. A five-by-five square structuring element is selected. The closing operation is defined as dilation followed by erosion of the mask image. This operation fills non-structural holes caused by segmentation errors or scanning interference, ensuring polygon topological closure. The Canny edge detection algorithm is then applied to obtain continuous edges with gradient abrupt changes in the binary mask image, forming a closed boundary contour. During the Canny edge detection process, a low threshold of 50 and a high threshold of 150 are set to accurately detect edges. The Douglas-Peucker algorithm is used to compress the boundary point sequence, reducing the number of vertices while preserving contour features. This algorithm uses a maximum point distance error of 0.5 as a simplification criterion to output approximate polygons described by fewer nodes, achieving compactness and stability in vector representation. For linear features such as roads and canals, the mask is first transformed using the medial axis to generate a one-pixel-wide skeleton structure. A distance transform is then used to connect the local maximum points to form a skeleton path. Freeman chain code is used to describe its direction change, and the skeleton line segments are encoded into digital sequences in the eight-neighborhood pattern. Discontinuous segments are identified and connected by linear interpolation. For jagged paths, cubic spline interpolation algorithm is used for smoothing to improve the geometric continuity and readability of line features after vectorization. For example, the point feature mask of the wellhead is used. The connected domain labeling algorithm is used to identify each independent entity area in the graph based on the 8-adjacency relationship and assign a unique label to each connected area. Calculate its geometric center as the position coordinate of the entity. The calculation formula is: ,in is the number of pixels in the i-th region, This method avoids the point offset problem caused by the blurred mask boundary, and the generated vector points accurately reflect the location attributes of point features such as the actual wellhead.
[0069] S4. Geographic Information Fusion Output: Extract key geographic information from the image header file of the original as-built TIFF format drawing. Use the relevant GDAL library functions to read the image header file and obtain the GeoTransform parameters and Projection definition. The GeoTransform is a set of six floating-point numbers that describes the linear mapping between image coordinates and geospatial coordinates. It includes the geographic coordinates of the upper left corner of the image, pixel resolution, and rotation information. The Projection field defines the projection coordinate system of the TIFF image, such as WGS84, UTM, or the National Geodetic System. During the vector layer creation phase, the CreateLayer function in the GDAL library is called to generate corresponding point, line, or polygon layers for each type of vectorized feature. For example, for field features, a polygon layer is created with the following function parameters: set the layer name to "Field," select the driver type as ESRShapefile, set the spatial reference object according to the extracted Projection definition, and set the geometry type to polygon. 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. Finally, call the SetGeoTransform function and bind the GeoTransform parameters to the output layer. This ensures that the coordinates of each spatial feature in the vector layer are accurately mapped from pixel indices to actual geographic coordinates. For example, for a field layer, the vertex coordinates of the field polygons are converted from pixel coordinates to geographic coordinates. This ensures that the output vector file has true geographic location attributes and can be spatially overlaid with other geographic data for analysis.
[0070] Based on steps S1-S4 above, a project completion map covering an area of 2,000 mu of farmland is taken as an example. It contains various types of fields, crisscrossing roads and canals, several buildings, and wellheads distributed throughout. First, the TIFF raster format completion map of the project is input into the improved Mask2Former semantic segmentation model for processing. During the model training phase, a dataset containing similar high-standard farmland completion maps in and around the area, totaling 500 images, was used to train and optimize the model. After model segmentation processing, binary mask images of fields, roads, canals, buildings, and wellheads are obtained. From the field mask image, it can be seen that the originally complex and fuzzy-bordered fields are clearly segmented. Even the boundaries of irregularly shaped fields with tortuous boundaries can be accurately outlined, which is highly consistent with the actual field shape. In the mask image post-processing stage, after performing a mask reconstruction operation based on morphological gradients on the field mask, the jaggedness 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 a mathematical morphological closing operation on a seven-by-seven cross-shaped structural element, the linear interruptions originally caused by scanning problems were bridged, the building outlines became more complete, and connectivity was significantly improved. In the feature-specific vectorization stage, the polygonal field features were processed through morphological closing operations, Canny edge detection, and the Douglas-Peucker algorithm. The resulting polygon vectors can accurately represent the shape and extent of the fields. The number of polygon vertices in the vector file is reasonable, which not only retains the key shape features of the fields but also achieves compact data storage. For the linear canal features, after medial axis transformation, Freeman chain code description, and path smoothing, the centerline vector obtained by vectorization can accurately reflect the direction of the canal. The centerline is continuous and smooth, without breakpoints or obvious deviations. Finally, in the geographic information fusion output stage, the GDAL library is used to write the geographic coordinate system and projection parameters of the original TIFF image into the ESR Shapefile vector file of the corresponding feature. The generated vector layers of various elements were displayed and analyzed in ArcGIS software, clearly showing the geographic distribution of elements such as fields, roads, canals, buildings, and wellheads. By overlaying this data with the region's current land use and terrain data, the rationality of land use, facility layout, and terrain compatibility of the high-standard farmland construction project can be intuitively analyzed. For example, the overlay analysis revealed that the construction locations of some roads are well-suited to the terrain slope, facilitating the passage of agricultural machinery. It also revealed that there is room for improvement in the connection between individual fields and surrounding water systems, providing data support for subsequent farmland optimization and renovation.
[0071] Example 3: The present application also provides a device for extracting and vectorizing multiple elements of a completed drawing. Figure 5As shown, the as-built drawing multi-element extraction and vectorization device includes: The image segmentation module 501 is 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 502 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 503 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 respectively 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. The layer file generation module 504 is configured to 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.
[0072] An embodiment of the present application provides an electronic device, which may include a processor and a memory, wherein the processor and the memory can communicate with each other; illustratively, the processor and the memory communicate with each other via a communication bus.
[0073] The processor executes the computer-executable instructions stored in the memory, so that the processor implements the solutions 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 devices, discrete gate or transistor logic devices, or discrete hardware components.
[0074] The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. System buses can be categorized as address buses, data buses, and control buses. Transceivers facilitate communication between the database access device and other computers (e.g., clients, read-write libraries, and read-only libraries). Memory may include random access memory (RAM) or non-volatile memory.
[0075] The electronic device provided in the embodiment of the present application may be the terminal device of the above embodiment.
[0076] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the technical solution of the method for extracting and vectorizing multiple elements of the as-built drawing in the above embodiment.
[0077] An embodiment of the present application also 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. When the at least one processor executes the computer program, it can implement the technical solution of the method for multi-element extraction and vectorization of completion drawings in the above embodiment.
[0078] In the several embodiments provided in this 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 merely illustrative. For example, the division of modules is only a logical function division. In actual implementation, there may be other division methods, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or module, which can be electrical, mechanical or other forms.
[0079] Modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of these modules may be selected to implement the solution of this embodiment based on actual needs.
[0080] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each module may exist physically separately, or two or more modules may be integrated into a single unit. The aforementioned module integration unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0081] The integrated modules implemented in the form of software function modules can be stored in a computer-readable storage medium. The software function modules stored in a storage medium include a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute some of the steps of the methods of various embodiments of the present application.
[0082] It should be understood that the processor described above may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the present invention may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.
[0083] The memory may include a high-speed RAM memory, and may also include non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk.
[0084] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be divided into address buses, data buses, and control buses.
[0085] The storage medium may be implemented by any type of volatile or non-volatile memory device, 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 may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0086] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral 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 also exist as discrete components in an electronic control unit or a main control device.
[0087] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0088] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions 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; The geographic coordinate system and projection parameters of the as-built drawing are written into the corresponding vector file to generate an independent layer file with geographic coordinate reference.
2. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1, characterized in that: 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.
3. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 2 is 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.
4. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1, 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.
5. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1 is 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.
6. The method for extracting and vectorizing multiple elements of as-built drawings according to claim 1, 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.
7. 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.
8. A device for extracting and vectorizing multiple elements of a completed drawing, characterized by: 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. The layer file generation module is configured to write the geographic coordinate system and projection parameters of the completion drawing into the corresponding vector file to generate an independent layer file with geographic coordinate reference.
9. 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 7.
10. 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 7.
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
Building extraction method and system of unified grid vector, and electronic equipment
CN118570641A
Farmland construction quality intelligent sampling inspection method, system and device and storage medium
CN120355086A
Semantic vector map robust construction method and device, storage medium and program product
CN120495558A
Cited By
Water body segmentation method and system, computer equipment and storage medium
CN121458741A
SAM-GAN-based building image segmentation method and system
CN121685576A
Method and system for identifying and analyzing electromagnetic and acoustic environment sensitive target of power transmission line based on artificial intelligence and geographic information system
CN121708474A