Graph correction method and device, electronic equipment and storage medium

By obtaining the minimum bounding rectangle and concave rectangle of satellite images, the problem of inaccurate image recognition in satellite image recognition models is solved, the regularization correction of images is realized, and the recognition accuracy is improved.

CN115393200BActive Publication Date: 2026-01-02BEIJING SANKUAI ONLINE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110564734.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-24
Publication Date
2026-01-02
Estimated Expiration
2041-05-24

AI Technical Summary

Technical Problem

Existing satellite image recognition models have low accuracy in recognizing images, especially irregular images containing concave parts, leading to inaccurate recognition results.

Method used

By obtaining the minimum bounding rectangle of the graphic to be processed, the concave rectangles corresponding to the concave parts are identified and removed. The graphic is then corrected using the minimum bounding rectangle and the concave rectangle to form a more regular graphic.

Benefits of technology

It improves the accuracy of image recognition, making the images recognized by the recognition model more regular and making up for the shortcomings of the recognition model. In particular, the correction effect on images containing concave parts is significant.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115393200B_ABST
    Figure CN115393200B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a graphics correction method and device, electronic equipment and storage medium. The graphics correction method comprises: obtaining a minimum circumscribed rectangle of a to-be-processed graphics; identifying a concave rectangle corresponding to a concave part included in the to-be-processed graphics based on the to-be-processed graphics and the minimum circumscribed rectangle; and eliminating the concave rectangle from the minimum circumscribed rectangle, taking the obtained graphics as a corrected graphics corresponding to the to-be-processed graphics. In the embodiments of the present application, the to-be-processed graphics can be corrected to a more regular graphics by correcting the to-be-processed graphics based on the minimum circumscribed rectangle of the to-be-processed graphics and the concave rectangle corresponding to the concave part, so as to make up for the defect that the graphics identified by the identification model is not accurate.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a graph correction method and device, electronic equipment and storage medium. BACKGROUND

[0002] Satellite map, also known as satellite remote sensing image or satellite image, as the name implies, is an image that uses satellite as a medium to feed back the real appearance of the earth's surface to users. Unlike traditional maps, the appearance of the earth's surface seen on the satellite map is real and real-time, so the use of satellite maps is very wide. For example, it can be used to detect ground information, detect geographical position and terrain, and can also be applied to urban and rural planning, navigation systems, military command deployment, disaster monitoring and disaster relief deployment, etc.

[0003] In order to analyze a part of the satellite map, an identification model can be used to identify the image of the part of the satellite map, so as to obtain the corresponding graph of the part. However, the graph identified by the identification model is irregular, so the accuracy of the identification is low. SUMMARY

[0004] In view of the above problems, the embodiments of the present application propose a graph correction method, device, electronic equipment and storage medium to overcome the above problems or at least partially solve the above problems.

[0005] In a first aspect, the embodiments of the present application disclose a graph correction method, comprising:

[0006] obtaining the minimum circumscribed rectangle of the to-be-processed graph;

[0007] based on the to-be-processed graph and the minimum circumscribed rectangle, identifying the inner recessed rectangle corresponding to the inner recessed part contained in the to-be-processed graph;

[0008] eliminating the inner recessed rectangle from the minimum circumscribed rectangle, and taking the obtained graph as the corrected graph corresponding to the to-be-processed graph.

[0009] Optionally, the method further comprises: for each first pixel on each edge of the minimum circumscribed rectangle, calculating the inner recessed depth corresponding to the current first pixel on the current edge according to the second pixel on the to-be-processed graph; based on the inner recessed depth, aggregating the first pixels belonging to the same inner recessed part into a first pixel set; for each first pixel set, determining the inner recessed rectangle corresponding to the inner recessed part to which the current first pixel set belongs according to the first pixel in the current first pixel set and the inner recessed depth corresponding to the first pixel in the current first pixel set.

[0010] Optionally, the calculating, according to the second pixel on the to-be-processed graph, the inner recess depth corresponding to the current first pixel on the current edge comprises: obtaining, as a current second pixel, a second pixel in the to-be-processed graph that is located on a straight line perpendicular to the current edge and closest to the current first pixel; and obtaining, as the inner recess depth corresponding to the current first pixel, a distance between the current first pixel and the current second pixel.

[0011] Optionally, the aggregating, based on the inner recess depth, the first pixels belonging to the same inner recess part into a first pixel set comprises: selecting, as an inner recess start pixel, a first pixel that is located after a first pixel with an inner recess depth less than or equal to a preset threshold and has a first inner recess depth greater than the preset threshold; selecting, as an inner recess end pixel corresponding to the inner recess start pixel, a last first pixel that is located after the inner recess start pixel and has an inner recess depth less than or equal to the preset threshold; and taking, as a first pixel set, the first pixels between an inner recess start pixel and an inner recess end pixel corresponding to the inner recess start pixel.

[0012] Optionally, the determining, according to the first pixel in the current first pixel set and the inner recess depth corresponding to the first pixel in the current first pixel set, an inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs comprises: taking, as a length of the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs, the pixels between the inner recess start pixel in the current first pixel set and the inner recess end pixel in the current first pixel set; and taking, as a width of the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs, an average of the minimum inner recess depth and the maximum inner recess depth corresponding to the first pixel in the current first pixel set.

[0013] Optionally, after obtaining the minimum circumscribed rectangle of the to-be-processed graph, the method further comprises: obtaining an included angle between the minimum circumscribed rectangle and a horizontal direction, and rotating the to-be-processed graph and the minimum circumscribed rectangle both clockwise by the included angle; and identifying, based on the to-be-processed graph and the minimum circumscribed rectangle, the inner recess rectangle corresponding to the inner recess part contained in the to-be-processed graph comprises: identifying, based on the to-be-processed graph rotated clockwise and the minimum circumscribed rectangle rotated clockwise, the inner recess rectangle corresponding to the inner recess part contained in the to-be-processed graph rotated clockwise; and eliminating the inner recess rectangle from the minimum circumscribed rectangle, and taking the obtained graph as the modified graph corresponding to the to-be-processed graph comprises: eliminating the inner recess rectangle rotated clockwise from the minimum circumscribed rectangle rotated clockwise, and rotating the obtained graph counterclockwise by the included angle, and taking the obtained graph as the modified graph corresponding to the to-be-processed graph.

[0014] Optionally, after the included angle is counterclockwise rotated, the method further comprises: obtaining a first center point position of the minimum circumscribed rectangle and a second center point position of the graph after the counterclockwise rotation; and moving the graph after the counterclockwise rotation until the second center point position coincides with the first center point position.

[0015] Optionally, the to-be-processed graph is a roof graph obtained by identifying a roof part in a satellite image by using a preset roof identification model.

[0016] In a second aspect, an embodiment of the present application discloses a graph correction device, comprising:

[0017] The obtaining module is configured to obtain a minimum circumscribed rectangle of the to-be-processed graph.

[0018] The identifying module is configured to identify, based on the to-be-processed graph and the minimum circumscribed rectangle, an inner recessed rectangle corresponding to an inner recessed part contained in the to-be-processed graph.

[0019] The correction module is configured to eliminate the inner recessed rectangle from the minimum circumscribed rectangle, and take a graph obtained as a corrected graph corresponding to the to-be-processed graph.

[0020] Optionally, the identifying module comprises: a calculating unit configured to, for each first pixel on each edge of the minimum circumscribed rectangle, calculate, according to a second pixel on the to-be-processed graph, an inner recessed depth corresponding to the current first pixel on the current edge; an aggregating unit configured to, based on the inner recessed depth, aggregate first pixels belonging to a same inner recessed part into a first pixel set; and a determining unit configured to, for each first pixel set, determine, according to a first pixel in the current first pixel set and the inner recessed depth corresponding to the first pixel in the current first pixel set, an inner recessed rectangle corresponding to the inner recessed part to which the current first pixel set belongs.

[0021] Optionally, the calculating unit comprises: a pixel obtaining subunit configured to obtain, as a current second pixel, a second pixel in the to-be-processed graph that is located on a straight line perpendicular to the current edge and closest to the current first pixel; and a depth obtaining subunit configured to obtain, as the inner recessed depth corresponding to the current first pixel, a distance between the current first pixel and the current second pixel.

[0022] Optionally, the aggregating unit comprises: a pixel selecting subunit, configured to select, as an inner recess starting pixel, a first pixel located after a first pixel with an inner recess depth less than or equal to a preset threshold and having a first inner recess depth greater than the preset threshold; and select, as an inner recess ending pixel corresponding to the inner recess starting pixel, a last first pixel located after the inner recess starting pixel and before a first pixel with an inner recess depth less than or equal to the preset threshold and having a last inner recess depth greater than the preset threshold; and a pixel aggregating subunit, configured to aggregate, as a first pixel set, the first pixels from the inner recess starting pixel to the inner recess ending pixel corresponding to the inner recess starting pixel.

[0023] Optionally, the determining unit comprises: a first determining subunit, configured to determine, as a length of an inner recess rectangle corresponding to an inner recess part to which the current first pixel set belongs, a pixel from an inner recess starting pixel in the current first pixel set to an inner recess ending pixel in the current first pixel set; and a second determining subunit, configured to determine, as a width of the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs, an average of a minimum inner recess depth and a maximum inner recess depth corresponding to the first pixels in the current first pixel set.

[0024] Optionally, the apparatus further comprises: a rotating module, configured to obtain an included angle between the minimum circumscribed rectangle and a horizontal direction, and rotate the to-be-processed graph and the minimum circumscribed rectangle both clockwise by the included angle; the identifying module is specifically configured to identify, based on the to-be-processed graph rotated clockwise and the minimum circumscribed rectangle rotated clockwise, an inner recess rectangle rotated clockwise corresponding to the inner recess part included in the to-be-processed graph; and the correcting module is specifically configured to remove the inner recess rectangle rotated clockwise from the minimum circumscribed rectangle rotated clockwise, and rotate the obtained graph counterclockwise by the included angle, to obtain a corrected graph corresponding to the to-be-processed graph.

[0025] Optionally, the apparatus further comprises: a moving module, configured to obtain a first center point position of the minimum circumscribed rectangle and a second center point position of the graph rotated counterclockwise, and move the graph rotated counterclockwise until the second center point position coincides with the first center point position.

[0026] Optionally, the to-be-processed graph is a roof graph obtained by identifying a roof part in a satellite image by using a preset roof identification model.

[0027] In a third aspect, an electronic device is disclosed, comprising: one or more processors; and one or more machine-readable media having stored thereon instructions that, when executed by the one or more processors, cause the processors to perform the graph correction method according to any one of the preceding aspects.

[0028] In a fourth aspect, the embodiments of the present application disclose a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the graphic correction method according to any one of the preceding aspects.

[0029] In the embodiments of the present application, the minimum circumscribed rectangle of the to-be-processed graphic is obtained, the inner recessed rectangle corresponding to the inner recessed part in the to-be-processed graphic is identified based on the to-be-processed graphic and the minimum circumscribed rectangle, and the inner recessed rectangle is removed from the minimum circumscribed rectangle, and the obtained graphic is taken as the corrected graphic corresponding to the to-be-processed graphic. Therefore, in the embodiments of the present application, the to-be-processed graphic is corrected based on the minimum circumscribed rectangle of the to-be-processed graphic and the inner recessed rectangle corresponding to the inner recessed part, so that the to-be-processed graphic can be corrected into a more regular graphic, thereby making up for the defect that the graphic identified by the recognition model is inaccurate. BRIEF DESCRIPTION OF DRAWINGS

[0030] Figure 1 is a step flow chart of a graphic correction method according to an embodiment of the present application.

[0031] Figure 2 is a step flow chart of another graphic correction method according to an embodiment of the present application.

[0032] Figure 3 is an effect schematic diagram of a graphic correction process according to an embodiment of the present application.

[0033] Figure 4 is a step flow chart of still another graphic correction method according to an embodiment of the present application.

[0034] Figure 5 is a structure block diagram of a graphic correction device according to an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the above objectives, characteristics and advantages of the present application more apparent and comprehensible, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0036] In order to make the above objectives, characteristics and advantages of the present application more apparent and comprehensible, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0037] Based on this, the embodiment of the present application proposes a way of automatically shaping and correcting the to-be-processed graph based on the minimum circumscribed rectangle of the to-be-processed graph and the inner recessed graph corresponding to the inner recessed part, which is low in cost, high in efficiency and high in accuracy. The embodiment of the present application can be applied to a server with data processing function.

[0038] Referring to Figure 1 , a step flow chart of a graph correction method is shown.

[0039] As Figure 1 shown, the graph correction method can include the following steps:

[0040] Step 101, obtaining the minimum circumscribed rectangle of the to-be-processed graph.

[0041] The satellite map has multiple levels, and different magnification levels correspond to different levels of satellite maps, and the higher the level, the clearer the details. The satellite map is composed of multiple tiles, and each level of tile corresponds to a picture with different clarity. Using a preset recognition model, part of the tiles (i.e. pictures) in the satellite map can be image-recognized to obtain the corresponding graph of the part of the tiles. However, since the graph recognized by the recognition model has low accuracy, in the embodiment of the present application, the graph recognized by the recognition model is taken as the to-be-processed graph, and the to-be-processed graph is corrected to make its shape more regular.

[0042] The to-be-processed graph can be any graph containing an inner recessed part. The to-be-processed graph can be a polygon or the like.

[0043] Optionally, in the scenario of identifying the roof of the satellite map, the to-be-processed graph can be a roof graph. The roof graph can be obtained by identifying the roof part of the satellite map using a preset roof identification model. The roof graph can contain at least one inner recessed part.

[0044] A large amount of sample data is obtained in advance, each sample data can include a sample picture corresponding to the roof part of the satellite map, and an actual roof graph obtained after labeling the sample picture. The initial model is trained using the sample data. In the training process, the input of the initial model is the sample picture, and the output is the predicted roof graph. According to the predicted roof graph and the actual roof graph, the loss value of the model can be calculated. In the case where the loss value meets the preset condition, it is determined that the training is completed, and the trained model is taken as the roof identification model. After the roof identification model is trained, the picture corresponding to the roof part of the satellite map is input into the roof identification model, and the roof graph corresponding to the roof part output by the roof identification model can be obtained.

[0045] The roof identification model can be any model with image recognition capability. For example, a Mask-RCNN (Mask Region Convolutional Neural Network) model, a U-Net (U-shaped network) model, and the like.

[0046] For the to-be-processed graph, the minimum circumscribed rectangle of the to-be-processed graph can be obtained. In implementation, the manner of obtaining the minimum circumscribed rectangle can include but is not limited to a fitting manner, a coordinate calculation manner, a function calculation manner, and the like.

[0047] Optionally, to simplify the processing process, the minimum circumscribed rectangle of the to-be-processed graph can be obtained by using a function such as cv2.minAreaRect. The data returned by the function cv2.minAreaRect() includes the center (x, y) of the minimum circumscribed rectangle, the width and height, and the rotation angle. However, to draw the minimum circumscribed rectangle, the coordinates of the four vertices of the rectangle are also needed, which can be obtained by using the function cv2.cv.BoxPoints(), and the returned form is [[x0, y0], [x1, y1], [x2, y2], [x3, y3]].

[0048] At step 102, based on the to-be-processed graph and the minimum circumscribed rectangle, an inner recessed rectangle corresponding to an inner recessed part in the to-be-processed graph is identified.

[0049] Considering that the inner recessed part in the to-be-processed graph is irregular, the inner recessed part needs to be modified to a regular rectangular shape. Based on the to-be-processed graph and the minimum circumscribed rectangle of the to-be-processed graph, an inner recessed rectangle corresponding to each inner recessed part in the to-be-processed graph can be identified.

[0050] For ease of description, the pixels on the minimum circumscribed rectangle are referred to as first pixels, and the pixels on the to-be-processed graph are referred to as second pixels. In an optional implementation, based on the to-be-processed graph and the minimum circumscribed rectangle, the process of identifying an inner recessed rectangle corresponding to an inner recessed part contained in the to-be-processed graph can include the following steps A1-A3:

[0051] A1, for each first pixel on each edge of the minimum circumscribed rectangle, the inner recessed depth corresponding to the current first pixel on the current edge is calculated according to the second pixels on the to-be-processed graph.

[0052] Optionally, the process of calculating the concave depth corresponding to the current first pixel on the current edge according to the second pixel on the to-be-processed graph can comprise: obtaining, as the current second pixel, a second pixel in the to-be-processed graph that is located on a straight line perpendicular to the current edge and passing through the current first pixel and that is closest to the current first pixel; and obtaining, as the concave depth corresponding to the current first pixel, a distance between the current first pixel and the current second pixel.

[0053] For each edge in the minimum circumscribed rectangle, each first pixel is traversed in turn from a first first pixel on the current edge. For a current first pixel on the current edge, a second pixel closest to the current first pixel is found by searching downward along a straight line perpendicular to the current edge and passing through the current first pixel, and the found second pixel is taken as a current second pixel corresponding to the current first pixel.

[0054] After the to-be-processed graph is identified, coordinates of the to-be-processed graph in a rectangular coordinate system can be obtained. After the minimum circumscribed rectangle of the to-be-processed graph is obtained, coordinates of the minimum circumscribed rectangle in the rectangular coordinate system can be obtained. According to the coordinates of the to-be-processed graph and the coordinates of the minimum circumscribed rectangle, coordinates of the current first pixel and coordinates of the current second pixel can be calculated, and then according to the coordinates of the current first pixel and the coordinates of the current second pixel, a distance between the current first pixel and the current second pixel can be calculated. Alternatively, the distance between the current first pixel and the current second pixel can also be represented by a number of pixels between the current first pixel and the current second pixel on a straight line perpendicular to the current edge and passing through the current first pixel.

[0055] A2, based on the concave depth, aggregating the first pixels belonging to the same concave part into a first pixel set.

[0056] After the concave depth corresponding to each first pixel on each edge in the minimum circumscribed rectangle is calculated, for each edge, each first pixel is traversed in turn from a first first pixel on the current edge, the first pixels are clustered based on the concave depth, and the first pixels belonging to the same concave part are aggregated into a first pixel set. That is, one concave part corresponds to one first pixel set.

[0057] Optionally, based on the inner recess depth, the process of aggregating the first pixels belonging to the same inner recess part into a first pixel set can comprise: selecting, as an inner recess start pixel, a first pixel located after the first pixel with the inner recess depth less than or equal to the preset threshold and before the first pixel with the first inner recess depth greater than the preset threshold; selecting, as an inner recess end pixel corresponding to the inner recess start pixel, a last first pixel located after the inner recess start pixel and before the first pixel with the inner recess depth less than or equal to the preset threshold and with the last inner recess depth greater than the preset threshold; and considering the first pixels from the inner recess start pixel to the inner recess end pixel corresponding to the inner recess start pixel as belonging to the same inner recess part, and thus regarding these first pixels as a first pixel set.

[0058] For example, a side of the minimum circumscribed rectangle contains 10 first pixels, i.e., first pixel 1, first pixel 2, first pixel 3, first pixel 4, first pixel 5, first pixel 6, first pixel 7, first pixel 8, first pixel 9, and first pixel 10. Starting from the first pixel 1, it is determined in sequence whether the inner recess depth corresponding to each first pixel is greater than the preset threshold. The determination result is that the inner recess depth corresponding to the first pixel 1 is less than or equal to the preset threshold, the inner recess depth corresponding to the first pixel 2 is greater than the preset threshold, the inner recess depth corresponding to the first pixel 3 is greater than the preset threshold, the inner recess depth corresponding to the first pixel 4 is greater than the preset threshold, the inner recess depth corresponding to the first pixel 5 is less than or equal to the preset threshold, the inner recess depth corresponding to the first pixel 6 is less than or equal to the preset threshold, the inner recess depth corresponding to the first pixel 7 is greater than the preset threshold, the inner recess depth corresponding to the first pixel 8 is greater than the preset threshold, the inner recess depth corresponding to the first pixel 9 is greater than the preset threshold, and the inner recess depth corresponding to the first pixel 10 is less than or equal to the preset threshold.

[0059] Therefore, the first pixel 2 is selected as an inner recess start pixel, the first pixel 4 is selected as an inner recess end pixel corresponding to the first pixel 2, and the first pixel 2, the first pixel 3, and the first pixel 4 are considered to belong to the same inner recess part, and thus the first pixel 2, the first pixel 3, and the first pixel 4 are regarded as a first pixel set. The first pixel 7 is selected as an inner recess start pixel, the first pixel 9 is selected as an inner recess end pixel corresponding to the first pixel 7, and the first pixel 7, the first pixel 8, and the first pixel 9 are considered to belong to the same inner recess part, and thus the first pixel 7, the first pixel 8, and the first pixel 9 are regarded as a first pixel set.

[0060] The specific value of the preset threshold can be any applicable value, and the embodiments of the present application do not limit the same. For example, the preset threshold can be 10 pixels, 15 pixels, or the like.

[0061] A3, for each first pixel set, determining the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs according to the first pixel in the current first pixel set and the inner recess depth corresponding to the first pixel in the current first pixel set.

[0062] Optionally, the process of determining the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs according to the first pixel in the current first pixel set and the inner recess depth corresponding to the first pixel in the current first pixel set can comprise: taking the pixels between the inner recess start pixel in the current first pixel set and the inner recess end pixel in the current first pixel set as the length of the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs; taking the average of the minimum inner recess depth and the maximum inner recess depth corresponding to the first pixel in the current first pixel set as the width of the inner recess rectangle corresponding to the inner recess part to which the current first pixel set belongs.

[0063] For example, for a first pixel set composed of the first pixel 2, the first pixel 3 and the first pixel 4, the inner recess depth corresponding to the first pixel 2 is 12 pixels, the inner recess depth corresponding to the first pixel 3 is 16 pixels, and the inner recess depth corresponding to the first pixel 4 is 13 pixels. Therefore, the three pixels of the first pixel 2, the first pixel 3 and the first pixel 4 are taken as the length of the inner recess rectangle corresponding to the inner recess part to which the first pixel set belongs. The average of the minimum inner recess depth of 12 pixels and the maximum inner recess depth of 16 pixels, i.e. 14 pixels, is taken as the width of the inner recess rectangle corresponding to the inner recess part to which the first pixel set belongs. It should be noted that the specific values in the above example are only used for illustration and do not limit the embodiments of the present application. Since it is considered that there can be a large error if the maximum inner recess depth is directly used as the width of the inner recess rectangle, the average of the minimum inner recess depth and the maximum inner recess depth is used as the width of the inner recess rectangle in the embodiments of the present application, thereby reducing the error.

[0064] Step 103: removing the inner recess rectangle from the minimum circumscribed rectangle to obtain a modified graph corresponding to the to-be-processed graph.

[0065] After obtaining the inner recess rectangle corresponding to each inner recess part included in the to-be-processed graph, each inner recess rectangle is removed from the minimum circumscribed rectangle of the to-be-processed graph, i.e. the minimum circumscribed rectangle of the to-be-processed graph is subtracted by each inner recess rectangle, and the graph obtained after removing each inner recess rectangle from the minimum circumscribed rectangle is taken as the modified graph corresponding to the to-be-processed graph.

[0066] In the embodiments of the present application, the to-be-processed graph is modified to a more regular graph by modifying the to-be-processed graph based on the minimum circumscribed rectangle of the to-be-processed graph and the inner recess graph corresponding to the inner recess part, thereby making up for the defect that the graph recognized by the recognition model is not accurate.

[0067] Referring to Figure 2 , a step flow chart of another graphic correction method of an embodiment of the present application is shown.

[0068] As Figure 2 shown, the graphic correction method can include the following steps:

[0069] Step 201, obtaining a minimum circumscribed rectangle of a to-be-processed graphic.

[0070] Step 202, obtaining an included angle between the minimum circumscribed rectangle and the horizontal direction.

[0071] Referring to the above step 101, if the minimum circumscribed rectangle of the to-be-processed graphic is obtained by using the function cv2.minAreaRect, the data returned by the function cv2.minAreaRect() includes: the center (x, y) of the minimum circumscribed rectangle, (width, height), and the rotation angle. The rotation angle is the included angle between the minimum circumscribed rectangle and the horizontal direction.

[0072] Step 203, rotating the to-be-processed graphic and the minimum circumscribed rectangle both clockwise by the included angle.

[0073] The to-be-processed graphic and the minimum circumscribed rectangle are both rotated clockwise by the included angle, so that the to-be-processed graphic after clockwise rotation and the minimum circumscribed rectangle after clockwise rotation are both placed in the horizontal direction.

[0074] Optionally, in order to simplify the processing process, the to-be-processed graphic can be rotated clockwise by the included angle by using the function affinity.rotate, and the minimum circumscribed rectangle can be rotated clockwise by the included angle by using the function affinity.rotate.

[0075] Step 204, based on the to-be-processed graphic after clockwise rotation and the minimum circumscribed rectangle after clockwise rotation, identifying a to-be-processed graphic after clockwise rotation corresponding to a concave part in the to-be-processed graphic.

[0076] The specific process of step 204 can refer to the related description in the above step 102.

[0077] Since the to-be-processed graphic after clockwise rotation and the minimum circumscribed rectangle after clockwise rotation are both placed in the horizontal direction, in the process of calculating the concave depth, selecting along the vertical direction is more convenient than selecting along the inclined direction.

[0078] Step 205, eliminating the to-be-processed graphic after clockwise rotation from the minimum circumscribed rectangle after clockwise rotation, and rotating the included angle counterclockwise, and taking the obtained graphic as the corrected graphic corresponding to the to-be-processed graphic.

[0079] After the concave rectangle after clockwise rotation is removed from the minimum circumscribed rectangle after clockwise rotation, the figure obtained after counterclockwise rotation of the angle is removed so as to return to the original position. The figure obtained after counterclockwise rotation is taken as the corrected figure corresponding to the to-be-processed figure.

[0080] Figure 3 is a schematic diagram of the effect of a figure correction process according to an embodiment of the present application. As shown in Figure 3 , the gray filled area in (a) is a real roof figure, the figure composed of dashed lines is a to-be-processed figure, the rectangle composed of solid lines is a minimum circumscribed rectangle of the to-be-processed figure, and θ is the angle between the minimum circumscribed rectangle and the horizontal direction. The figure in (a) is rotated forward by the angle θ to obtain (b). By processing (b), based on the to-be-processed figure after clockwise rotation and the minimum circumscribed rectangle after clockwise rotation, a concave rectangle after clockwise rotation corresponding to the concave part contained in the to-be-processed figure is identified, and the concave rectangle after clockwise rotation is removed from the minimum circumscribed rectangle after clockwise rotation to obtain (c). (c) is rotated counterclockwise by the angle θ to obtain (d), and the figure composed of solid lines in (d) is the corrected figure corresponding to the to-be-processed figure.

[0081] Referring to Figure 4 , a step flowchart of still another figure correction method according to an embodiment of the present application is shown.

[0082] As shown in Figure 4 , the figure correction method can include the following steps:

[0083] Step 401, a minimum circumscribed rectangle of a to-be-processed figure is obtained.

[0084] Step 402, an angle between the minimum circumscribed rectangle and the horizontal direction is obtained.

[0085] Step 403, the to-be-processed figure and the minimum circumscribed rectangle are both rotated clockwise by the angle.

[0086] Step 404, based on the to-be-processed figure after clockwise rotation and the minimum circumscribed rectangle after clockwise rotation, a concave rectangle after clockwise rotation corresponding to a concave part contained in the to-be-processed figure is identified.

[0087] Step 405, the concave rectangle after clockwise rotation is removed from the minimum circumscribed rectangle after clockwise rotation, and the angle is rotated counterclockwise.

[0088] Step 406, a first center point position of the minimum circumscribed rectangle and a second center point position of the figure after counterclockwise rotation are obtained.

[0089] Step 407, the figure after counterclockwise rotation is moved until the second center point position coincides with the first center point position.

[0090] Considering that the position of the figure can be offset after two rotations, position correction can be performed. The first center point position of the minimum circumscribed rectangle obtained in the acquisition step 401 and the second center point position of the figure after the counterclockwise rotation in the step 405 are obtained. The figure after the counterclockwise rotation in the moving step 405 is moved until the second center point position coincides with the first center point position, and the position correction is completed.

[0091] The embodiment of the present application can be applied to a map display scene, and the roof figure identified by the model is reshaped, so that the reshaped roof figure is closer to the real roof. The embodiment of the present application has low cost, wide coverage and good correction effect.

[0092] Reference Figure 5 , a structural block diagram of a figure correction device is shown.

[0093] As shown in Figure 5 , the figure correction device can include the following modules:

[0094] The acquisition module 501 is configured to acquire a minimum circumscribed rectangle of a to-be-processed figure.

[0095] The identification module 502 is configured to identify, based on the to-be-processed figure and the minimum circumscribed rectangle, an inner recessed rectangle corresponding to an inner recessed part included in the to-be-processed figure.

[0096] The correction module 503 is configured to eliminate the inner recessed rectangle from the minimum circumscribed rectangle, and take the obtained figure as a corrected figure corresponding to the to-be-processed figure.

[0097] Optionally, the identification module 502 includes: a calculation unit configured to, for each first pixel on each edge of the minimum circumscribed rectangle, calculate, according to a second pixel on the to-be-processed figure, an inner recessed depth corresponding to the current first pixel on the current edge; an aggregation unit configured to, based on the inner recessed depth, aggregate the first pixels belonging to the same inner recessed part into a first pixel set; and a determination unit configured to, for each first pixel set, determine, according to the first pixel in the current first pixel set and the inner recessed depth corresponding to the first pixel in the current first pixel set, an inner recessed rectangle corresponding to the inner recessed part to which the current first pixel set belongs.

[0098] Optionally, the calculation unit includes: a pixel acquisition subunit configured to acquire, as a current second pixel, a second pixel in the to-be-processed figure located on a straight line perpendicular to the current edge and closest to the current first pixel; and a depth acquisition subunit configured to acquire, as the inner recessed depth corresponding to the current first pixel, a distance between the current first pixel and the current second pixel.

[0099] Optionally, the aggregating unit comprises: a pixel selecting subunit, configured to select, as an inner recess starting pixel, a first pixel located after a first pixel with an inner recess depth less than or equal to a preset threshold and having a first inner recess depth greater than the preset threshold; select, as an inner recess ending pixel corresponding to the inner recess starting pixel, a last first pixel located after the inner recess starting pixel and before a first pixel with an inner recess depth less than or equal to the preset threshold and having a first inner recess depth greater than the preset threshold; and a pixel aggregating subunit, configured to aggregate, as a first pixel set, the first pixels between an inner recess starting pixel and an inner recess ending pixel corresponding to the inner recess starting pixel.

[0100] Optionally, the determining unit comprises: a first determining subunit, configured to determine, as a length of an inner recess rectangle corresponding to an inner recess portion to which the current first pixel set belongs, a pixel between an inner recess starting pixel in the current first pixel set and an inner recess ending pixel in the current first pixel set; and a second determining subunit, configured to determine, as a width of the inner recess rectangle corresponding to the inner recess portion to which the current first pixel set belongs, an average value of a minimum inner recess depth and a maximum inner recess depth corresponding to the first pixels in the current first pixel set.

[0101] Optionally, the apparatus further comprises: a rotating module, configured to obtain an angle between the minimum circumscribed rectangle and a horizontal direction, and rotate the to-be-processed graph and the minimum circumscribed rectangle both clockwise by the angle; the identifying module 502 is specifically configured to identify, based on the to-be-processed graph after clockwise rotation and the minimum circumscribed rectangle after clockwise rotation, an inner recess rectangle after clockwise rotation corresponding to the inner recess portion included in the to-be-processed graph; and the correcting module 503 is specifically configured to remove the inner recess rectangle after clockwise rotation from the minimum circumscribed rectangle after clockwise rotation, and rotate the obtained graph counterclockwise by the angle, to obtain a corrected graph corresponding to the to-be-processed graph.

[0102] Optionally, the apparatus further comprises: a moving module, configured to obtain a first center point position of the minimum circumscribed rectangle and a second center point position of the graph after counterclockwise rotation, and move the graph after counterclockwise rotation until the second center point position coincides with the first center point position.

[0103] Optionally, the to-be-processed graph is a roof graph obtained by identifying a roof portion in a satellite graph by using a preset roof identification model.

[0104] In the embodiment of the application, the to-be-processed graph is corrected into a more regular graph by correcting the to-be-processed graph based on the minimum circumscribed rectangle of the to-be-processed graph and the inner recess graph corresponding to the inner recess portion, so as to compensate for the inaccuracy of the graph identified by the identification model.

[0105] For the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts are referred to the part of the method embodiment.

[0106] In the embodiments of the present application, an electronic device is also provided. The electronic device can include one or more processors, and one or more machine-readable media having instructions, such as an application program, stored thereon. When the instructions are executed by the one or more processors, the processors perform the above-mentioned image correction method.

[0107] In the embodiments of the present application, a non-transitory computer-readable storage medium having a computer program stored thereon is also provided, which can be executed by the processor of an electronic device to complete the above-mentioned image correction method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0108] Each of the embodiments in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same and similar parts between the embodiments can be referred to each other.

[0109] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, apparatus, or computer program product. Therefore, the embodiments of the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0110] The embodiments of the present application are described with reference to flowcharts and / or block diagrams according to the method, terminal device (system), and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the computer or other programmable data processing terminal device produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The apparatus that implements the functions specified in one block or multiple blocks.

[0111] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow Figure 1 one or more flow or block Figure 1 one or more flow or block

[0112] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow Figure 1 one or more flow or block Figure 1 one or more flow or block

[0113] While preferred embodiments of the application have been described, those skilled in the art will recognize that additional modifications and variations can be made thereto without departing from the scope of the application. It is therefore intended that the appended claims cover all such modifications and variations as fall within the scope of the application.

[0114] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and do not imply singular or plural. Moreover, the terms "include", "have", or any other variant thereof are intended to cover non-exclusive inclusions, such that a process, method, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises a... " does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0115] The above provides a kind of graphic correction method, device, electronic equipment and storage medium provided by the present application, the principle and implementation mode of the present application are described in this paper by applying specific examples, the above example is only for helping to understand the method of the present application and its core idea;For the general technical personnel in the art, according to the idea of the present application, there will be changes in specific implementation mode and application range, and the above description should not be understood as the limitation of the present application.

Claims

1. A method for correcting graphics, characterized in that, include: Obtain the smallest bounding rectangle of the graphic to be processed; Based on the graphic to be processed and the minimum bounding rectangle, identify the concave rectangle corresponding to the concave portion contained in the graphic to be processed; The concave rectangle is removed from the minimum bounding rectangle, and the resulting graphic is used as the corrected graphic corresponding to the graphic to be processed. The step of identifying the concave rectangle corresponding to the concave portion contained in the graphic to be processed, based on the graphic to be processed and the minimum bounding rectangle, includes: For each first pixel on each side of the minimum bounding rectangle, calculate the concave depth corresponding to the current first pixel on the current side based on the second pixel on the graphic to be processed; Based on the concave depth, the first pixels belonging to the same concave part are aggregated into a first pixel set; For each set of first pixels, the concave rectangle corresponding to the concave portion of the current set of first pixels is determined based on the first pixel in the current set of first pixels and the concave depth corresponding to the first pixel in the current set of first pixels.

2. The method according to claim 1, characterized in that, The step of calculating the concave depth corresponding to the current first pixel on the current edge based on the second pixel on the image to be processed includes: The second pixel in the image to be processed, which is located on the straight line perpendicular to the current edge where the current first pixel is located and is closest to the current first pixel, is taken as the current second pixel; The distance between the current first pixel and the current second pixel is obtained and used as the concave depth corresponding to the current first pixel.

3. The method according to claim 1, characterized in that, The step of aggregating first pixels belonging to the same concave portion into a first pixel set based on the concave depth includes: The first pixel with a concave depth greater than the preset threshold, which is located after the first pixel with a concave depth less than or equal to the preset threshold, is selected as the concave start pixel. The first pixel whose last concave depth is greater than the preset threshold is selected after the concave start pixel and before the first pixel whose concave depth is less than or equal to the preset threshold, and is used as the concave end pixel corresponding to the concave start pixel. The first pixel between a concave starting pixel and the concave ending pixel corresponding to that concave starting pixel is taken as a first pixel set.

4. The method according to claim 3, characterized in that, The step of determining the concave rectangle corresponding to the concave portion of the current first pixel set based on the first pixel in the current first pixel set and the concave depth corresponding to the first pixel in the current first pixel set includes: The pixels from the beginning of the concave portion of the current first pixel set to the end of the concave portion of the current first pixel set are used as the length of the concave rectangle corresponding to the concave portion of the current first pixel set; the average of the minimum and maximum concave depths corresponding to the first pixel in the current first pixel set is used as the width of the concave rectangle corresponding to the concave portion of the current first pixel set.

5. The method according to claim 1, characterized in that, After obtaining the minimum bounding rectangle of the graphic to be processed, the method further includes: obtaining the angle between the minimum bounding rectangle and the horizontal direction, and rotating both the graphic to be processed and the minimum bounding rectangle clockwise by the angle; Based on the graphic to be processed and the minimum bounding rectangle, identify the concave rectangle corresponding to the concave portion contained in the graphic to be processed, including: based on the graphic to be processed after clockwise rotation and the minimum bounding rectangle after clockwise rotation, identify the concave rectangle corresponding to the concave portion contained in the graphic to be processed after clockwise rotation. The process of removing the concave rectangle from the minimum bounding rectangle and using the resulting graphic as the corrected graphic corresponding to the graphic to be processed includes: removing the concave rectangle from the clockwise rotated minimum bounding rectangle and rotating the included angle counterclockwise, and using the resulting graphic as the corrected graphic corresponding to the graphic to be processed.

6. The method according to claim 5, characterized in that, After rotating the included angle counterclockwise, it also includes: Obtain the first center point position of the smallest bounding rectangle and the second center point position of the graphic after counterclockwise rotation; move the graphic after counterclockwise rotation until the second center point position coincides with the first center point position.

7. The method according to claim 1, characterized in that, The image to be processed is a rooftop image obtained by identifying the rooftop portion in a satellite image using a preset rooftop recognition model.

8. A graphic correction device, characterized in that, include: The acquisition module is used to obtain the minimum bounding rectangle of the graphic to be processed; The identification module is used to identify, based on the graphic to be processed and the minimum bounding rectangle, a concave rectangle corresponding to a concave portion contained in the graphic to be processed. The identification of the concave rectangle corresponding to a concave portion contained in the graphic to be processed, based on the graphic to be processed and the minimum bounding rectangle, includes: For each first pixel on each side of the minimum bounding rectangle, calculate the concave depth corresponding to the current first pixel on the current side based on the second pixel on the graphic to be processed; Based on the concave depth, the first pixels belonging to the same concave part are aggregated into a first pixel set; For each set of first pixels, the concave rectangle corresponding to the concave portion of the current set of first pixels is determined based on the first pixel in the current set of first pixels and the concave depth corresponding to the first pixel in the current set of first pixels. The correction module is used to remove the concave rectangle from the minimum bounding rectangle and use the resulting graphic as the corrected graphic corresponding to the graphic to be processed.

9. An electronic device, characterized in that, include: One or more processors; and one or more machine-readable media on which instructions are stored; When the instructions are executed by the one or more processors, the processors perform the graphics correction method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the graphics correction method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Image identification method and apparatus

    CN105069454A