Map beautification method, device, robot and storage medium

By performing a series of image processing on the map images acquired by the robot, including grayscale, preprocessing, contour extraction and beautification, the problem of messy lines of the map image is solved and the aesthetics and intuitiveness are improved.

CN114612628BActive Publication Date: 2025-04-22WAYZ ROBOTICS (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210253436.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-15
Publication Date
2025-04-22
Estimated Expiration
2042-03-15

AI Technical Summary

Technical Problem

Due to sensor errors, the lines are messy, unsightly, and the map information is not displayed intuitively.

Method used

The beautified map image is obtained by performing a series of processing such as grayscale processing, preprocessing, contour extraction, contour length calculation, position connection adjustment, image addition and irregular area elimination.

Benefits of technology

It improves the aesthetics of map images, enhances the intuitiveness of map information, and solves the problem of messy lines of map images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114612628B_ABST
    Figure CN114612628B_ABST
Patent Text Reader

Abstract

The present invention discloses a map beautification method, device, robot and storage medium. The method comprises: graying the acquired map image to obtain a grayed image; preprocessing the grayed image to obtain a binary image; extracting contours from the binary image to obtain multiple contours; calculating the contour length of each contour, and searching for each long strip contour whose contour length is greater than or equal to a preset length threshold from each contour; adjusting the position of each long strip contour to obtain a contour image; adding the contour image to the grayed image to obtain an added image; searching and eliminating irregular areas outside the corresponding contour in the added image to obtain a beautified map image. Based on each contour, the method adjusts the position of the long strip contours in the contour to achieve the beautification of the contour, thereby achieving the beautification of the map image and improving the aesthetics of the map image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to a map beautification method, device, robot and storage medium. Background Art

[0002] With the development of artificial intelligence, the research of robots has received more and more attention and investment, and the positioning, map creation and acquisition of robots are hot research issues in the field of robots. At present, robots can obtain map images for users to use based on their own sensors; however, in the process of obtaining map images through sensors, due to sensor errors, the obtained map images have problems such as messy lines, unsightly appearance, and non-intuitive display of map information.

[0003] Therefore, how to process the acquired map images by the robot to improve the aesthetics of the map images acquired by the robot is an issue that needs to be solved urgently. Summary of the invention

[0004] In view of this, the purpose of the present invention is to overcome the deficiencies in the prior art and to provide a map beautification method, device, robot and storage medium.

[0005] In a first aspect, the present invention provides a map beautification method, comprising:

[0006] grayscale the acquired map image to obtain a grayscale image;

[0007] Preprocessing the grayscale image to obtain a binary image;

[0008] Performing contour extraction on the binary image to obtain multiple contours, wherein the contour is a collection of pixel points on the edge of the image and has directionality and order;

[0009] Calculating the contour length of each of the contours, and searching for each of the long contours whose contour length is greater than or equal to a preset length threshold from the contours;

[0010] Performing position connection adjustment on each of the long strip contours to obtain a contour image;

[0011] Adding the contour image and the grayscale image to obtain an added image;

[0012] Irregular areas outside the corresponding contour in the added image are found and eliminated to obtain a beautified map image.

[0013] In one implementation, the step of adjusting the positions of the long strip contours to obtain the contour image includes:

[0014] Performing image coordinate processing on each of the long strip contours to obtain the coordinates of each pixel point on each of the long strip contours;

[0015] Determine the relative position of each pixel point on each of the long strip contours based on the coordinates of each pixel point on each of the long strip contours;

[0016] According to the relative position, determine the adjacent pixel point group formed by the pixel points located at the adjacent front and rear positions on each of the long strip contours, and calculate the slope of the contour line segment formed between two pixel points in each of the adjacent pixel point groups;

[0017] Extracting a slope-changed pixel point group having the slope and not being zero from adjacent pixel point groups of each of the long strip contours, and calculating a distance between two pixel points in the slope-changed pixel point group;

[0018] When the distance is less than or equal to a predetermined distance threshold, two pixel points of the slope change pixel point group are taken as inflection points;

[0019] When the distance is greater than a predetermined distance threshold, a pixel point located at a front position in the slope change pixel point group is taken as an inflection point;

[0020] According to the inflection point, the position of the long strip contour including the inflection point is adjusted and connected to obtain a contour image.

[0021] In one embodiment, the step of adjusting and connecting the long strip contours including the inflection point according to the inflection point to obtain the contour image includes:

[0022] Determining the order in which the long strip contours are sorted in the binary image according to the directionality and sequence of the long strip contours;

[0023] According to the sequence, the long strip of contours containing the inflection point and being ranked at the front is sequentially used as the first contour line segment, and the long strip of contours containing the inflection point and being ranked at the rear of the first contour line segment is sequentially used as the second contour line segment;

[0024] Calculating vector coordinates of the first contour line segment and the second contour line segment, and determining the line segment directions of the first contour line segment and the second contour line segment based on the vector coordinates;

[0025] Based on the line segment direction, the position of the second contour line segment is adjusted, and the second contour line segment is connected with the first contour line segment to obtain a contour image.

[0026] In one implementation, adjusting the position of the second contour line segment based on the line segment direction and connecting the second contour line segment with the first contour line segment to obtain the contour image includes:

[0027] When the first contour line segment and the second contour line segment have the same direction, transferring the second contour line segment to the first contour line segment to obtain a contour image, wherein the first contour line segment and the second contour line segment form a horizontal or vertical straight line segment with a slope of zero or no slope;

[0028] When the line segment directions of the first contour line segment and the second contour line segment are opposite to each other, the inflection point on the first contour line segment is connected with the inflection point on the second contour line segment by a straight line to obtain a contour image.

[0029] In one implementation, extracting contours from the binary image to obtain a plurality of contours comprises:

[0030] Using an image traversal algorithm and a connected domain search algorithm to perform pixel search on the binary image to obtain a black pixel area and a white pixel area;

[0031] A set of edge pixel points between the black pixel area and the white pixel area is extracted to obtain a plurality of contours.

[0032] In one embodiment, the step of searching and eliminating the irregular area outside the corresponding contour in the added image to obtain the beautified map image includes:

[0033] Using an image traversal algorithm to find the outer contour pixel points outside the corresponding contour in the added image;

[0034] Performing diffusion search on the neighborhood corresponding to the outline pixel points to obtain the irregular area formed by the outline pixel points;

[0035] The irregular area is filled with gray to obtain a beautified map image.

[0036] In one implementation, preprocessing the grayscale image to obtain a binary image includes:

[0037] Using a Gaussian filtering algorithm to perform blur processing on the grayscale image to obtain a blurred image;

[0038] The blurred image is binarized to obtain a binarized image.

[0039] In a second aspect, the present invention provides a map beautification device, comprising:

[0040] A grayscale processing module is used to perform grayscale processing on the acquired map image to obtain a grayscale image;

[0041] A preprocessing module, used for preprocessing the grayscale image to obtain a binary image;

[0042] A contour extraction module, used for performing contour extraction on the binary image to obtain multiple contours;

[0043] A calculation module, used for calculating the contour length of each of the contours, and searching for each long contour whose contour length is greater than or equal to a preset length threshold from among the contours;

[0044] A connection adjustment module is used to adjust the position of each of the long strip contours to obtain a contour image;

[0045] An image addition module, used for adding the contour image and the grayscale image to obtain an added image;

[0046] The beautification module is used to find and eliminate irregular areas outside the corresponding contours in the added image to obtain a beautified map image.

[0047] In a third aspect, the present invention provides a robot, comprising a memory and at least one processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the above-mentioned map beautification method.

[0048] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed, implements the above-mentioned map beautification method.

[0049] The embodiments of the present invention have the following advantages:

[0050] The method of the present invention comprises graying the acquired map image to obtain a graying image; preprocessing the graying image to obtain a binary image; extracting contours from the binary image to obtain multiple contours; calculating the contour length of each contour, and searching for each long strip contour whose contour length is greater than or equal to a preset length threshold from each contour; adjusting the position of each long strip contour to obtain a contour image; adding the contour image to the graying image to obtain an added image; searching and eliminating irregular areas outside the corresponding contour in the added image to obtain a beautified map image. The present invention obtains a binary image and extracts contours after performing a series of basic image processing on the map image, and based on each contour, adjusts the position of the long strip contours in the contour to achieve beautification of the contour to obtain a contour image; then performs image addition processing on the contour image and eliminates irregular areas in the added image to obtain a beautified map image, thereby achieving beautification of the map image and improving the aesthetics of the map image. Subsequently, map data can be intuitively obtained according to the beautified map image. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.

[0052] Figure 1 This is a schematic diagram of a first implementation of a map beautification method in an embodiment of the present invention;

[0053] Figure 2 is a schematic diagram of an original map image in an embodiment of the present invention;

[0054] Figure 3 A schematic diagram of a grayscale image in an embodiment of the present invention;

[0055] Figure 4 Schematic diagram of a second implementation of the map beautification method in an embodiment of the present invention;

[0056] Figure 5 A schematic diagram of a blurred image in an embodiment of the present invention;

[0057] Figure 6 A schematic diagram of a binarized image in an embodiment of the present invention;

[0058] Figure 7 Schematic diagram of a third implementation of the map beautification method in an embodiment of the present invention;

[0059] Figure 8 Schematic diagram of multiple profiles in an embodiment of the present invention;

[0060] Fig. 9 Schematic diagram of a fourth implementation of the map beautification method in an embodiment of the present invention;

[0061] Fig.10 It is a schematic diagram of a fifth implementation mode of the map beautification method in an embodiment of the present invention;

[0062] Fig.11 This is a schematic diagram of a sixth implementation of the map beautification method in an embodiment of the present invention;

[0063] Fig.12 Schematic diagram of the direction of contour line segments in an embodiment of the present invention;

[0064] Fig.13 A schematic diagram of a contour image in an embodiment of the present invention;

[0065] Fig.14 A schematic diagram of adding images in an embodiment of the present invention;

[0066] Fig.15This is a schematic diagram of a seventh implementation of the map beautification method in an embodiment of the present invention;

[0067] Fig.16 A schematic diagram of a beautified map image in an embodiment of the present invention;

[0068] Fig.17 Schematic diagram of an embodiment of a map beautification device in an embodiment of the present invention. DETAILED DESCRIPTION

[0069] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0070] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0071] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0072] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0073] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.

[0074] Example 1

[0075] The embodiment of the present invention provides a map beautification method, which is applied to robots. Figure 1 , the map beautification method is described in detail below.

[0076] 110, grayscale processing is performed on the acquired map image to obtain a grayscale image.

[0077] The robot can obtain the original map image through sensors and Slam algorithm, such as Figure 2 As shown in the figure (the original image is a color image), there are many burrs on the black edge of the wall in the original map image; the wall is not straight or flat, that is, the visual effect is irregular; the wall is discontinuous and has breaks; for each element in the same type of map image, the grayscale changes are quite different. For example, the edge in the upper right corner of the map image represents the wall, but its grayscale is higher and it does not appear particularly black.

[0078] The acquired map image is grayed out, that is, the three-channel data of the map image is converted into single-channel data to obtain a grayed-out image (such as Figure 3 ), in addition, grayscale processing is just a basic image processing operation, which is to process a color image into a gray image.

[0079] 120, preprocessing the grayscale image to obtain a binary image.

[0080] In a possible implementation, Figure 4 As shown, step 120 may specifically include the following steps:

[0081] 121, a Gaussian filtering algorithm is used to blur the grayscale image to obtain a blurred image.

[0082] Since there are a lot of burrs on the wall edges in the original map image (i.e., noise data caused by sensor errors), a Gaussian filter is used to blur the grayscale image to obtain a blurred image, such as Figure 5 As shown, compared with the original map image, the edge features of the blurred image are blurred, but its main features are not affected, thereby reducing the step effect around the noise.

[0083] In this embodiment, the use of Gaussian filtering algorithm to blur the grayscale image is a basic operation in image processing. It mainly takes a weighted average value based on the values ​​of the eight pixels around a single pixel. The average value obtained is the pixel value of the new single pixel, which will weaken the step effect in the image.

[0084] 122, binarize the blurred image to obtain a binarized image.

[0085] In this embodiment, the blurred image is binarized to obtain a binarized image (such as Figure 6As shown in the figure, by selecting a higher grayscale threshold for binarization processing, it is not affected by the broken edges and a complete and clear edge feature is obtained; wherein, binarization processing is a basic step in image processing. According to the threshold value, the grayscale image of 0 to 255 is processed into an image of 0 or 1 (the pixel value greater than the threshold is modified to 1--white, and the pixel value less than or equal to the threshold is modified to 0--black), that is, the gray image is processed into a black and white image. Because after the grayscale processing, the grayscale size represents the probability size of the point being an obstacle, 0---obstacle, 127 represents an unknown area, and 255 represents a passable area, so only a grayscale value slightly higher than 127 needs to be selected as the threshold, such as 130 or 140, but due to the error of the laser. Therefore, it is more appropriate to select 160-170; the threshold size can be selected according to the grayscale image, or a fixed threshold can be set for a certain type of simple image. Since the image after grayscale processing is a very simple grayscale image, the threshold can be directly set to 160; pixels greater than or equal to the threshold are 1, white pixels; pixels less than the threshold are 0, black pixels.

[0086] 130, performing contour extraction on the binary image to obtain multiple contours.

[0087] In a possible implementation, Figure 7 As shown, step 130 may specifically include the following steps:

[0088] 131, an image traversal algorithm and a connected domain search algorithm are used to search pixels of the binary image to obtain black pixel areas and white pixel areas.

[0089] 132, extract the edge pixel set between the black pixels and the white pixels to obtain multiple contours.

[0090] In this embodiment, the beautification of the map image is achieved based on each contour, so it is necessary to extract the contour. Contour extraction is a basic operation of image processing and is a prior art. It will not be described in detail here. The opencv library can be used to search for black pixel areas and white pixel areas in the binary image through image traversal and communication domain search; multiple edge pixel point sets between the black pixel area and the white pixel area are extracted to obtain multiple contours, wherein the extracted edge pixel points are black pixels or white pixels, and multiple black pixels or white pixels adjacent to the edge of the black pixel area and the white pixel area are gathered into multiple edge pixel point sets to form multiple contours. The contours have directionality and sequentiality. Figure 8As shown, the thin white lines are the multiple contours we extracted, and the contours are not very regular, and there are many broken line segments, that is, the line segments are not continuous. The contour is a collection of pixel points corresponding to the pixels of the periphery (or inner periphery) of a figure, and in the processing process, any contour is marked as serial number 1, and based on the contour, other contours are marked in clockwise or counterclockwise direction, and the serial number and direction of each contour can be obtained, that is, the contour has directionality and order. In the embodiment of the present invention, when the contour is beautified based on each contour, and then the beautification of the map image is realized, there is no requirement for the continuity or integrity of the contour, so that the beautification of the map image with messy lines can be realized.

[0091] 140 , calculating the contour length of each contour, and searching for each long contour strip whose contour length is greater than or equal to a preset length threshold from each contour.

[0092] In this embodiment, the contour length mainly depends on the set length of the contour's pixel points. For example, if the number of all pixel points of a contour is 15, then the length of this contour is approximately equal to 15. If the number of all pixel points of another contour is 36, then the length of this contour is approximately 36. Therefore, it can be known that the length of the second contour is greater than the length of the first contour.

[0093] After the contours are obtained, each contour needs to be beautified, the contour length of each contour is calculated, and each long contour whose contour length is greater than or equal to the preset length threshold is searched from each contour. The preset length threshold can be set according to the actual situation and is not limited here. In this process, when the contour is too short, that is, the contour length is less than the preset length threshold, it is defaulted that the contour will not be beautified in the future. Such short contours are generally the contours of very small obstacles. In order to ensure that the beautified map information is not distorted, it is retained.

[0094] 150, adjusting the positions of the contour strips to obtain a contour image.

[0095] In a possible implementation, Fig. 9 As shown, step 150 may specifically include the following steps:

[0096] 151, performing image coordinate processing on each strip contour to obtain the coordinates of each pixel point on each strip contour.

[0097] 152, based on the coordinates of each pixel point on each long strip contour, determine the relative position of each pixel point on each long strip contour.

[0098] Each long strip contour is processed into an image coordinate to obtain the coordinates of each pixel on each long strip contour, that is, an image coordinate system is created in the binary image. Under the image coordinate system, the coordinate representation of each pixel on each contour can be obtained. Based on the coordinates of each pixel on each long strip contour, the relative position of each pixel on each long strip contour can be determined.

[0099] 153. According to the relative position, determine the adjacent pixel point group formed by the pixel points located at the adjacent front and rear positions on each strip contour, and calculate the slope of the contour line segment formed between two pixel points in each adjacent pixel point group.

[0100] According to the relative position of each pixel point on each long strip contour, as well as the directionality and sequentiality of the contour, adjacent pixel point groups formed by the pixel points located at the adjacent front and rear positions on each long strip contour are searched in turn, that is, an adjacent pixel point group includes two pixel points that are adjacent in position order. For example, a long strip contour includes four pixel points, and these four pixel points are arranged in order of position as X1, X2, X3, and X4 according to the directionality and sequentiality of the long strip contour. Then the adjacent pixel point group Z corresponding to the long strip contour is Z1 (X1, X2), Z2 (X2, X3), and Z3 (X3, X4); and according to the coordinates corresponding to the pixel points, the slope of the contour segment formed between the two pixel points in each adjacent pixel point group is calculated.

[0101] 154 , extracting a slope-changing pixel point group having a slope and a non-zero slope from the adjacent pixel point groups of each strip contour, and calculating the distance between two pixel points in the slope-changing pixel point group.

[0102] From all adjacent pixel groups, the corresponding adjacent pixel group whose contour segment formed by the adjacent pixel group has a slope and the slope is not zero is extracted, and it is used as the slope change pixel group, and the distance between two pixel points in the slope change pixel group is calculated according to the coordinates of the pixel points, where the distance is a fixed value.

[0103] 155. When the distance is less than or equal to a predetermined distance threshold, two pixel points of the slope change pixel point group are taken as inflection points.

[0104] 156. When the distance is greater than a predetermined distance threshold, a pixel point located at a front position in the slope change pixel point group is taken as an inflection point.

[0105] When the distance between each slope change pixel point group obtained is less than or equal to the predetermined distance threshold, the pixel points in the slope change pixel point group are retained; when the distance between each slope change pixel point group is greater than the predetermined distance threshold, the pixel points located at the rear position in the slope change pixel point group are deleted, and the pixel points located at the front position in the slope change pixel point group are retained. In this process, the slope change pixel point group belongs to the adjacent pixel point group, and the contour has directionality and order, so the two pixel points in each adjacent pixel point group on the contour have a position sorting relationship; when the distance is greater than the predetermined distance threshold, the pixel points at the corresponding position are retained; all the pixel points retained in this step are used as inflection points, wherein the predetermined distance threshold can be set according to the actual situation, which will not be elaborated here. For example, the adjacent pixel point groups Z1 (X1, X2) and Z2 (X2, X3) are also slope change pixel point groups. When in Z1 (X1, X2), the distance between X1 and X2 is less than a predetermined distance threshold, the pixel points X1 and X2 are taken as inflection points; when in Z2 (X2, X3), the distance between X2 and X3 is greater than the predetermined distance threshold, since the pixel point X2 is located at the front position of the slope change pixel point group, the pixel point X2 is taken as the inflection point; when in Z3 (X3, X4), the distance between X3 and X4 is greater than the predetermined distance threshold, since the pixel point X3 is located at the front position of the slope change pixel point group, but X3 is judged not to be an inflection point in the previous adjacent pixel point group Z2 (X2, X3), there is no inflection point in Z3 (X3, X4); after processing, the pixel points X1 and X2 are retained as inflection points.

[0106] 157, according to the inflection point, the position of the long strip contour containing the inflection point is adjusted and connected to obtain a contour image.

[0107] In a possible implementation, Fig.10 As shown, step 157 may specifically include the following steps:

[0108] 1571, according to the directionality and sequence of the long strip contours, determine the order of sorting the long strip contours in the binary image.

[0109] 1572. According to the order of precedence, the long strip of contours that contain an inflection point and are ranked at the front are used as the first contour line segment, and the long strip of contours that contain an inflection point and are ranked after the first contour line segment are used as the second contour line segment.

[0110] 1573. Calculate the vector coordinates of the first contour line segment and the second contour line segment, and determine the segment directions of the first contour line segment and the second contour line segment based on the vector coordinates.

[0111] 1574, based on the line segment direction, adjust the position of the second contour line segment, connect the second contour line segment with the first contour line segment, and obtain a contour image.

[0112] Each strip of contour has directionality and sequence. According to its directionality and sequence, the order of sorting of each strip of contour in the binary image is determined, and the contour line segments formed by two inflection points as endpoints are found and deleted. Then, according to the order of each strip of contour, the strip of contour containing the inflection point and the front position of the contour sorting is used as the first contour line segment, and the strip of contour containing the inflection point and the contour sorting position after the first contour line segment is used as the second contour line segment. According to the coordinates of each pixel point on each strip of contour, the vector coordinates of the first contour line segment and the second contour line segment can be calculated, and based on the vector coordinates, the line segment directions of the first contour line segment and the second contour line segment can be determined.

[0113] In a possible implementation, Fig.11 As shown, step 1574 may specifically include the following steps:

[0114] 15741, when the line segment directions of the first contour line segment and the second contour line segment are in the same direction, the second contour line segment is transferred and connected to the first contour line segment to obtain a contour image.

[0115] 15742, when the line segment directions of the first contour line segment and the second contour line segment are opposite, the inflection point on the first contour line segment is connected with the inflection point on the second contour line segment by a straight line to obtain a contour image.

[0116] like Fig.12 As shown, the clockwise direction is defined as the contour direction, the contour line segments in the wireframe labeled 1 have horizontal line segments whose line segment directions are all in the same direction, and the contour line segments in the wireframe labeled 2 have vertical line segments whose line segment directions are in opposite directions.

[0117] When the line segment directions of the first contour line segment and the second contour line segment are in the same direction, that is, the first contour line segment and the second contour line segment are two horizontal or vertical line segments in the same direction, the second contour line segment is transferred and connected to the first contour line segment based on the first contour line segment, and the first contour line segment and the second contour line segment form a horizontal or vertical straight line segment with a slope of zero or no slope, thereby beautifying the contour in the binary image and obtaining a contour image.

[0118] When the first contour line segment and the second contour line segment are in opposite directions, that is, the first contour line segment and the second contour line segment are two horizontal or vertical line segments in opposite directions, the inflection point of the first contour line segment is directly connected with the inflection point of the second contour line segment by a straight line, thereby beautifying the contour in the binary image and obtaining a contour image (such as Fig.13 shown).

[0119] 160, adding the contour image and the grayscale image to obtain an added image.

[0120] The contour image obtained above is compared with the grayscale image obtained after the grayscale processing in the first step ( Figure 3 ) to add the images and obtain an added image, such as Fig.14 As shown, the added image includes a black outline, a white regular area surrounded by the black outline, a white irregular area outside the black outline, and a gray pixel area.

[0121] 170, find and eliminate irregular areas outside the corresponding contour in the added image to obtain a beautified map image.

[0122] In a possible implementation, Fig.15 As shown, step 170 may specifically include the following steps:

[0123] 171, an image traversal algorithm is used to find the outer contour pixels outside the corresponding contour in the added image.

[0124] 172, perform diffusion search on the neighborhood corresponding to the outline pixel points to obtain the irregular area formed by the outline pixel points.

[0125] 173, fill the irregular area with gray to obtain the beautified map image.

[0126] Through the image traversal algorithm, the outline pixel point outside the corresponding outline in the added image is found, and the diffusion search is performed from the outline pixel point to the neighborhood of the outline pixel point to find all the outline pixel points on the added image, and the irregular area formed by the outline pixel points is obtained, that is, all the white pixels outside the black outline in the added image and the white irregular area formed by the white pixels are found; the white irregular area is filled with gray, so that the white irregular area is integrated with the surrounding gray pixel area to achieve the purpose of eliminating the irregular area, thereby obtaining a beautified map image (such as Fig.16 shown).

[0127] The embodiment of the present invention performs grayscale processing on the acquired map image to obtain a grayscale image; performs preprocessing on the grayscale image to obtain a binary image; performs contour extraction on the binary image to obtain multiple contours; calculates the contour length of each contour, and searches for each long strip contour whose contour length is greater than or equal to a preset length threshold from each contour; performs position connection adjustment on each long strip contour to obtain a contour image; performs image addition on the contour image and the grayscale image to obtain an added image; searches for and eliminates irregular areas outside the corresponding contour in the added image to obtain a beautified map image. The embodiment of the present invention performs a series of basic image processing on the map image to obtain a binary image and extract the contour, and based on each contour, performs position connection adjustment on the long strip contour in the contour to achieve beautification of the contour and obtain the contour image; then performs image addition processing on the contour image and eliminates irregular areas in the added image to obtain a beautified map image, thereby achieving beautification of the map image and improving the aesthetics of the map image. Subsequently, map data can be intuitively obtained based on the beautified map image.

[0128] Example 2

[0129] Please refer to Fig.17 The embodiment of the present invention provides a map beautification device, which includes:

[0130] A grayscale processing module 710 is used to perform grayscale processing on the acquired map image to obtain a grayscale image;

[0131] A preprocessing module 720 is used to preprocess the grayscale image to obtain a binary image;

[0132] A contour extraction module 730 is used to extract contours from the binary image to obtain multiple contours;

[0133] A calculation module 740 is used to calculate the contour length of each of the contours, and search for each long contour whose contour length is greater than or equal to a preset length threshold from the contours;

[0134] A connection adjustment module 750 is used to perform position connection adjustment on each of the long strip contours to obtain a contour image;

[0135] An image adding module 760, configured to add the contour image and the grayscale image to obtain an added image;

[0136] The beautification module 770 is used to find and eliminate irregular areas outside the corresponding contour in the added image to obtain a beautified map image.

[0137] It can be understood that the modules of this embodiment correspond to the steps of the above-mentioned embodiment 1, and any optional items in the above-mentioned embodiment 1 are also applicable to this embodiment, so they are not described in detail here.

[0138] An embodiment of the present invention further provides a robot, which includes a memory and at least one processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the map beautification method of the above embodiment.

[0139] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data (such as outlines, outline images, etc.) created according to the use of the commodity identification system optimization device, etc. In addition, the memory may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0140] An embodiment of the present invention further provides a computer-readable storage medium storing machine executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the map beautification steps of the above embodiment.

[0141] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0142] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0143] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0144] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A map beautification method, characterized in that: include: grayscale the acquired map image to obtain a grayscale image; Preprocessing the grayscale image to obtain a binary image; Performing contour extraction on the binary image to obtain multiple contours, wherein the contour is a collection of pixel points on the edge of the image and has directionality and order; Calculating the contour length of each of the contours, and searching for each of the long contours whose contour length is greater than or equal to a preset length threshold from the contours; Performing position connection adjustment on each of the long strip contours to obtain a contour image; Adding the contour image and the grayscale image to obtain an added image; Finding and eliminating irregular areas outside the corresponding contour in the added image to obtain a beautified map image; The position connection adjustment of each of the long strip contours to obtain the contour image comprises: Performing image coordinate processing on each of the long strip contours to obtain the coordinates of each pixel point on each of the long strip contours; Determine the relative position of each pixel point on each of the long strip contours based on the coordinates of each pixel point on each of the long strip contours; According to the relative position, determine the adjacent pixel point group formed by the pixel points located at the adjacent front and rear positions on each of the long strip contours, and calculate the slope of the contour line segment formed between two pixel points in each of the adjacent pixel point groups; Extracting a slope-changed pixel point group having the slope and not being zero from adjacent pixel point groups of each of the long strip contours, and calculating a distance between two pixel points in the slope-changed pixel point group; When the distance is less than or equal to a predetermined distance threshold, two pixel points of the slope change pixel point group are taken as inflection points; When the distance is greater than a predetermined distance threshold, a pixel point located at a front position in the slope change pixel point group is taken as an inflection point; According to the inflection point, the position of the long strip contour including the inflection point is adjusted and connected to obtain a contour image.

2. The map beautification method according to claim 1, characterized in that: The step of adjusting and connecting the long strip contours including the inflection point according to the inflection point to obtain the contour image comprises: Determining the order in which the long strip contours are sorted in the binary image according to the directionality and sequence of the long strip contours; According to the sequence, the long strip of contours containing the inflection point and being ranked at the front is sequentially used as the first contour line segment, and the long strip of contours containing the inflection point and being ranked at the rear of the first contour line segment is sequentially used as the second contour line segment; Calculating vector coordinates of the first contour line segment and the second contour line segment, and determining the line segment directions of the first contour line segment and the second contour line segment based on the vector coordinates; Based on the line segment direction, the position of the second contour line segment is adjusted, and the second contour line segment is connected with the first contour line segment to obtain a contour image.

3. The map beautification method according to claim 2, characterized in that: The adjusting the position of the second contour line segment based on the line segment direction and connecting the second contour line segment with the first contour line segment to obtain the contour image comprises: When the first contour line segment and the second contour line segment have the same direction, transferring the second contour line segment to the first contour line segment to obtain a contour image, wherein the first contour line segment and the second contour line segment form a horizontal or vertical straight line segment with a slope of zero or no slope; When the line segment directions of the first contour line segment and the second contour line segment are opposite to each other, the inflection point on the first contour line segment is connected with the inflection point on the second contour line segment by a straight line to obtain a contour image.

4. The map beautification method according to claim 1, characterized in that: The performing contour extraction on the binary image to obtain a plurality of contours comprises: Using an image traversal algorithm and a connected domain search algorithm to perform pixel search on the binary image to obtain a black pixel area and a white pixel area; A set of edge pixel points between the black pixel area and the white pixel area is extracted to obtain a plurality of contours.

5. The map beautification method according to claim 1, characterized in that: The step of searching and eliminating the irregular area outside the corresponding contour in the added image to obtain a beautified map image comprises: Using an image traversal algorithm to find the outer contour pixel points outside the corresponding contour in the added image; Performing diffusion search on the neighborhood corresponding to the outline pixel points to obtain the irregular area formed by the outline pixel points; The irregular area is filled with gray to obtain a beautified map image.

6. The map beautification method according to claim 1, characterized in that: The preprocessing of the grayscale image to obtain a binary image comprises: Using a Gaussian filtering algorithm to perform blur processing on the grayscale image to obtain a blurred image; The blurred image is binarized to obtain a binarized image.

7. A map beautification device, characterized in that: include: A grayscale processing module is used to perform grayscale processing on the acquired map image to obtain a grayscale image; A preprocessing module, used for preprocessing the grayscale image to obtain a binary image; A contour extraction module, used for performing contour extraction on the binary image to obtain multiple contours; A calculation module, used for calculating the contour length of each of the contours, and searching for each long contour whose contour length is greater than or equal to a preset length threshold from among the contours; A connection adjustment module is used to adjust the position of each of the long strip contours to obtain a contour image; An image addition module, used for adding the contour image and the grayscale image to obtain an added image; A beautification module, used for finding and eliminating irregular areas outside the corresponding contour in the added image to obtain a beautified map image; Wherein, the connection adjustment module is specifically used for: Perform image coordinate processing on each of the long strip contours to obtain the coordinates of each pixel point on each of the long strip contours; determine the relative position of each pixel point on each of the long strip contours based on the coordinates of each pixel point on each of the long strip contours; determine the adjacent pixel point group formed by the pixel points located at the adjacent front and rear positions on each of the long strip contours according to the relative position, and calculate the slope of the contour line segment formed between two pixel points in each of the adjacent pixel point groups; extract the slope change pixel point group in which the slope exists and the slope is not zero from the adjacent pixel point group of each of the long strip contours, and calculate the distance between the two pixel points in the slope change pixel point group; when the distance is less than or equal to a predetermined distance threshold, use the two pixel points of the slope change pixel point group as inflection points; when the distance is greater than the predetermined distance threshold, use the pixel point located at the front position in the slope change pixel point group as the inflection point; according to the inflection point, adjust the position of the long strip contour containing the inflection point and connect them to obtain a contour image.

8. A robot, characterized in that: The robot comprises a memory and at least one processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the map beautification method according to any one of claims 1 to 6.

9. A computer storage medium, characterized in that The computer program is stored therein, and when the computer program is executed, the map beautification method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method for automatic contour extraction and path generation of bitmap

    CN105528485A

  • Image processing method, mobile terminal and computer readable storage medium

    CN107563977A