Image theme color extraction method, method and apparatus for creating a map based on an image
By removing interfering pixels from the target image in a custom map platform and determining a number of theme colors that exceed the map feature categories, the problem of inconsistent map feature colors was solved, improving configuration efficiency and visual effects.
Patent Information
- Application Number
- CN202211664585.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-23
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-12-23
AI Technical Summary
Existing custom map platforms may have visual inconsistencies between map element colors when configuring map styles, and configuring map elements one by one is time-consuming, laborious, and inefficient.
By acquiring the color data of each pixel in the target image, removing interference pixels with excessively high or low saturation, determining that the number of theme colors is greater than the number of map feature categories, extracting the theme colors from the target image, and applying them to the display of map features.
It achieves visual coordination between map elements, improves configuration efficiency, eliminates the need for users to configure map elements one by one, and meets the color matching characteristics of map scenes.
Smart Images

Figure CN116012476B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of custom map technology, specifically to an image theme color extraction method, an image-based map creation method, and an apparatus. Background Technology
[0002] Existing custom map platforms offer users the ability to configure map styles, such as satellite street style, public transportation style, and night view style, helping users to realize their personalized map customization needs.
[0003] However, when configuring map styles, users need to configure each of the various map elements that make up the vector map individually. Among these elements, such as land, green space, building blocks, roads, and labels, there may be visual inconsistencies in the colors of different map elements. Furthermore, configuring each map element individually is time-consuming, laborious, and inefficient. Summary of the Invention
[0004] At least one embodiment of this disclosure provides a method for extracting image theme colors, a method and apparatus for creating maps from images.
[0005] In a first aspect, embodiments of this disclosure propose a method for extracting image theme colors, the method comprising:
[0006] Obtain the color data of each pixel in the target image used to create the map;
[0007] Based on the color data of each pixel in the target image, interfering pixels in the target image are removed to obtain multiple target pixels for extracting the theme color; wherein the saturation of the target pixels is within a preset saturation range;
[0008] The number of theme colors to be extracted from the image is determined based on the number of categories of map features in the map to be created; wherein, the number of theme colors is greater than the number of categories.
[0009] Based on the number of theme colors and the color data of multiple target pixels, the theme colors corresponding to the number of theme colors are extracted from the target image.
[0010] Secondly, embodiments of this disclosure also propose a method for creating maps based on images, the method comprising:
[0011] Obtain the target image used to create the map;
[0012] Based on the number of categories of map features in the map to be created, multiple theme colors are extracted from the target image using the image theme color extraction method described in the first aspect, wherein the number of theme colors is greater than the number of categories;
[0013] The color corresponding to each map feature category in the map to be created is determined based on multiple theme colors;
[0014] Create a map based on the color corresponding to each map feature category.
[0015] Thirdly, embodiments of this disclosure also provide an image theme color extraction device, which includes:
[0016] The acquisition unit is used to acquire the color data of each pixel in the target image used to create the map.
[0017] The elimination unit is used to eliminate interfering pixels in the target image based on the color data of each pixel in the target image, so as to obtain multiple target pixels for extracting the theme color; wherein the saturation of the target pixels is within a preset saturation range;
[0018] The determining unit is used to determine the number of theme colors to be extracted from the image based on the number of categories of map features in the map to be created; wherein, the number of theme colors is greater than the number of categories;
[0019] The extraction unit is used to extract the theme color corresponding to the number of theme colors from the target image based on the number of theme colors and the color data of multiple target pixels.
[0020] Fourthly, embodiments of this disclosure also propose an apparatus for creating maps based on images, the apparatus comprising:
[0021] The acquisition unit is used to acquire the target image for creating the map.
[0022] The extraction unit is used to extract multiple theme colors from the target image based on the number of categories of map features in the map to be created, using the image theme color extraction method described in the first aspect, wherein the number of theme colors is greater than the number of categories;
[0023] The determination unit is used to determine the color corresponding to each map feature category in the map to be created based on multiple theme colors;
[0024] Create cells to create maps based on the colors corresponding to each map feature category.
[0025] Fifthly, embodiments of this disclosure also provide a computer device, comprising at least one computing device and at least one storage device for storing instructions; the instructions, when executed by the at least one computing device, cause the at least one computing device to perform steps of the image theme color extraction method described in the first aspect or the image-based map creation method described in the second aspect.
[0026] In a sixth aspect, embodiments of this disclosure also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a program or instructions that cause a computer to perform the image theme color extraction method as described in the first aspect or the image-based map creation method as described in the second aspect.
[0027] In a seventh aspect, embodiments of this disclosure also provide a computer program product, wherein the computer program product includes a computer program stored in a computer-readable storage medium, and at least one processor of the computer reads from the storage medium and executes the computer program, causing the computer to perform the image theme color extraction method as described in the first aspect or the image-based map creation method as described in the second aspect.
[0028] As can be seen, in at least one embodiment of this disclosure, by acquiring the color data of each pixel in the target image used to create the map, and using the color data of each pixel to remove interfering pixels with excessively high or low saturation, the target pixels used to extract the theme color do not affect the overall visual effect of the map, and ultimately make the theme colors of different map elements visually coordinated. In addition, by determining that the number of theme colors to be extracted from the image is greater than the number of map element categories in the map to be created, it is easier to select image theme colors that are more in line with the color matching characteristics of the map scene for the map elements. Attached Figure Description
[0029] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings.
[0030] Figure 1 A schematic flowchart illustrating an image theme color extraction method provided in this embodiment of the disclosure;
[0031] Figure 2 This is a schematic diagram of a process for removing interfering pixels provided in an embodiment of the present disclosure;
[0032] Figure 3 This is a schematic diagram of another process for removing interfering pixels provided in an embodiment of the present disclosure;
[0033] Figure 4 This is a schematic diagram of a process for extracting the theme color corresponding to the number of theme colors from a target image, provided in an embodiment of the present disclosure.
[0034] Figure 5 A flowchart illustrating a method for creating a map based on an image, as provided in an embodiment of this disclosure;
[0035] Figure 6 A flowchart illustrating a method for determining the color corresponding to a map feature category, as provided in this embodiment of the disclosure;
[0036] Figure 7 and Figure 8 A schematic diagram of a map created based on two different styles of images;
[0037] Figure 9 A block diagram of an image theme color extraction device provided in an embodiment of this disclosure;
[0038] Figure 10 A block diagram of an image-based map creation apparatus provided in an embodiment of this disclosure;
[0039] Figure 11 An exemplary block diagram of a computer device provided in an embodiment of this disclosure. Detailed Implementation
[0040] To better understand the above-described objectives, features, and advantages of this disclosure, the present disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. It is to be understood that the described embodiments are only some, not all, of the embodiments of this disclosure. The specific embodiments described herein are merely for explaining this disclosure and are not intended to limit it. All other embodiments obtained by those skilled in the art based on the described embodiments of this disclosure are within the scope of protection of this disclosure.
[0041] It should be noted that in this article, relational terms such as “first” and “second” are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0042] In some related technologies, users use the theme color extracted from the image to configure the colors of various map elements. One way to extract the theme color from the image is to extract the pixel colors of the image based on the median segmentation method of the RGB (Red, Green, Blue) color space. Here, the color space is the way of organizing colors. The RGB color space is based on the three basic colors R (Red), G (Green), and B (Blue), and other colors are produced by superimposing them to different degrees.
[0043] The median segmentation method based on the RGB color space is essentially a color quantization method for images. Specifically, a spatial rectangular coordinate system is constructed with R, G, and B axes. Based on the color of each pixel in the image, each pixel in the image is distributed into this spatial rectangular coordinate system, resulting in a cuboid containing all the pixels in the image. Then, the longest side of the cuboid is cut in half, resulting in two cuboids containing the same number of pixels. The longest side of the cuboid is then cut in half again, and the segmentation steps are repeated until the number of cuboids obtained by segmentation equals the number of theme colors in the image, and the number of theme colors is the same as the number of map feature categories. Finally, for each cuboid, the color of the pixel closest to the center point of the cuboid or the average color of all pixels in the cuboid is taken as the theme color of the cuboid.
[0044] However, the median segmentation method based on the RGB color space is prone to problems of excessively high or low color saturation because image colors are described in the RGB color space. Saturation refers to the vividness of a color; the higher the saturation, the more vibrant the color, and the lower the saturation, the more muted the color. Therefore, excessively high or low color saturation will affect the overall visual effect of the map and cause visual disharmony. Furthermore, the number of extracted image theme colors is the same as the number of map element categories, with one image theme color corresponding to one map element category, without considering color brightness. Brightness refers to the lightness of a color and can express the user's emotions. Excessive brightness can produce a feeling of excitement, while excessive brightness can produce a feeling of depression. Therefore, there is a problem that the color scheme of the image theme color does not match the color characteristics of the corresponding map element category in the map scene. For example, the color scheme of water features is characterized by high brightness and non-depressing, but the image theme color corresponding to water features has low brightness and is relatively depressing.
[0045] To address some or all of the problems existing in the prior art, this disclosure proposes a method for extracting image theme colors for custom maps, a method and apparatus for creating maps based on images, and other related solutions. By extracting theme colors suitable for the map scene from the image, the theme colors can be applied to the display of map elements. Since interference pixels with excessively high or low saturation are removed, the overall visual effect of the map is not affected, ultimately achieving visual harmony between the theme colors of different map elements. Furthermore, by determining that the number of image theme colors extracted is greater than the number of map element categories in the map to be created, it is easier to select image theme colors that better match the color scheme characteristics of the map scene for the map elements. In addition, when applying theme colors to the display of map elements, the mapping between theme colors and map elements can be achieved without user intervention, which improves configuration efficiency compared to users configuring map elements one by one.
[0046] Figure 1This is a flowchart illustrating an image theme color extraction method provided in an embodiment of this disclosure. This image theme color extraction method is a key technology for realizing the image-based map creation function in a custom map platform. The execution subject of this image theme color extraction method is an electronic device, including but not limited to smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, servers, etc. The server can be a standalone server or a cluster of multiple servers, and can include locally installed servers and cloud-based servers.
[0047] like Figure 1 As shown, the image theme color extraction method may include, but is not limited to, steps 101 to 104:
[0048] In step 101, the color data of each pixel in the target image used to create the map is obtained.
[0049] In this embodiment of the disclosure, the custom map platform can provide a map customization interface to the user, which includes an image upload control (e.g., an "Upload Image" button). The user opens the map customization interface using a browser on their front-end device. After triggering the image upload control in the map customization interface, the user can upload a target image for map creation to the custom map platform. The back-end server of the custom map platform then receives the uploaded target image, which can be displayed in the map customization interface.
[0050] In this embodiment of the disclosure, the color data of each pixel in the target image used to create the map can be obtained through the getImageData method of the Canvas tag in Hyper Text Markup Language 5.0 (HTML5), such as the RGB data of each pixel. In some embodiments, the color data of each pixel in the target image used to create the map can also be obtained through other existing methods, such as obtaining the color data of the pixels through the Unity engine (a real-time 3D interactive content creation tool); or, for example, obtaining the color data of the pixels through the GetPixel method of the Bitmap object in the C# programming language.
[0051] In step 102, based on the color data of each pixel in the target image, interfering pixels in the target image are removed to obtain multiple target pixels for extracting the theme color; wherein the saturation of the target pixels is within a preset saturation range.
[0052] In this embodiment, pixels with saturation levels higher than the upper limit of a preset saturation range are identified as interference pixels with excessively high saturation; pixels with saturation levels lower than the lower limit of the preset saturation range are identified as interference pixels with excessively low saturation. The upper and lower limits of the preset saturation range can be fixed values, meaning the preset saturation range remains constant for different images. In other embodiments, the upper and lower limits of the preset saturation range can be non-fixed values, meaning the preset saturation range differs for different images. For any given image, the upper and lower limits of the preset saturation range can be determined based on the saturation of each pixel in the image. For example, if an image contains 100 pixels, these 100 pixels are sorted in ascending order of saturation. The top 10 and bottom 10 pixels by saturation are identified as pixels outside the saturation range. The saturation of the 11th pixel is then determined as the lower limit of the saturation range, and the saturation of the 90th pixel is determined as the upper limit of the saturation range.
[0053] In this embodiment, considering that existing image theme color extraction methods, such as the median segmentation method based on the RGB color space, are prone to problems of excessively high or low color saturation, which affects the overall visual effect of the map, this embodiment removes interference pixels with excessively high or low saturation from the target image after obtaining the color data of each pixel in the target image used to create the map, so as to avoid the impact of these interference pixels on the overall visual effect of the map.
[0054] In step 103, the number of theme colors to be extracted from the image is determined based on the number of categories of map features in the map to be created; wherein the number of theme colors is greater than the number of categories.
[0055] In this embodiment of the disclosure, map elements are the elements that make up a map. A map may include at least one map element category. The map element category includes, but is not limited to, at least one of the following: roads, land, buildings, water systems (e.g., rivers, lakes, etc.), and markings. Among them, markings include ground markings and above-ground markings. Ground markings include, but are not limited to, ground elements such as directional arrows, lane lines, stop lines, and ground text. Above-ground markings include, but are not limited to, above-ground elements such as signs and speed cameras.
[0056] In this embodiment, considering existing image theme color extraction methods, such as the median segmentation method based on the RGB color space, the number of extracted theme colors is the same as the number of map feature categories, meaning one map feature category corresponds to one image theme color. This may lead to a mismatch between the image theme color and the color scheme characteristics of the corresponding map feature category in the map scene. For example, the color scheme of water features is characterized by high brightness and a non-depressing feel, but the corresponding image theme color for water features has low brightness and is relatively depressing. Therefore, in this embodiment, the number of extracted image theme colors is determined to be greater than the number of map feature categories, which facilitates the selection of image theme colors that better match the color scheme characteristics of the map scene for the map features.
[0057] In step 104, the theme color corresponding to the number of theme colors is extracted from the target image based on the number of theme colors and the color data of multiple target pixels.
[0058] In this embodiment of the disclosure, after determining the number of theme colors, the colors of the target image are quantized using the color data of multiple target pixels, such as RGB data. Each quantized value is a theme color, and finally multiple theme colors are obtained. The number of multiple theme colors is the number of theme colors determined in advance.
[0059] As can be seen, this embodiment of the present disclosure obtains the color data of each pixel in the target image used to create the map, and uses this color data to remove interfering pixels with excessively high or low saturation. This ensures that the target pixels used to extract the theme color do not affect the overall visual effect of the map, ultimately achieving visual harmony between the theme colors of different map elements. Furthermore, by determining that the number of theme colors to be extracted from the image is greater than the number of map element categories in the map to be created, it is easier to select image theme colors that better match the color scheme characteristics of the map scene. In addition, when applying the theme color to the display of map elements, the mapping between the theme color and map elements can be achieved without user intervention, improving configuration efficiency compared to users configuring map elements one by one.
[0060] Based on the above embodiments, Figure 1 One implementation of step 102, "Based on the color data of each pixel in the target image, remove interfering pixels in the target image to obtain multiple target pixels for extracting the theme color," is as follows: Figure 2 The flowchart shown includes, but is not limited to, steps 201 to 203, the process for removing interfering pixels.
[0061] In step 201, the color data of each pixel in the target image is converted from the RGB color space to the HSL color space to obtain the saturation of each pixel in the target image.
[0062] In this embodiment, the HSL color space describes color using three dimensions: H (Hue), S (Saturation), and L (Lightness). Converting from the RGB color space to the HSL color space is a mature technology in image processing and will not be elaborated further.
[0063] In step 202, a saturation range is determined based on the saturation of each pixel in the target image. The ratio between the number of pixels with saturation higher than the upper limit of the saturation range and the total number of pixels in the target image is a preset first ratio, and the ratio between the number of pixels with saturation lower than the lower limit of the saturation range and the total number of pixels in the target image is a preset second ratio.
[0064] In this embodiment, the first ratio and the second ratio can be the same or different. For example, both the first ratio and the second ratio are 10%, thereby sorting the saturation of each pixel in the target image in descending or ascending order, and determining the top 10% and bottom 10% of pixels by saturation as non-target pixels. For example, if there are 100 pixels, these 100 pixels are sorted in ascending order of saturation, the top 10 and bottom 10 pixels by saturation are determined as non-target pixels, and the saturation of the 11th pixel is determined as the lower limit of the saturation range, and the saturation of the 90th pixel is determined as the upper limit of the saturation range.
[0065] In step 203, pixels with saturation levels within the saturation range are identified as target pixels for extracting the theme color.
[0066] In this embodiment of the disclosure, pixels with saturation higher than the upper limit of the saturation range are defined as pixels with excessively high saturation, and pixels with saturation lower than the lower limit of the saturation range are defined as pixels with excessively low saturation. Pixels with excessively high and low saturation are discarded, and the remaining pixels are the target pixels for extracting the theme color.
[0067] Based on the above embodiments, Figure 1 Before step 102, "removing interfering pixels from the target image based on the color data of each pixel in the target image," the image theme color extraction method may also include the following steps:
[0068] Based on the color data of each pixel in the target image, multiple pixels whose colors can be used for map feature color matching are determined, and the color data of multiple pixels whose colors can be used for map feature color matching are all within a preset color data range.
[0069] In this embodiment, some pixels in the target image have colors that cannot be used for map element color matching. For example, pure black or near-pure black pixels and pure white or near-pure white pixels cannot be used for map element color matching. Pure black has RGB data of (0,0,0), and pure white has RGB data of (255,255,255). In this embodiment, pixels with RGB data between (0,0,0) and (45,45,45) are considered near-pure black pixels; pixels with RGB data between (235,235,235) and (255,255,255) are considered near-pure white pixels. Therefore, the preset color data range in this embodiment is (46,46,46) to (234,234,234), and pixel colors within this range can be used for map element color matching. It should be noted that those skilled in the art can set the color data range according to actual needs; this embodiment does not limit the specific values of the color data range.
[0070] In this embodiment of the disclosure, before removing interfering pixels from the target image, pixels whose colors cannot be used for map element color matching are first removed, resulting in multiple pixels whose colors can be used for map element color matching. Then, interfering pixels are removed from these multiple pixels. It should be noted that the colors of the interfering pixels can be used for map element color matching; however, if the saturation of the interfering pixels is too high or too low, it will affect the overall visual effect of the map. Accordingly, Figure 1 One implementation of step 102, "Based on the color data of each pixel in the target image, remove interfering pixels in the target image to obtain multiple target pixels for extracting the theme color," is as follows: Based on the color data of multiple pixels whose pixel colors can be used for map feature color matching, remove interfering pixels from the multiple pixels to obtain multiple target pixels for extracting the theme color, including but not limited to, such as... Figure 3 Steps 301 to 303 are shown below:
[0071] In step 301, the color data of multiple pixels whose pixel colors can be used for map feature color matching are converted from the RGB color space to the HSL color space to obtain the saturation of the multiple pixels.
[0072] In step 302, a saturation range is determined based on the saturation of the plurality of pixels. The ratio between the number of pixels with saturation higher than the upper limit of the saturation range and the total number of pixels is a preset first ratio, and the ratio between the number of pixels with saturation lower than the lower limit of the saturation range and the total number of pixels is a preset second ratio.
[0073] In this embodiment, the first ratio and the second ratio can be the same or different. For example, both the first ratio and the second ratio are 10%. This allows the saturation of multiple pixels whose color can be used for map element color matching to be sorted in descending or ascending order, and the pixels in the top 10% and bottom 10% of the saturation ranking are determined as non-target pixels. For example, if there are 80 pixels, these 80 pixels are sorted in ascending order of saturation. The top 8 and bottom 8 pixels are determined as non-target pixels, and the saturation of the 9th pixel in the ranking is determined as the lower limit of the saturation range, and the saturation of the 72nd pixel in the ranking is determined as the upper limit of the saturation range.
[0074] In step 303, pixels with saturation levels within the saturation range are identified as target pixels for extracting the theme color.
[0075] In this embodiment of the disclosure, pixels with saturation higher than the upper limit of the saturation range are defined as pixels with excessively high saturation, and pixels with saturation lower than the lower limit of the saturation range are defined as pixels with excessively low saturation. Pixels with excessively high and low saturation are discarded, and the remaining pixels are the target pixels for extracting the theme color.
[0076] Based on the above embodiments, Figure 1 Step 104, "based on the number of theme colors and the color data of multiple target pixels, extracts the theme colors corresponding to the number of theme colors from the target image," includes, but is not limited to, such as... Figure 4 Steps 401 to 403 are shown below:
[0077] In step 401, based on the color data of multiple target pixels, the distribution of multiple target pixels in the coordinate system of the RGB color space is determined, resulting in a first cuboid containing multiple target pixels.
[0078] In step 402, the longest side of the first cuboid is cut in half to obtain two second cuboids containing the same number of pixels; the longest side of the second cuboid is cut in half, and the cutting steps are repeated until the number of cuboids obtained by cutting is equal to the number of theme colors.
[0079] For example, the first cuboid is divided into two second cuboids, denoted as cuboid A and cuboid B. The length, width, and height of cuboid A are 3, 2, and 1 respectively; the length, width, and height of cuboid B are 4, 1, and 1 respectively. Then, the second cuboid with the longest side is cuboid B, and the length of the longest side is 4. Cut cuboid B in half along its longest side to get two third cuboids containing the same number of pixels. Cut the longest side of the third cuboid in half again, and repeat the cutting steps until the number of cuboids obtained is equal to the number of theme colors.
[0080] In step 403, for each cuboid obtained by segmentation, the theme color corresponding to the cuboid is determined based on the color data of each target pixel in the cuboid.
[0081] In this embodiment of the disclosure, based on the color data of each target pixel in the cuboid, the color of the target pixel closest to the center point of the cuboid or the average color of all target pixels in the cuboid is taken as the theme color of the cuboid.
[0082] It should be noted that extracting the theme color corresponding to the number of theme colors from the target image is essentially a color quantization method for images. Those skilled in the art can use other color quantization methods to extract the theme color corresponding to the number of theme colors from the target image. For example, the octree quantization method can be used to extract the theme color corresponding to the number of theme colors from the target image. The octree quantization method is a mature technology in the field of image processing and will not be elaborated further.
[0083] As can be seen, the image theme color extraction method disclosed in at least one embodiment of this disclosure obtains the color data of each pixel in the target image used to create the map, and uses the color data of each pixel to remove interference pixels with excessively high or low saturation, so that the target pixels used to extract the theme color do not affect the overall visual effect of the map, and ultimately make the theme colors of different map elements visually coordinated; in addition, by determining that the number of image theme colors to be extracted is greater than the number of map element categories in the map to be created, it is easier to select image theme colors that are more in line with the color matching characteristics of the map scene for the map elements.
[0084] Based on the aforementioned image theme color extraction method Figure 5This is a flowchart illustrating a method for creating a map based on an image, provided in an embodiment of this disclosure. The execution subject of this method is an electronic device, including but not limited to smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, servers, etc. The server can be an independent server or a cluster of multiple servers, and can include servers built locally and servers set up in the cloud.
[0085] like Figure 5 As shown, the method for creating a map based on an image may include, but is not limited to, steps 501 to 503:
[0086] In step 501, the target image for creating the map is obtained.
[0087] In this embodiment of the disclosure, the custom map platform can provide a map customization interface to the user, which includes an image upload control (e.g., an "Upload Image" button). The user opens the map customization interface using a browser on their front-end device. After triggering the image upload control in the map customization interface, the user can upload a target image for map creation to the custom map platform. The back-end server of the custom map platform then receives the uploaded target image, which can be displayed in the map customization interface.
[0088] In step 502, based on the number of categories of map features in the map to be created, multiple theme colors are extracted from the target image using the aforementioned image theme color extraction method, wherein the number of theme colors is greater than the number of categories.
[0089] In this embodiment of the disclosure, the categories of map elements include, but are not limited to, roads, land, buildings, water features and labels. Taking the five categories of roads, land, buildings, water features and labels as an example, the number of theme colors extracted is 5×N, where N is a positive integer greater than 2. It should be noted that the number of theme colors only needs to be greater than the number of categories. This embodiment does not limit the specific relationship between the number of theme colors and the number of categories.
[0090] In this embodiment of the disclosure, since the number of theme colors is greater than the number of categories of map elements, it is easier to select image theme colors for map elements that are more in line with the color scheme characteristics of the map scene.
[0091] In step 503, the color corresponding to each map feature category in the map to be created is determined based on multiple theme colors.
[0092] In this embodiment of the disclosure, multiple theme colors can be converted from the RGB color space to the HSL color space to obtain the brightness corresponding to each theme color; then, based on the multiple theme colors and the brightness corresponding to each theme color, the color corresponding to each map element category in the map to be created is determined.
[0093] As can be seen, in this embodiment of the disclosure, the brightness corresponding to the theme color is considered. Brightness refers to the lightness of a color and can express the user's emotions. Therefore, determining the color corresponding to the map element category based on the brightness corresponding to the theme color can make the map element category match the color characteristics in the map scene. For example, the color characteristics of water system elements are high brightness and not oppressive. Based on the brightness corresponding to the theme color, a theme color with high brightness can be configured for water system elements.
[0094] In addition, in this embodiment of the disclosure, when the theme color is applied to the display of map elements, the mapping between the theme color and map elements can be achieved without user intervention, which can improve configuration efficiency compared to users configuring map elements one by one.
[0095] Based on the above embodiments, the color corresponding to each map feature category in the map to be created is determined based on multiple theme colors and the brightness corresponding to each theme color, including, for example... Figure 6 Steps 601 to 603 are shown below:
[0096] In step 601, the brightness corresponding to each theme color is sorted to obtain a brightness sequence.
[0097] In step 602, based on the preset relative brightness relationship between different map element categories, the brightness corresponding to each map element category is selected from the brightness sequence.
[0098] In this embodiment of the disclosure, considering that the target images uploaded by users for creating maps may have different styles, resulting in different ranges of brightness variation for multiple theme colors extracted from the target images, in order to select theme colors that conform to the color matching characteristics in the map scene from image theme colors of different styles, the relative brightness relationship between different map element categories can be preset.
[0099] In some embodiments, different map element categories can be first divided into two main categories: a first category with lower brightness and a second category with higher brightness. For example, roads, land, and buildings are classified into the first category with lower brightness to highlight the solidity and depth of these map elements, while water features and labels are classified into the second category with higher brightness to highlight the dynamism and brightness of these map elements. Then, the relative brightness relationship between these two categories is set. For example, the maximum brightness in the first category is 20% lower than the minimum brightness in the second category. Next, the relative brightness relationship between different map element categories within the same category is set. For example, in the first category, the brightness of roads is 10% lower than that of land, and the brightness of land is 5% lower than that of buildings. It should be noted that those skilled in the art can configure the relative brightness relationship between different map element categories according to actual needs.
[0100] In step 603, for any map feature category, the theme color corresponding to the brightness is determined as the color corresponding to the map feature category.
[0101] In this embodiment of the disclosure, after determining the color corresponding to the map feature category, the color corresponding to the map feature category can be used to render the colors of different map features under the same map feature category in the map, thereby generating a map with a style similar to the target image.
[0102] For example, Figure 7 and Figure 8 The image is a schematic diagram of a map created based on two different styles of images. It can be seen that regardless of the style of the images, the created map is visually harmonious as a whole and conforms to the color scheme characteristics of the map scene.
[0103] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art will understand that the embodiments of this disclosure are not limited to the described order of actions, because according to the embodiments of this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art will understand that the embodiments described in the specification are all optional embodiments.
[0104] Figure 9 This is a schematic diagram of an image theme color extraction device provided in an embodiment of this disclosure. This device can be applied to electronic devices, including but not limited to smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, and servers. The server can be a standalone server or a cluster of multiple servers, and can include locally located servers and cloud-based servers. The image theme color extraction device provided in this embodiment can execute the processing flow provided in various embodiments of the image theme color extraction method, such as... Figure 9As shown, the image theme color extraction device includes: an acquisition unit 91, a rejection unit 92, a determination unit 93, and an extraction unit 94.
[0105] Acquisition unit 91 is used to acquire the color data of each pixel in the target image used to create the map;
[0106] The elimination unit 92 is used to eliminate interfering pixels in the target image based on the color data of each pixel in the target image, so as to obtain multiple target pixels for extracting the theme color; wherein the saturation of the target pixels is within a preset saturation range.
[0107] The determining unit 93 is used to determine the number of theme colors to be extracted from the image based on the number of categories of map features in the map to be created; wherein the number of theme colors is greater than the number of categories;
[0108] Extraction unit 94 is used to extract the theme color corresponding to the number of theme colors from the target image based on the number of theme colors and the color data of multiple target pixels.
[0109] In some embodiments, the elimination unit 92 is further configured to: determine multiple pixels whose pixel colors can be used for map feature color matching based on the color data of each pixel in the target image, wherein the color data of the multiple pixels are all within a preset color data range; accordingly, the elimination unit 92 eliminates interfering pixels among the multiple pixels based on the color data of the multiple pixels whose pixel colors can be used for map feature color matching.
[0110] In some embodiments, the rejection unit 92 is configured to:
[0111] The color data of each pixel in the target image is converted from the RGB color space to the HSL color space to obtain the saturation of each pixel in the target image;
[0112] Based on the saturation of each pixel in the target image, a saturation range is determined. The ratio between the number of pixels with saturation higher than the upper limit of the saturation range and the number of pixels in the target image is a preset first ratio, and the ratio between the number of pixels with saturation lower than the lower limit of the saturation range and the number of pixels in the target image is a preset second ratio.
[0113] Pixels with saturation levels within the specified range are identified as target pixels for extracting the theme color.
[0114] In some embodiments, the extraction unit 94 is configured to:
[0115] Based on the color data of multiple target pixels, the distribution of multiple target pixels in the coordinate system of the RGB color space is determined, resulting in a first cuboid containing multiple target pixels;
[0116] Cut the longest side of the first cuboid in half to get two second cuboids containing the same number of pixels; cut the longest side of the second cuboid in half again, and repeat the cutting steps until the number of cuboids obtained by cutting is equal to the number of theme colors.
[0117] For each cuboid obtained from the segmentation, the theme color corresponding to the cuboid is determined based on the color data of each target pixel in the cuboid.
[0118] For details of the various embodiments of the image theme color extraction device disclosed above, please refer to the details of the various embodiments of the image theme color extraction method described above. To avoid repetition, they will not be repeated.
[0119] Figure 10 This is a schematic diagram of an image-based map creation apparatus provided in this disclosure. This apparatus can be applied to electronic devices, including but not limited to smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, and servers. The server can be a standalone server or a cluster of multiple servers, and can include locally located servers and cloud-based servers. The image-based map creation apparatus provided in this disclosure can execute the processing flows provided in various embodiments of the image-based map creation method, such as... Figure 10 As shown, the device for creating a map based on an image includes: an acquisition unit 1001, an extraction unit 1002, a determination unit 1003, and a creation unit 1004.
[0120] Acquisition unit 1001 is used to acquire the target image for creating a map;
[0121] Extraction unit 1002 is used to extract multiple theme colors from the target image based on the number of categories of map features in the map to be created, using an image theme color extraction method, wherein the number of theme colors is greater than the number of categories;
[0122] The determination unit 1003 is used to determine the color corresponding to each map feature category in the map to be created based on multiple theme colors;
[0123] Create cell 1004 to create a map based on the color corresponding to each map feature category.
[0124] In some embodiments, the determining unit 1003 includes:
[0125] The conversion subunit is used to convert multiple theme colors from the RGB color space to the HSL color space to obtain the brightness of each theme color.
[0126] Determine sub-cells, which are used to determine the color corresponding to each map feature category in the map to be created based on multiple theme colors and the brightness corresponding to each theme color.
[0127] In some embodiments, determining a subunit is used for:
[0128] Sort the brightness levels corresponding to each theme color to obtain a brightness sequence;
[0129] Based on the preset relative brightness relationships between different map element categories, the brightness corresponding to each map element category is selected from the brightness sequence;
[0130] For any map feature category, the theme color corresponding to that brightness is determined as the color corresponding to that map feature category.
[0131] For details of the embodiments of the image-based map creation apparatus disclosed above, please refer to the details of the embodiments of the image-based map creation method described above. To avoid repetition, these details will not be repeated.
[0132] Figure 11 This is an exemplary block diagram of a computer device provided in an embodiment of this disclosure. Figure 11 As shown, the computer device includes: at least one computing device 1101 and at least one storage device 1102 for storing instructions. It is understood that the storage device 1102 in this embodiment may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
[0133] In some implementations, storage device 1102 stores elements such as executable modules or data structures, or subsets thereof, or extended sets thereof: operating systems and applications.
[0134] The operating system includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic tasks and handle hardware-based tasks. The application programs include various applications, such as media players and browsers, used to implement various application tasks. The program implementing the image theme color extraction method or the image-based map creation method provided in the embodiments of this disclosure can be included in the application programs.
[0135] In this embodiment of the disclosure, at least one computing device 1101 executes the steps of the image theme color extraction method or the image-based map creation method provided in this embodiment of the disclosure by calling a program or instruction stored in at least one storage device 1102, specifically, a program or instruction stored in an application.
[0136] The image theme color extraction method or the image-based map creation method provided in this disclosure can be applied to or implemented by the computing device 1101. The computing device 1101 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the hardware or by instructions in software within the computing device 1101. The computing device 1101 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor.
[0137] The steps of the image theme color extraction method or the image-based map creation method provided in this disclosure can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in storage device 1102, and computing device 1101 reads the information in storage device 1102 and combines it with hardware to complete the steps of the method.
[0138] This disclosure also proposes a computer-readable storage medium storing a program or instructions that cause a computer to perform steps, such as those in embodiments of an image theme color extraction method or an image-based map creation method, which will not be repeated here to avoid repetition. The computer-readable storage medium can be a non-transitory computer-readable storage medium.
[0139] This disclosure also proposes a computer program product, wherein the computer program product includes a computer program stored in a non-transitory computer-readable storage medium, and at least one processor of a computer reads from the storage medium and executes the computer program, causing the computer to perform steps such as those of the image theme color extraction method or the image-based map creation method, which will not be repeated here to avoid repetition.
[0140] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0141] Those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of this disclosure and form different embodiments.
[0142] Those skilled in the art will understand that the descriptions of the various embodiments have different focuses, and for parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0143] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and all such modifications and variations fall within the scope defined by the appended claims.
Claims
1. A method for extracting the theme color of an image, the method comprising: Obtain the color data of each pixel in the target image used to create the map; Based on the color data of each pixel in the target image, interfering pixels in the target image are removed to obtain multiple target pixels for extracting the theme color; wherein the saturation of the target pixels is within a preset saturation range; Based on the number of categories of map features in the map to be created, determine the number of theme colors to be extracted from the image; wherein, the number of theme colors is greater than the number of categories; Based on the number of theme colors and the color data of the plurality of target pixels, extract the theme color corresponding to the number of theme colors from the target image; The step involves removing interfering pixels from the target image based on the color data of each pixel, resulting in multiple target pixels used to extract the theme color, including: The color data of each pixel in the target image is converted from the RGB color space to the HSL color space to obtain the saturation of each pixel in the target image; Based on the saturation of each pixel in the target image, the saturation range is determined. The saturation of each pixel in the target image is sorted in descending or ascending order. The ratio between the number of pixels with saturation higher than the upper limit of the saturation range and the number of pixels in the target image is a preset first ratio. The ratio between the number of pixels with saturation lower than the lower limit of the saturation range and the number of pixels in the target image is a preset second ratio. Pixels whose saturation falls within the saturation range are identified as target pixels for extracting the theme color.
2. The method according to claim 1, wherein, Before removing interfering pixels from the target image based on the color data of each pixel in the target image, the method further includes: Based on the color data of each pixel in the target image, multiple pixels whose colors can be used for map feature color matching are determined, and the color data of the multiple pixels are all within a preset color data range; The step of removing interfering pixels from the target image based on the color data of each pixel in the target image includes: Based on the color data of multiple pixels that can be used for map feature color matching, interference pixels are removed from these multiple pixels.
3. The method according to claim 1, wherein, The step of extracting the theme color corresponding to the number of theme colors from the target image based on the number of theme colors and the color data of the multiple target pixels includes: Based on the color data of the multiple target pixels, the distribution of the multiple target pixels in the coordinate system of the RGB color space is determined, and a first cuboid containing the multiple target pixels is obtained. Cut the longest side of the first cuboid in half to obtain two second cuboids containing the same number of pixels; cut the longest side of the second cuboid in half again, and repeat the cutting step until the number of cuboids obtained by cutting is equal to the number of theme colors. For each cuboid obtained by segmentation, the theme color corresponding to the cuboid is determined based on the color data of each target pixel in the cuboid.
4. A method for creating a map based on an image, the method comprising: Obtain the target image used to create the map; Based on the number of categories of map elements in the map to be created, the image theme color extraction method according to any one of claims 1 to 3 is used to extract multiple theme colors from the target image, wherein the number of theme colors is greater than the number of categories; The color corresponding to each map feature category in the map to be created is determined based on multiple theme colors; A map is created based on the color corresponding to each map feature category.
5. The method according to claim 4, wherein, The process of determining the color corresponding to each map feature category in the map to be created based on multiple theme colors includes: The multiple theme colors are converted from the RGB color space to the HSL color space to obtain the brightness corresponding to each theme color; Based on the multiple theme colors and the brightness corresponding to each theme color, the color corresponding to each map element category in the map to be created is determined.
6. The method according to claim 5, wherein, The step of determining the color corresponding to each map feature category in the map to be created based on the multiple theme colors and the brightness corresponding to each theme color includes: Sort the brightness corresponding to each theme color to obtain a brightness sequence; Based on the preset relative brightness relationships between different map element categories, the brightness corresponding to each map element category is selected from the brightness sequence; For any map element category, the theme color corresponding to that brightness is determined as the color corresponding to that map element category.
7. An image theme color extraction device, the device comprising: The acquisition unit is used to acquire the color data of each pixel in the target image used to create the map. The elimination unit is used to eliminate interfering pixels in the target image based on the color data of each pixel in the target image, so as to obtain multiple target pixels for extracting the theme color; wherein the saturation of the target pixels is within a preset saturation range; The determining unit is used to determine the number of theme colors to be extracted from the image based on the number of categories of map features in the map to be created; wherein the number of theme colors is greater than the number of categories; The extraction unit is configured to extract the theme color corresponding to the number of theme colors from the target image based on the number of theme colors and the color data of the plurality of target pixels; The step involves removing interfering pixels from the target image based on the color data of each pixel, resulting in multiple target pixels used to extract the theme color, including: The color data of each pixel in the target image is converted from the RGB color space to the HSL color space to obtain the saturation of each pixel in the target image; Based on the saturation of each pixel in the target image, the saturation range is determined. The saturation of each pixel in the target image is sorted in descending or ascending order. The ratio between the number of pixels with saturation higher than the upper limit of the saturation range and the number of pixels in the target image is a preset first ratio. The ratio between the number of pixels with saturation lower than the lower limit of the saturation range and the number of pixels in the target image is a preset second ratio. Pixels whose saturation falls within the saturation range are identified as target pixels for extracting the theme color.
8. An apparatus for creating maps based on images, the apparatus comprising: The acquisition unit is used to acquire the target image for creating the map. An extraction unit is configured to extract multiple theme colors from the target image based on the number of categories of map features in the map to be created, using the image theme color extraction method according to any one of claims 1 to 3, wherein the number of theme colors is greater than the number of categories; A determining unit is used to determine the color corresponding to each map feature category in the map to be created based on multiple theme colors; A creation unit is used to create a map based on the color corresponding to each map feature category.
9. A computer device, wherein, The device includes at least one computing device and at least one storage device for storing instructions; when the instructions are executed by the at least one computing device, they cause the at least one computing device to perform the steps of the image theme color extraction method as described in any one of claims 1 to 3 or the steps of the image-based map creation method as described in any one of claims 4 to 6.
10. A computer-readable storage medium, wherein, The computer-readable storage medium stores a program or instructions that cause a computer to perform the steps of the image theme color extraction method as described in any one of claims 1 to 3 or the steps of the image-based map creation method as described in any one of claims 4 to 6.
Citation Information
Patent Citations
Page template generation method and device, electronic equipment and storage medium
CN115248685A
Theme color determination method, picture display method and model training method and device
CN115439661A
