Building contour optimization method, device, equipment, medium and product

A building contour optimization method based on two-stage rotation search and adaptive judgment in geographic coordinates solves the accuracy and stability problems caused by fixed parameters in existing technologies, and achieves efficient and accurate contour extraction under different image resolutions and building densities.

CN122156672APending Publication Date: 2026-06-05NAVINFO

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NAVINFO
Filing Date
2026-03-03
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing building outline optimization methods suffer from poor generalization ability and low accuracy in extracting outlines due to their reliance on fixed parameters. In particular, they lack stability and generalization ability in automated processing when building density changes, and they cannot effectively handle multiple overlapping situations.

Method used

A two-stage rotational search is performed under WGS84 geographic coordinates to calculate the minimum bounding rectangle. The processing flow is dynamically adjusted by combining the intersection-union ratio and geometric parameters. Irregular buildings are handled by acute angle filtering and short side filtering. A small intersection ratio decision mechanism is introduced to optimize multiple overlaps. Computational efficiency is improved by sparse matrix storage.

Benefits of technology

It improves the geometric accuracy and robustness of building outline extraction, generates more accurate and non-redundant building instance results, reduces processing complexity, and achieves automated generation with controllable quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122156672A_ABST
    Figure CN122156672A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a building contour optimization method, device, equipment, medium and product. The method comprises: converting a contour pixel coordinate of an initial mask of a building into a geographic coordinate; performing a rotation search on the initial mask based on the geographic coordinate to determine a minimum circumscribed rectangle of the initial mask; determining a building mask of the building according to the minimum circumscribed rectangle and the initial mask; and determining contour information of the building according to the building mask of the building. The method is used to improve the contour extraction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, equipment, medium and product for optimizing building contours. Background Technology

[0002] In the fields of intelligent interpretation of remote sensing images and automated production of geographic information, the geometric normalization of building outlines is a key step in connecting pixel-level segmentation results with vector map outputs. This technology is widely used in scenarios such as smart cities, 3D real-scene China, and high-precision map updates. It aims to transform the original segmentation mask into a standardized polygonal outline with a simple structure, orthogonal angles, and conforming to the prior knowledge of artificial buildings, in order to meet cartographic standards and downstream application requirements.

[0003] Existing methods generally employ a fixed processing flow and parameter configuration, including noise cleanup based on morphological operations (such as a fixed number of erosions / dilations), vertice simplification using the Douglas-Peucker algorithm, and geometric correction based on preset thresholds.

[0004] However, existing methods suffer from poor generalization ability in building profile optimization due to their reliance on fixed parameters, resulting in low accuracy of the extracted profiles. Summary of the Invention

[0005] The building outline optimization method, apparatus, equipment, medium, and product provided in this application are used to improve the accuracy of outline extraction.

[0006] In a first aspect, embodiments of this application provide a method for optimizing building outlines, including:

[0007] Convert the outline pixel coordinates of the building's initial mask to geographic coordinates;

[0008] Based on geographic coordinates, a rotational search is performed on the initial mask to determine the minimum bounding rectangle of the initial mask;

[0009] The building mask is determined based on the minimum bounding rectangle and the initial mask;

[0010] The building's outline information is determined based on the building mask.

[0011] In one possible implementation, a rotational search is performed on the initial mask based on geographic coordinates to determine the minimum bounding rectangle of the building mask, including:

[0012] Based on geographic coordinates, a rotation search is performed with a first angular step size to determine the minimum bounding rectangle of the initial mask under multiple candidate rotation angles.

[0013] Based on the minimum bounding rectangle under the target rotation angle, within a preset angle range, a rotation search is performed with a second angle step to determine the minimum bounding rectangle of the initial mask; the second angle step is smaller than the first angle step.

[0014] In one possible implementation, determining the building mask of the building based on the minimum bounding rectangle and the initial mask includes:

[0015] Determine the intersection-union ratio between the minimum bounding rectangle and the initial mask;

[0016] If the cross-union ratio (CUNR) is greater than the CUNR threshold, the initial mask is used as the building mask for the building. The CUNR threshold is determined based on the aspect ratio of the minimum bounding rectangle and / or the mask area of ​​the minimum bounding rectangle.

[0017] In one possible implementation, after determining the intersection-union ratio of the minimum bounding rectangle to the initial mask, the method further includes:

[0018] If the cross-union ratio is less than the cross-union ratio threshold, the contour of the initial mask is filtered to obtain a filtered mask; the filtering process includes acute angle filtering and / or short side filtering.

[0019] The confidence level of the filter mask is determined based on the cross-union ratio between the filter mask and the initial mask.

[0020] The building mask is obtained based on the filter mask and the confidence level of the filter mask.

[0021] In one possible implementation, determining the building mask of the building based on the minimum bounding rectangle and the initial mask includes:

[0022] Determine the number of buildings within the target area;

[0023] When the number of buildings exceeds the first preset number, traverse the target area and determine the first and second buildings within the target area; the first and second buildings are two different buildings within the target area.

[0024] Based on the intersection ratio between the first building mask and the second building mask, an instance optimization operation is performed on the first building and the second building to determine the optimized building and the building mask of the building; the first building mask is the building mask of the first building, and the second building mask is the building mask of the second building; the intersection ratio represents the coverage ratio of the smaller mask area in the first building mask and the second building mask.

[0025] In one possible implementation, after determining the number of buildings within the target area, the method further includes:

[0026] When the number of buildings is greater than the second preset number, adjust the size of the target area until the number of buildings in the target area is less than or equal to the second preset number. Then, traverse the target area and determine the first and second buildings in the target area. The second preset number is greater than the first preset number.

[0027] In one possible implementation, based on the crossover ratio between the first building mask and the second building mask, an instance optimization operation is performed on the first building and the second building to determine the instance-optimized building and the building mask of the building, including:

[0028] If the cross ratio is greater than the first threshold, then the mask of the building with the smaller mask area in the first building and the second building is deleted, and the deleted building and the building mask of the building are determined.

[0029] If the intersection ratio is less than the first threshold and greater than the second threshold, or if the intersection ratio is less than the second threshold and the mask overlap area is greater than the preset overlap area, then the first building mask and the second building mask are merged to obtain a merged mask.

[0030] Based on the filter-merged mask and its confidence level, the building and its building mask are determined; the filter-merged mask is obtained by filtering the merged mask, and the confidence level of the filter-merged mask is determined based on the cross-union ratio of the merged mask and the filter-merged mask.

[0031] If the cross ratio is less than the second threshold and the mask overlap area is less than the preset overlap area, then the first building mask and the second building mask are etched to obtain the first etched mask and the second etched mask.

[0032] Based on the first corrosion mask and the first building mask, as well as the second corrosion mask and the second building mask, the first corrosion mask and the second corrosion mask are merged or deleted to determine the processed building and the building mask of the building.

[0033] In one possible implementation, determining the building's outline information based on the building mask includes:

[0034] Extract the main outline of the building based on the building mask;

[0035] The main outline of the building is filtered to obtain the filtered main outline.

[0036] After the confidence level of the filtered main outline meets the preset confidence level requirements, the base outline and roof projection outline of the building are generated; the confidence level of the filtered main outline is obtained after performing legality and / or rationality checks on the filtered main outline.

[0037] The coordinates of the building's base outline and roof projection outline are transformed to obtain and display the building's outline information.

[0038] In one possible implementation, the building mask is stored using a sparse matrix storage structure.

[0039] Secondly, embodiments of this application provide a building outline optimization device, comprising:

[0040] The conversion module is used to convert the outline pixel coordinates of the initial mask of a building into geographic coordinates;

[0041] The search module is used to perform a rotational search on the initial mask based on geographic coordinates to determine the minimum bounding rectangle of the initial mask;

[0042] The first determining module is used to determine the building mask of the building based on the minimum bounding rectangle and the initial mask;

[0043] The second determining module is used to determine the outline information of the building based on the building mask.

[0044] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;

[0045] The memory stores instructions that the computer executes;

[0046] The processor executes computer execution instructions stored in memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.

[0047] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.

[0048] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.

[0049] The building contour optimization method, apparatus, equipment, medium, and product provided in this application convert the contour pixel coordinates of the initial mask of the building into geographic coordinates, and perform rotation angle search in the geographic coordinate system to calculate the minimum bounding rectangle that best fits the building mask, avoiding geometric distortion caused by a fixed orientation. Based on this, the geometric parameters of the minimum bounding rectangle and the initial mask are combined to dynamically determine whether to use the minimum bounding rectangle to replace or enter the orthogonalization process, thereby determining the building mask and the contour information of the building. Thus, by integrating the scale consistency of geographic coordinates with an adaptive judgment strategy, the consistency of contour regularization under different image resolutions and building density scenes is improved, thereby improving the geometric accuracy and practicality of the building extraction results.

[0050] Furthermore, a two-stage rotational search can quickly find the minimum bounding rectangle. After finding the minimum bounding rectangle, the intersection-union ratio (IU) between the minimum bounding rectangle and the initial mask is calculated to determine whether the building is a standard rectangular building. If the building is a standard rectangular building, the building mask is determined based on the minimum bounding rectangle. If the building is a non-standard rectangular building, acute angle filtering and / or short side filtering are used to determine the building mask. This approach can take into account the geometric characteristics of both regular and irregular buildings, improving the accuracy and robustness of building mask extraction. Simultaneously, a confidence score can be determined for building masks using acute angle filtering and / or short side filtering. This confidence score can be used for subsequent decision-making, thereby enabling automated contour generation with controllable quality and traceable results.

[0051] For cases where there are at least two buildings, their overlapping relationship can be determined based on the intersection ratio. This allows for targeted optimization operations such as merging, deletion, or morphological correction, resulting in more accurate and non-redundant building instance results. Furthermore, to reduce processing complexity, the number of buildings can be set to within a second preset number by adjusting the region size, ensuring that subsequent traversal, pairing, and instance optimization operations based on the intersection ratio can be performed under reasonable load and reliable accuracy.

[0052] Finally, during building contour extraction, the building mask is stored using a sparse matrix storage structure. This saves memory space and improves computational efficiency, enhancing the efficiency of processing large batches of tasks. Simultaneously, by filtering the main building contour for noise, debris, and irregular edges, a more complete and cleaner filtered main contour is obtained. Legality and / or rationality checks are then performed on this filtered main contour, and its confidence level is calculated. Only when the confidence level of the filtered main contour reaches a preset threshold are the building's base contour and roof projection contour generated. Subsequently, these two contours are transformed from the image coordinate system to the geographic coordinate system or other unified spatial reference system, completing coordinate alignment and standardization, and finally outputting the final building contour information. This achieves the effect of improving the accuracy of contour extraction. Attached Figure Description

[0053] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0054] Figure 1 A schematic diagram illustrating a scenario for the building outline optimization method provided in this application;

[0055] Figure 2 A flowchart illustrating a building outline optimization method provided in this application;

[0056] Figure 3 A flowchart illustrating another building outline optimization method provided in this application;

[0057] Figure 3a A comparative illustration of rectangular replacement of buildings provided in this application;

[0058] Figure 3b A comparative diagram illustrating the non-rectangular orthogonalization of buildings provided in this application;

[0059] Figure 3c A comparative diagram illustrating the example optimization processing of buildings provided in this application;

[0060] Figure 4 A structural schematic diagram of the building outline optimization device provided in this application;

[0061] Figure 5 A schematic diagram of the structure of the electronic device provided in this application.

[0062] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0063] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0064] First, let me explain the terms used in this application:

[0065] Building outline extraction refers to the process of automatically identifying and accurately delineating the outer boundary (including the base outline and / or roof projection outline) of a building from data such as remote sensing images, aerial images, or 3D point clouds through image processing, semantic segmentation, or deep learning. The results are usually represented in the form of vector polygons or binary masks and are used in applications such as urban planning, geographic information systems (GIS), and digital twin modeling.

[0066] In the field of building outline extraction, the current industry-standard technical approach is as follows: after obtaining the original building mask (hereinafter referred to as mask) generated by instance segmentation models such as Mask2Former and P2Pformer, a series of post-processing modules are used to achieve orthogonalization and de-masking of the building outline. This process has been widely applied in remote sensing map information element construction scenarios, and includes:

[0067] First, morphological smoothing techniques are employed, combining erosion and dilation operations to effectively remove noise, fill mask holes and breaks while preserving edge structure. Next, contour simplification and geometric regularization are performed. The Douglas-Peucker (DP) algorithm is used to reduce the number of polygon vertices, and based on two detected orthogonal principal directions, line segments with deviation angles less than a preset threshold θ are projected to the nearest principal direction, achieving contour straightening correction. Finally, to address the overlap problem of adjacent building masks, a watershed algorithm based on Euclidean distance transformation is used to generate segmentation boundaries along the minimum distance line in the overlapping area, and the overlapping parts are reasonably allocated according to area proportions, thereby completing the de-covering process and improving the topological accuracy and mapping standardization of the contour.

[0068] However, the existing technology currently has the following problems:

[0069] 1. Parameter dependency leads to automation failure. Existing methods heavily rely on manually preset parameters when orthogonalizing mask contours. When the resolution of the input image changes or there are significant differences in building density, the parameters must be readjusted. If the parameters are set improperly, the same algorithm will exhibit over-normalization or under-normalization on different images, seriously affecting the stability and generalization ability of automated processing.

[0070] 2. Lack of N-ary overlap handling capability: Existing de-overlapping methods typically only support overlap handling between pairs of instances. In complex scenarios such as high-rise building clusters, three or more instances often overlap (e.g., building A overlays building B, building B overlays building C, building A overlays building C). In such cases, watershed-based segmentation is prone to generating invalid topology structures, requiring manual intervention for correction.

[0071] To address the problems in the existing technology, embodiments of this application provide a building outline optimization method, which can:

[0072] Under WGS84 geographic coordinates, the geographiclib library is used to calculate spherical distance and azimuth. A two-stage rotation search (15° coarse search + 3° fine search) is employed to find the center point. The mask is then rotated around its own center point, and the area of ​​the rectangle formed by the current mask and the meridians is calculated. The minimum area bounding rectangle is then determined to avoid distortion errors caused by planar projection. The area ratio (IoU) between the original mask and this rectangle is calculated, and the aspect ratio is used to determine if the building presents a distinct rectangle. If high coverage conditions are met (e.g., IoU > 0.6 and not elongated, short side length / field side length < 1 / 3), the bounding rectangle replacement is directly performed; otherwise, a general polygon orthogonalization process is initiated. This solves the problem of distortion caused by blind regularization.

[0073] Even after orthogonalization, sharp corners or tiny jagged edges may still remain in the contour, failing to meet the requirements for building regularization. Therefore, the following measures were taken: Short edge removal and sharp angle removal functions were called before and after orthogonalization to delete vertices that did not meet the angle threshold (less than 52° or greater than 152°) or had excessively short side lengths (less than 12 pixels); the sensitivity of the judgment was dynamically enhanced based on the combination of side length and angle conditions (such as approaching the critical angle and both sides being short sides); multiple iterations were performed until convergence or the minimum vertex count limit was reached. This solved the problem of sharp corners and short-side noise remaining after regularization.

[0074] A four-level classification decision mechanism based on the overlap ratio is adopted: if IOSM > 0.5, the large mask is considered to almost completely cover the small mask, so the large mask is retained and the small mask is deleted; if 0.5 > IOSM > 0.3, the large and small masks are considered to have moderate overlap, and an attempt is made to merge them and then perform the short side and acute angle removal operation. If this fails, the overlapping area of ​​the small mask is trimmed according to its area; if 0.3 > IOSM > 0.15, the boundary between the large and small masks is considered to be blurred, and erosion and shrinkage separation is performed first. If the shrinkage is too small (either mask is less than 50% of its original area), the merging is reversed; if IOSM < 0.15, the large and small masks have slight overlap, and direct erosion separation is performed. If this fails, the merging is reversed. In addition, the area ratio of the large and small masks is also introduced as a criterion for whether to perform fast erosion to accelerate convergence, in order to solve the problems of complex overlapping relationships and rigid processing strategies.

[0075] A dual quality control mechanism is employed: Geometric rationality check: Before the final output, it checks for sharp corners (less than 20°) or extreme long-to-short side ratios (greater than 2), marking them as low confidence if found; Topological validity check: It checks whether polygons are self-intersecting or unclosed, marking them as low confidence if invalid; IoU check: If the IoU value between the orthogonalized mask and the original mask is too small, it is marked as low confidence. This addresses the issue of uncontrollable contour quality after removing the overlay.

[0076] Figure 1 A schematic diagram of a scenario for the building outline optimization method provided in this application, such as... Figure 1 As shown, the specific application scenario of this application can be a building outline optimization system. This system can be deployed and run in various remote sensing data sources, urban remote sensing images of different resolutions, and diverse software and hardware environments. The typical application scenarios and operating conditions are as follows:

[0077] I. Automatic building extraction and map updating;

[0078] In automatic building extraction on maps, the original masks of buildings in satellite remote sensing images processed by instance segmentation models are quickly converted into standard vector outlines, which greatly reduces the cost of manual digitization and provides high-quality map data.

[0079] II. Generation of GIS building vector data;

[0080] It can be embedded as a post-processing module into the processing flow of instance segmentation models based on Mask2Former, etc. It supports the automatic export of building outlines from model output to standard SHP format in GIS environments such as ArcGIS, SuperMap, and QGIS. The result can effectively avoid edge shapes such as sharp corners and jagged edges that do not meet the requirements.

[0081] Its applicable data input environments include:

[0082] I. Image input resolution range: 0.3 meters;

[0083] II. Applicable Model Output: Mask2Former;

[0084] III. Mask quality tolerance: It can handle low-quality segmentation results with problems such as adhesion, blurred edges, and small holes;

[0085] IV. Practicality of building density: Suitable for both conventional and densely built areas.

[0086] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0087] Figure 2 This application provides a flowchart illustrating a method for optimizing building outlines, as shown below. Figure 2 As shown, the method includes:

[0088] S201. Convert the outline pixel coordinates of the building's initial mask into geographic coordinates.

[0089] The initial mask can refer to the building region segmentation result in remote sensing or aerial images, represented in binary form (e.g., 0 and 1 or 0 and 255). Foreground pixels (e.g., values ​​of 1) mark the parts belonging to buildings, while background pixels (e.g., values ​​of 0) represent non-building areas.

[0090] The outline pixel coordinates of the initial mask can refer to the sequence of building boundary points extracted from the initial mask. These points can be represented by integer positions in the image coordinate system, with the format (x, y), where x is the column index (horizontal) and y is the row index (vertical).

[0091] Geographic coordinates can refer to the latitude and longitude coordinates of a real location on the Earth's surface. In this embodiment, the mapping relationship between contour pixel coordinates and real geographic space can be used to convert each contour pixel coordinate in the initial mask into the latitude and longitude coordinates corresponding to the geographic coordinates. S202, Based on the geographic coordinates, perform a rotation search on the initial mask to determine the minimum bounding rectangle of the initial mask.

[0092] Rotation search can refer to the process of rotating the mask contour gradually within a range of 0° to 180° in a geographic coordinate system, with a point on the initial mask as the origin of rotation. After each rotation, the circumscribed rectangle (i.e., the rectangle whose sides are parallel to the meridians and parallels) is calculated and its area is recorded. By traversing all rotation angles, the direction that minimizes the area of ​​the circumscribed rectangle is found, thus determining the optimal rotation angle.

[0093] The minimum bounding rectangle of the initial mask can be defined as the smallest rectangular area in the geographic coordinate system that completely contains the outline of the building corresponding to the initial mask. This rectangle can be rotated, and its position, size, and orientation are determined by the rotation search process. It can more closely match the actual orientation and shape of the building. Compared with a bounding box with a fixed orientation, it can reduce blank redundancy to determine whether the building is a regular rectangle and to perform outline regularization.

[0094] S203. Determine the building mask of the building based on the minimum bounding rectangle and the initial mask;

[0095] S204. Determine the outline information of the building based on the building mask.

[0096] Among them, through geometric consistency evaluation, the most suitable contour expression form is adaptively selected. That is, after determining the minimum bounding rectangle in the geographic coordinate system, it is compared with the initial mask to extract key geometric parameters, such as intersection-union ratio (IoU), area ratio, aspect ratio, etc., to measure the degree of fit and rationality of the minimum bounding rectangle to the initial mask.

[0097] If the smallest bounding rectangle can represent a building shape that approximates a regular rectangle, then this smallest bounding rectangle can be used as a building mask, and the building outline can be determined based on the building mask, achieving a concise, orthogonal, and geographically accurate representation. If there are deviations (such as IoU not meeting requirements, elongated shape, or complex structure), then it is determined to be a non-standard rectangular building, and the initial mask is transferred to subsequent processing steps (such as polygon simplification or orthogonalization), rather than being forcibly rectangularized. This avoids a one-size-fits-all simplification strategy, ensuring that the outline result conforms to drafting standards while remaining faithful to the actual building shape.

[0098] The building outline optimization method provided in this application can make intelligent decisions by using the minimum bounding rectangle as a reference and combining the geometric characteristics of the initial mask, thereby stably generating high-fidelity and structurally reasonable vector outlines under different building types, image resolutions and scene densities.

[0099] Optionally, based on geographic coordinates, a rotational search is performed on the initial mask to determine the minimum bounding rectangle of the building mask, including:

[0100] Based on geographic coordinates, a rotation search is performed with a first angular step size to determine the minimum bounding rectangle of the initial mask under multiple candidate rotation angles.

[0101] Based on the minimum bounding rectangle under the target rotation angle, within a preset angle range, a rotation search is performed with a second angle step to determine the minimum bounding rectangle of the initial mask; the second angle step is smaller than the first angle step.

[0102] The first angle step size can refer to the angle interval (such as 30° or 15°) used in the initial coarse search phase. It is used to quickly traverse multiple candidate rotation directions within a complete semicircle range from 0° to 180°, and initially locate the approximate angle range that minimizes the area of ​​the circumscribed rectangle, so as to balance computational efficiency and comprehensive coverage.

[0103] The second angle step size can refer to a smaller angle interval (such as 5° or 3°) used in the fine search phase. Its accuracy is higher than that of the first angle step size. It is used to perform high-resolution scanning within the locked local angle range to accurately find the globally optimal minimum bounding rectangle direction, thereby improving geometric fit.

[0104] The preset angle range can refer to a local neighborhood (such as ±7.5° or ±5°) defined around the optimal angle (i.e. the target rotation angle) obtained in the coarse search stage. This serves as the search window for the fine search, avoiding repeated high-cost calculations across the entire angle range while ensuring that better solutions are not overlooked.

[0105] Therefore, a large first angle step is used to quickly coarsely screen within the full angle range (0° to 180°) to determine the approximately optimal direction; then a smaller second angle step is used to finely optimize within a preset angle range near this direction. This ensures computational efficiency while accurately solving for the truly smallest circumscribed rectangle in the geographic coordinate system, providing a reliable geometric benchmark for subsequent contour regularization.

[0106] Optionally, the building mask of the building is determined based on the minimum bounding rectangle and the initial mask, including:

[0107] Determine the intersection-union ratio between the minimum bounding rectangle and the initial mask;

[0108] If the cross-union ratio (CUNR) is greater than the CUNR threshold, the initial mask is used as the building mask for the building. The CUNR threshold is determined based on the aspect ratio of the minimum bounding rectangle and / or the mask area of ​​the minimum bounding rectangle.

[0109] The Intersection over Union (IoU) ratio between the minimum bounding rectangle and the initial mask refers to the ratio of the area of ​​the overlapping region between the minimum bounding rectangle and the initial mask after converting them into a binary mask in a geographic coordinate system, to the area of ​​their union. A closer IoU to 1 indicates that the minimum bounding rectangle accurately represents the building outline.

[0110] The Intersection over Union (IoU) threshold can be considered a dynamic criterion used to determine whether the minimum bounding rectangle can be used as a building mask to replace the initial mask. This threshold is not a fixed value but rather adaptively adjusts based on the aspect ratio of the minimum bounding rectangle (e.g., slender buildings require higher fit) and / or its mask area (e.g., small buildings tolerate lower IoU). In other words, it can be determined based on the aspect ratio of the minimum bounding rectangle, the mask area, or both. For example, large, square buildings may require an IoU > 0.7, while small or slightly irregular buildings may require an IoU > 0.5.

[0111] The mask area can refer to the total number of all foreground pixels (i.e., pixels marked as belonging to buildings) in the initial mask. In a pixel coordinate system, it can be expressed in pixels. It can also be combined with the spatial resolution or georeferenced information of the image, or converted into the actual ground area (e.g., square meters). This area can reflect the coverage scale of buildings on the image or ground.

[0112] Therefore, by calculating the intersection-over-union (IoU) ratio between the minimum bounding rectangle and the initial mask, and combining this with the rectangle's own geometric properties (such as aspect ratio and area), a dynamic judgment threshold is set: if the IoU exceeds the IoU threshold, the rectangle is considered to fit sufficiently and have a reasonable shape, and is directly used as the output of the building mask; otherwise, the original structure is retained. This avoids misjudgments under different building scales and shapes using a uniform threshold, achieving more robust and adaptive contour regularization and display.

[0113] In some embodiments, when the mask area of ​​the minimum bounding rectangle is less than the first pixel value, the cross-union ratio threshold is the first cross-union ratio threshold.

[0114] When the mask area of ​​the minimum bounding rectangle is between the first pixel value and the second pixel value, if the minimum bounding rectangle is elongated, the intersection-union ratio (IU) threshold is the second IU threshold; if the minimum bounding rectangle is not elongated, the IU threshold is the third IU threshold. Wherein, the second pixel value is greater than the first pixel value, and the third IU threshold is greater than the second IU threshold. When the aspect ratio of the minimum bounding rectangle is greater than a preset ratio, it is elongated; otherwise, it is not elongated.

[0115] When the mask area of ​​the minimum bounding rectangle is between the second and third pixel values, if the minimum bounding rectangle is elongated, the cross-union ratio (CUN) threshold is the fourth CUN threshold; if the minimum bounding rectangle is not elongated, the CUN threshold is the fifth CUN threshold; the fifth CUN threshold is greater than the fourth CUN threshold.

[0116] When the mask area of ​​the minimum bounding rectangle is greater than the third pixel value, if the minimum bounding rectangle is a narrow rectangle, the cross-union ratio (CUN) threshold is the sixth CUN threshold; if the minimum bounding rectangle is not a narrow rectangle, the CUN threshold is the seventh CUN threshold; the seventh CUN threshold is greater than the sixth CUN threshold.

[0117] It should be noted that users can divide the mask area of ​​the minimum bounding rectangle into multiple pixel value ranges as needed to set different cross-union thresholds.

[0118] In this embodiment of the application, after determining the intersection-union ratio of the minimum bounding rectangle and the initial mask, the method further includes:

[0119] If the cross-union ratio is less than the cross-union ratio threshold, the contour of the initial mask is filtered to obtain a filtered mask; the filtering process includes acute angle filtering and / or short side filtering.

[0120] The confidence level of the filter mask is determined based on the cross-union ratio between the filter mask and the initial mask.

[0121] The building mask is obtained based on the filter mask and the confidence level of the filter mask.

[0122] Among them, acute angle filtering can refer to checking the vertex angles of the building outline. If the interior angle at a vertex is less than the preset acute angle threshold (such as 52°) or close to a flat angle (such as greater than 152°), then the angle is considered to be geometric noise, jagged edges, or unreasonable structure. The corresponding vertex is then deleted or merged to eliminate sharp protrusions or unnatural angles, making the outline more in line with the orthogonal or smooth characteristics of real buildings.

[0123] Short edge filtering refers to traversing each edge formed by adjacent vertices in the contour. If its length is less than a preset pixel threshold (such as 12 pixels), the edge is determined to be redundant detail or noise. The contour is simplified by removing one of its endpoints. In this way, tiny jagged edges or broken edges caused by image resolution or segmentation errors can be effectively removed.

[0124] A filter mask refers to a binary mask generated by re-rasterizing the optimized polygons after performing geometric simplification operations such as acute angle filtering and / or short side filtering on the outline of the initial mask. It represents a building area that has been structurally cleaned and simplified, preserving the main shape while removing unreasonable or redundant geometric details.

[0125] In this embodiment, the fidelity is quantified by calculating the cross-union ratio (IoU) between the filtered mask and the initial mask: if the IoU is high (e.g., >0.85), it indicates that the filtering has not significantly changed the main structure of the building, the result is credible, and a high confidence level is assigned; if the IoU is low, it may be oversimplified or distorted, and the confidence level is reduced accordingly.

[0126] This results in the output building outline not only including the polygonal boundaries optimized by geometric filtering, but also including their confidence score; this confidence score can be used for subsequent decision-making, thereby enabling automated outline generation with controllable quality and traceable results.

[0127] Optionally, the building mask of the building is determined based on the minimum bounding rectangle and the initial mask, including:

[0128] Determine the number of buildings within the target area;

[0129] When the number of buildings exceeds the first preset number, traverse the target area and determine the first and second buildings within the target area; the first and second buildings are two different buildings within the target area.

[0130] Based on the intersection ratio between the first building mask and the second building mask, an instance optimization operation is performed on the first building and the second building to determine the optimized building and the building mask of the building; the first building mask is the building mask of the first building, and the second building mask is the building mask of the second building; the intersection ratio represents the coverage ratio of the smaller mask area in the first building mask and the second building mask.

[0131] The target area can refer to the geographical area in the remote sensing image that actually contains effective object information and can be used for subsequent analysis and processing. It can exclude invalid filling, black borders, cloud occlusion, or areas without data at the image edges. In this embodiment, the area can be the effective imaging area with real ground observation content covered by the sliding window traversal in the remote sensing image.

[0132] In areas with fewer buildings, individual buildings, with their clear boundaries and sufficient spacing, can be accurately represented by independent masks using conventional segmentation methods. However, in high-density areas, buildings may overlap or break in their initial masks due to mutual occlusion and contour adhesion. By introducing a first preset number as a trigger condition, instance optimization operations based on the intersection ratio can be activated only when necessary (i.e., in high-density scenes), avoiding redundant calculations for simple scenes.

[0133] Intersection over Smaller Mask (IOSM) refers to the ratio of the area of ​​the intersection region between two building masks (such as a first building mask and a second building mask) to the area of ​​the smaller of the two. It is used to quantify the degree to which the smaller mask is covered by the larger mask. The higher the index (maximum 1), the more the smaller building mask is contained by the other building mask.

[0134] After determining the intersection ratio, it is possible to determine whether the first building and the second building overlap, and based on the different overlap situations, to determine the corresponding overlay situation, so as to optimize the operation of the first building and the second building.

[0135] In some embodiments, after determining the overlap ratio, the degree of overlap and overlay relationship between the first building and the second building can be judged based on its value: if the overlap ratio is higher than a set overlap ratio threshold, it indicates that a large part of the smaller building mask is covered by the other mask, and there is obvious one-way overlay. In this case, it can be determined as duplicate detection or missegmentation, and then the operation of deleting the smaller mask or merging it into the larger mask can be performed; if the overlap ratio is lower than another set overlap ratio threshold, it may be adjacent contact or slight adhesion. It is possible to retain both or perform boundary erosion treatment to remove adhesion; if the overlap ratio is zero, there is no overlap and no processing is required.

[0136] Therefore, by analyzing the overlapping relationship based on the intersection ratio, targeted optimization operations such as merging, deletion, or morphological correction can be implemented to generate more accurate and non-redundant architectural instance results.

[0137] In this embodiment of the application, after determining the number of buildings within the target area, the method further includes:

[0138] When the number of buildings is greater than the second preset number, adjust the size of the target area until the number of buildings in the target area is less than or equal to the second preset number. Then, traverse the target area and determine the first and second buildings in the target area. The second preset number is greater than the first preset number.

[0139] When the number of buildings in the target area exceeds the second preset number, it indicates that the building density in the area is too high, which may lead to severe overlap of building masks, blurred boundaries, or overload of computing resources, directly affecting the accuracy and efficiency of subsequent instance optimization. Therefore, it is necessary to dynamically reduce the scope of the target area and gradually reduce the processing complexity until the number of buildings in the area drops to within the second preset number, ensuring that subsequent traversal, pairing, and instance optimization operations based on the intersection ratio can be performed under reasonable load and reliable accuracy, thereby ensuring the quality of the overall segmentation results and the stability of the algorithm.

[0140] There are several ways to narrow down the target region. For example, when the number of building instances detected within a sliding window exceeds a threshold (e.g., >40) and the window size is 1024×1024, it can be automatically recursively decomposed into four 512×512 sub-windows to improve the resolution accuracy and processing efficiency of high-density areas. In addition, morphological erosion can be used to shrink the mask boundary, low-confidence areas can be clipped based on the segmentation confidence map, a conservative core region can be generated by proportionally shrinking within the minimum bounding rectangle, or only the main connected components can be retained for target regions containing multiple fragments to remove noise.

[0141] In this embodiment of the application, based on the crossover ratio between the first building mask and the second building mask, an instance optimization operation is performed on the first building and the second building to determine the instance-optimized building and the building mask of the building, including:

[0142] If the cross ratio is greater than the first threshold, then the mask of the building with the smaller mask area in the first building and the second building is deleted, and the deleted building and the building mask of the building are determined.

[0143] If the intersection ratio is less than the first threshold and greater than the second threshold, or if the intersection ratio is less than the second threshold and the mask overlap area is greater than the preset overlap area, then the first building mask and the second building mask are merged to obtain a merged mask.

[0144] Based on the filter-merged mask and its confidence level, the building and its building mask are determined; the filter-merged mask is obtained by filtering the merged mask, and the confidence level of the filter-merged mask is determined based on the cross-union ratio of the merged mask and the filter-merged mask.

[0145] If the cross ratio is less than the second threshold and the mask overlap area is less than the preset overlap area, then the first building mask and the second building mask are etched to obtain the first etched mask and the second etched mask.

[0146] Based on the first corrosion mask and the first building mask, as well as the second corrosion mask and the second building mask, the first corrosion mask and the second corrosion mask are merged or deleted to determine the processed building and the building mask of the building.

[0147] If the crossover ratio is greater than the first threshold (e.g., 0.5), it indicates that a large portion of the smaller building mask is covered by the other, indicating significant redundancy or duplicate detection. In this case, the system will delete the building with the smaller mask area, retaining only the larger building as a valid instance, thereby determining the deleted building and using its corresponding mask as the building mask to eliminate duplication and improve the uniqueness and accuracy of the building extraction results.

[0148] If the intersection ratio is between the first and second thresholds (e.g., 0.3 < intersection ratio ≤ 0.5), it indicates that the two buildings overlap and may belong to multiple fragments of the same building caused by segmentation. Alternatively, even if the intersection ratio is lower than the second threshold, their absolute overlap area still exceeds the preset pixel or geographic area threshold, indicating that the two buildings do indeed intersect spatially and are not accidental neighbors. In both cases, the system will perform a merging process (e.g., union or connected component fusion) on the first and second building masks to generate a unified merged mask, thereby repairing the breakage, eliminating fragmentation, and ensuring the integrity and topological consistency of the building instances.

[0149] Simultaneously, geometric filtering (such as removing acute angles and short sides) can be applied to the merged mask to obtain a filtered merged mask. The confidence level is then calculated based on the cross-union ratio (CUI) between the filtered merged mask and the merged mask. This confidence level reflects the fidelity of the filtered merged mask to the merged mask. Therefore, by combining this confidence level, it can be determined whether to adopt the result as the building and its building mask, thus ensuring both structural integrity and geometric rationality and result reliability.

[0150] When the overlap ratio is lower than the second threshold and the overlap area of ​​the two masks is also less than the preset overlap area, it indicates that the two buildings have only a weak or no substantial overlap, which may be due to false contact caused by blurred boundaries, segmentation burrs, or slight adhesion. At this time, the first building mask and the second building mask can be etched to generate the first etched mask and the second etched mask, so as to shrink the boundary and eliminate edge interference. Then, by comparing the changes of each mask before and after etching (such as whether they still overlap after etching and whether the area loss is too large), it is determined whether the two should be further merged (if they are still adjacent and semantically consistent after etching) or one should be retained / deleted independently (if they are completely separated after etching or one of them is severely degraded). Thus, based on this judgment, the processed building and its building mask can be determined, and while removing noise adhesion, unrelated building instances can be avoided from being mistakenly merged.

[0151] In this embodiment of the application, when determining the threshold, the case that is equal to the threshold can be classified into the processing branch of less than the threshold or greater than the threshold, depending on actual needs.

[0152] Therefore, by using a multi-level intersection ratio and overlapping area joint criterion, combined with adaptive operations such as erosion, merging, and deletion, the system effectively distinguishes between real overlap, fragmented breaks, and edge adhesion noise between building instances. While preserving the integrity of independent buildings, it accurately handles the problems of repeated detection and boundary ambiguity.

[0153] Optionally, based on the building mask, the outline information of the building is determined, including:

[0154] Extract the main outline of the building based on the building mask;

[0155] The main outline of the building is filtered to obtain the filtered main outline.

[0156] After the confidence level of the filtered main outline meets the preset confidence level requirements, the base outline and roof projection outline of the building are generated; the confidence level of the filtered main outline is obtained after performing legality and / or rationality checks on the filtered main outline.

[0157] The coordinates of the building's base outline and roof projection outline are transformed to obtain and display the building's outline information.

[0158] The process involves filtering the main outline of the building to remove noise, debris, or irregular edges, resulting in a cleaner and more structurally complete filtered main outline. This filtered main outline is then subjected to validity (e.g., geometric closure, area rationality) and / or rationality (e.g., shape conforming to architectural priors, consistency with remote sensing imagery) checks, and its confidence level is calculated. Only when the confidence level reaches a preset threshold are the building's base outline (footprint) and roof projection outline further generated. Finally, these two outlines are transformed from the image coordinate system to the geographic coordinate system or other unified spatial reference system, completing coordinate alignment and standardization, and outputting the building outline information.

[0159] The building mask is stored using a sparse matrix storage structure. During maximum contour extraction, the sparse matrix can be transformed into a locally dense array to extract the main contour. This saves memory space, improves computational efficiency, and enhances the efficiency of processing large batches of tasks.

[0160] Figure 3 A flowchart illustrating another building outline optimization method provided in this application is shown below. Figure 3 As shown, the method includes:

[0161] 1. Load input data and geographic reference information;

[0162] First, read the JSON result file generated by the Mask2Former model, which contains the roof pixel coordinates, height offset information, and path of the original TIF image for multiple building instances.

[0163] The affine transformation parameters of the TIF file are read using the GDAL library to obtain its location information in the geographic coordinate system. This information will be used for all subsequent geographic coordinate transformations and minimum bounding rectangle calculations.

[0164] 2. Perform parallel processing of building outline right angle conversion;

[0165] Initiate multi-process processing and perform normalization independently on each building mask:

[0166] 1) Construct a binary mask: Convert the input contour points into a binary image of size 8704×8704;

[0167] 2) Find and simplify the main contour: Extract the largest connected region and perform initial simplification to reduce the number of contour points in the original mask;

[0168] 3) Geographic coordinate transformation: Convert the outline points from pixel coordinates to WGS84 latitude and longitude coordinates;

[0169] 4) Solving for the minimum area circumscribed rectangle using a two-stage rotation search:

[0170] a. Rotate the original mask around the center point of the original mask in a step of 15° within the range of 0° to 180°. Using the property that the meridians and parallels are perpendicular, find the minimum area enclosed by the meridians and parallels of the rotated mask. By comparing these areas, find the rotation angle that minimizes the area of ​​the bounding box.

[0171] b. Within the optimal angle range of ±15°, perform a fine search with a step size of 3°, repeat the above rotation operation, further optimize the results, and obtain a more precise rotation angle;

[0172] c. Rotate the minimum bounding box rectangle around the center point of the original mask and the rotation angle obtained above. The resulting bounding box is the desired circumscribed rectangle.

[0173] Since all calculations are performed on geographic coordinates rather than pixel coordinates, planar projection errors are avoided.

[0174] 5) Conditional decision on whether to use rectangular replacement:

[0175] Calculate the IoU value between the original mask and the bounding rectangle obtained in step 4 above, and set dynamic thresholds based on the area and rectangle shape (an aspect ratio greater than 3 indicates a long and narrow rectangle). Specifically, for rectangles with an area less than 2400 pixels, IoU > 0.5; for rectangles with an area between 2400 and 10000 pixels, IoU > 0.56 is required for a long and narrow rectangle, and IoU > 0.62 is required for a non-long and narrow rectangle; for rectangles with an area between 10000 and 20000 pixels, IoU > 0.6 is required for a long and narrow rectangle, and IoU > 0.65 is required for a non-long and narrow rectangle; for rectangles with an area between 20000 and 56000 pixels, IoU > 0.62 is required for a long and narrow rectangle, and IoU > 0.67 is required for a non-long and narrow rectangle; for rectangles with an area greater than 56000 pixels, IoU > 0.68 is required for a long and narrow rectangle, and IoU > 0.72 is required for a non-long and narrow rectangle.

[0176] If the IOU value between the solution rectangle and the original mask is calculated, and the corresponding conditions are met, then the rectangle is directly used as the final outline; otherwise, the building is considered not to be a standard rectangular building and enters the general orthogonalization process.

[0177] 6) Multi-round acute angle and short-side filtering: Short-side and acute-angle removal operations are performed multiple times before and after orthogonalization. For each edge (the edge formed by the current point and the next point), its length is checked to see if it is less than 12 pixels. If it meets the requirement, the next point is deleted. This process is repeated until no more vertices are deleted. For each acute-angle removal operation, its angle is checked to see if it is less than 52° or greater than 152°. If it meets the condition, it is removed. This process is repeated until no more vertices are deleted. Multiple rounds of this iterative operation ensure that the final image converges to a perfect rectangle.

[0178] 7) Fidelity verification and confidence assignment: Calculate the IoU between the normalized contour and the original mask, and assign confidence to the normalized shape based on the IoU value and the number of polygon points;

[0179] 3. Resolving local conflicts in layered sliding windows;

[0180] Set the sliding window size to 1024×1024 and the step size to 512, covering the effective area of ​​the remote sensing image. For each window position:

[0181] 1) Scan all building instances and filter out the set of indices whose masks have non-zero pixels within the current window;

[0182] 2) If the number of instances is ≥2, proceed to the capping detection process;

[0183] 3) Special mechanism processing: When the number of instances of a window is greater than 40 and the window size is 1024, it is automatically decomposed into four 512×512 sub-windows for recursive processing, which improves the parsing accuracy and processing speed of high-density areas.

[0184] 4. Multi-level criterion-driven overprinting elimination strategy;

[0185] Within each window, traverse all pairwise combinations of building instances, calculate the ratio of the intersection to the smaller area (IOSM), and execute the following four-level decision logic:

[0186] 1) IOSM > 0.5: Almost completely covered, delete the smaller mask;

[0187] 2) 0.3 < IOSM ≤ 0.5: Perform operations to remove acute angles and short sides on the merged image, then perform a judgment on the rationality of the polygon contour. If all rationality conditions are met and no None is returned when removing short sides and acute angles, save the synthesized mask. Otherwise, if any one of the conditions fails, roll back and delete the smaller mask;

[0188] 3) 0.15 < IOSM ≤ 0.3: Introduce the overlapping area as a new judgment condition. If the overlapping area is less than 1000 pixel values, perform erosion operations on the two masks. After erosion, judge whether the area of any one of the two masks is less than 50% of the original. If one is less, roll back and perform the merge operation. If the merge operation has problems as in 2), delete the smaller mask. If the overlapping area is greater than 1000 pixel values, consider performing the merge operation. If the merge has problems as in 2), perform the operation of deleting the smaller mask;

[0189] 4) 0 < IOSM ≤ 0.15: Perform erosion operations, and the erosion process judgment is the same as in 3).

[0190] 5. Final contour extraction and quality control;

[0191] After completing the processing of all windows, traverse the remaining mask instances that have not been deleted and execute:

[0192] 1) Extract the maximum contour: Convert the sparse matrix into a locally dense array and extract the main contour;

[0193] 2) Douglas-Peucker simplification: Remove redundant vertices;

[0194] 3) Dual detection of legality and rationality: Check whether there are sharp corners or extreme ratios of long to short sides; verify whether the polygon is self-intersecting; if any one fails, give a low confidence to the processed graph;

[0195] 4) Double-layer contour restoration: Generate the building base contour; Combine the height offset parameter to restore the roof projection contour;

[0196] 5) Coordinate system conversion and output: Convert WGS84 coordinates to GCJ-02 coordinates; Export SHP files and JSON files (including attributes such as roof contours, bottom contours, and building heights).

[0197] Figure 3aThis is a comparative illustration of the rectangular replacement of the building provided in this application; such as... Figure 3a As shown, replacing the building outline with the minimum bounding rectangle significantly enhances the geometric regularity of the building outline.

[0198] Figure 3b This application provides a comparative schematic diagram of the non-rectangular orthogonalization of buildings; such as... Figure 3b As shown, through non-matrix orthogonalization processing, the boundary of the building outline is made close to right angle and without jagged edges.

[0199] Figure 3c A comparative diagram illustrating the example optimization processing of buildings provided in this application; Figure 3c The number 1 in the diagram is a comparison of the building before and after corrosion separation. Figure 3c The number 2 in the diagram is a comparison of the building before and after deletion; Figure 3c The number 3 in the diagram is a comparison of the buildings before and after the merger. For example... Figure 3c As shown, the building outline optimization method provided in this application significantly enhances the geometric regularity of the building outline, with most boundaries approaching right angles and without jagged edges; and the spatial overlapping relationship between building instances is effectively eliminated, resulting in a clear topological structure without overlap or breakage.

[0200] Figure 4 A structural schematic diagram of the building outline optimization device provided in this application is shown below. Figure 4 As shown, the building outline optimization device 40 provided in this embodiment includes:

[0201] The conversion module 401 is used to convert the outline pixel coordinates of the initial mask of the building into geographic coordinates.

[0202] The search module 402 is used to perform a rotational search on the initial mask based on geographic coordinates to determine the minimum bounding rectangle of the initial mask.

[0203] The first determining module 403 is used to determine the building mask of the building based on the minimum bounding rectangle and the initial mask.

[0204] The second determining module 404 is used to determine the outline information of the building based on the building mask of the building.

[0205] In one possible implementation, the search module 402 can also be specifically used for:

[0206] Based on geographic coordinates, a rotation search is performed with a first angular step size to determine the minimum bounding rectangle of the initial mask under multiple candidate rotation angles.

[0207] Based on the minimum bounding rectangle under the target rotation angle, within a preset angle range, a rotation search is performed with a second angle step to determine the minimum bounding rectangle of the initial mask; the second angle step is smaller than the first angle step.

[0208] In one possible implementation, the first determining module 403 can also be specifically used for:

[0209] Determine the intersection-union ratio between the minimum bounding rectangle and the initial mask;

[0210] If the cross-union ratio (CUNR) is greater than the CUNR threshold, the initial mask is used as the building mask for the building. The CUNR threshold is determined based on the aspect ratio of the minimum bounding rectangle and / or the mask area of ​​the minimum bounding rectangle.

[0211] In one possible implementation, the first determining module 403 can also be specifically used for:

[0212] If the cross-union ratio is less than the cross-union ratio threshold, the contour of the initial mask is filtered to obtain a filtered mask; the filtering process includes acute angle filtering and / or short side filtering.

[0213] The confidence level of the filter mask is determined based on the cross-union ratio between the filter mask and the initial mask.

[0214] The building mask is obtained based on the filter mask and the confidence level of the filter mask.

[0215] In one possible implementation, the first determining module 403 can also be specifically used for:

[0216] Determine the number of buildings within the target area;

[0217] When the number of buildings exceeds the first preset number, traverse the target area and determine the first and second buildings within the target area; the first and second buildings are two different buildings within the target area.

[0218] Based on the intersection ratio between the first building mask and the second building mask, an instance optimization operation is performed on the first building and the second building to determine the optimized building and the building mask of the building; the first building mask is the building mask of the first building, and the second building mask is the building mask of the second building; the intersection ratio represents the coverage ratio of the smaller mask area in the first building mask and the second building mask.

[0219] In one possible implementation, the first determining module 403 can also be specifically used for:

[0220] When the number of buildings is greater than the second preset number, adjust the size of the target area until the number of buildings in the target area is less than or equal to the second preset number. Then, traverse the target area and determine the first and second buildings in the target area. The second preset number is greater than the first preset number.

[0221] In one possible implementation, the first determining module 403 can also be specifically used for:

[0222] If the cross ratio is greater than the first threshold, then the mask of the building with the smaller mask area in the first building and the second building is deleted, and the deleted building and the building mask of the building are determined.

[0223] If the intersection ratio is less than the first threshold and greater than the second threshold, or if the intersection ratio is less than the second threshold and the mask overlap area is greater than the preset overlap area, then the first building mask and the second building mask are merged to obtain a merged mask.

[0224] Based on the filter-merged mask and its confidence level, the building and its building mask are determined; the filter-merged mask is obtained by filtering the merged mask, and the confidence level of the filter-merged mask is determined based on the cross-union ratio of the merged mask and the filter-merged mask.

[0225] If the cross ratio is less than the second threshold and the mask overlap area is less than the preset overlap area, then the first building mask and the second building mask are etched to obtain the first etched mask and the second etched mask.

[0226] Based on the first corrosion mask and the first building mask, as well as the second corrosion mask and the second building mask, the first corrosion mask and the second corrosion mask are merged or deleted to determine the processed building and the building mask of the building.

[0227] In one possible implementation, the second determining module 404 can also be specifically used for:

[0228] Extract the main outline of the building based on the building mask;

[0229] The main outline of the building is filtered to obtain the filtered main outline.

[0230] After the confidence level of the filtered main outline meets the preset confidence level requirements, the base outline and roof projection outline of the building are generated; the confidence level of the filtered main outline is obtained after performing legality and / or rationality checks on the filtered main outline.

[0231] The coordinates of the building's base outline and roof projection outline are transformed to obtain and display the building's outline information.

[0232] In one possible implementation, the second determining module 404 can also be specifically used for:

[0233] The building mask is stored using a sparse matrix storage structure.

[0234] The building outline optimization device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0235] Figure 5 A schematic diagram of the structure of the electronic device provided in this application. Figure 5 As shown, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the device 50 further includes a communication component 503. The processor 501, memory 502, and communication component 503 are connected via a bus 504.

[0236] In a specific implementation, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to perform the above-described method.

[0237] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0238] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0239] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0240] 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. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0241] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0242] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0243] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage 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 readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0244] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0245] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0246] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0247] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0248] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0249] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to 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; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0250] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A method for optimizing building outlines, characterized in that, include: Convert the outline pixel coordinates of the building's initial mask to geographic coordinates; Based on geographic coordinates, the initial mask is rotated and searched to determine the minimum bounding rectangle of the initial mask; The building mask of the building is determined based on the minimum bounding rectangle and the initial mask; The outline information of the building is determined based on the building mask.

2. The method according to claim 1, characterized in that, The step of performing a rotational search on the initial mask based on geographic coordinates to determine the minimum bounding rectangle of the building mask includes: Based on geographic coordinates, a rotation search is performed with a first angular step size to determine the minimum bounding rectangle of the initial mask under multiple candidate rotation angles; Based on the minimum bounding rectangle under the target rotation angle, within a preset angle range, a rotation search is performed with a second angle step to determine the minimum bounding rectangle of the initial mask; the second angle step is smaller than the first angle step.

3. The method according to claim 1, characterized in that, The step of determining the building mask of the building based on the minimum bounding rectangle and the initial mask includes: Determine the intersection-union ratio between the minimum bounding rectangle and the initial mask; If the cross-union ratio is greater than the cross-union ratio threshold, then the initial mask is used as the building mask of the building; the cross-union ratio threshold is determined based on the aspect ratio of the minimum bounding rectangle and / or the mask area of ​​the minimum bounding rectangle.

4. The method according to claim 3, characterized in that, After determining the intersection-union ratio (IU) of the minimum bounding rectangle and the initial mask, the method further includes: If the cross-union ratio is less than the cross-union ratio threshold, the contour of the initial mask is filtered to obtain a filtered mask; the filtering process includes acute angle filtering and / or short side filtering. The confidence level of the filter mask is determined based on the cross-union ratio between the filter mask and the initial mask. The building mask of the building is obtained based on the filter mask and the confidence level of the filter mask.

5. The method according to claim 1, characterized in that, The step of determining the building mask of the building based on the minimum bounding rectangle and the initial mask includes: Determine the number of buildings within the target area; When the number of buildings exceeds a first preset number, the target area is traversed to determine the first building and the second building within the target area; the first building and the second building are two different buildings within the target area. Based on the intersection ratio between the first building mask and the second building mask, an instance optimization operation is performed on the first building and the second building to determine the instance-optimized building and the building mask of the building; the first building mask is the building mask of the first building, and the second building mask is the building mask of the second building; the intersection ratio represents the coverage ratio of the smaller mask area in the first building mask and the second building mask.

6. The method according to claim 5, characterized in that, After determining the number of buildings within the target area, the method further includes: When the number of buildings is greater than the second preset number, the size of the target area is adjusted until the number of buildings in the target area is less than or equal to the second preset number. Then, the step of traversing the target area and determining the first and second buildings in the target area is performed; the second preset number is greater than the first preset number.

7. The method according to claim 5, characterized in that, The step of performing instance optimization operations on the first building and the second building based on the crossover ratio between the first building mask and the second building mask, and determining the instance-optimized building and the building mask of the building, includes: If the crossover ratio is greater than the first threshold, then the mask of the building with the smaller mask area in the first building and the second building is removed, and the removed building and the building mask of the building are determined. If the intersection ratio is less than the first threshold and greater than the second threshold, or if the intersection ratio is less than the second threshold and the mask overlap area is greater than the preset overlap area, then the first building mask and the second building mask are merged to obtain a merged mask. Based on the filter merging mask and the confidence level of the filter merging mask, a building and a building mask for the building are determined; the filter merging mask is obtained by filtering the merged mask, and the confidence level of the filter merging mask is determined based on the cross-union ratio of the merged mask and the filter merging mask. If the cross ratio is less than the second threshold and the mask overlap area is less than the preset overlap area, then the first building mask and the second building mask are etched to obtain a first etched mask and a second etched mask. Based on the first corrosion mask and the first building mask, as well as the second corrosion mask and the second building mask, the first corrosion mask and the second corrosion mask are merged or deleted to determine the processed building and the building mask of the building.

8. The method according to any one of claims 1 to 7, characterized in that, Determining the outline information of the building based on the building mask includes: Extract the main outline of the building based on the building mask; The main outline of the building is filtered to obtain the filtered main outline. After the confidence level of the filtered main outline meets the preset confidence level requirements, the base outline and roof projection outline of the building are generated; the confidence level of the filtered main outline is obtained after performing a legality check and / or a reasonableness check on the filtered main outline; The base outline and roof projection outline of the building are transformed by coordinates to obtain and display the outline information of the building.

9. The method according to claim 7, characterized in that, The building mask is stored using a sparse matrix storage structure.

10. A building outline optimization device, characterized in that, include: The conversion module is used to convert the outline pixel coordinates of the initial mask of a building into geographic coordinates; The search module is used to perform a rotational search on the initial mask based on geographic coordinates to determine the minimum bounding rectangle of the initial mask; The first determining module is used to determine the building mask of the building based on the minimum bounding rectangle and the initial mask; The second determining module is used to determine the outline information of the building based on the building mask of the building.

11. An electronic device / computer-readable storage medium / computer program product, characterized in that, The electronic device includes: a memory and a processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-9; The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-9; The computer program product includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-9.