Map color matching method and system based on image color feature extraction
By using a map color matching method based on image color feature extraction, map color schemes are automatically generated, solving the customization problem of users' personalized needs in map drawing, realizing automated adjustment and rapid response of map color style, and improving map drawing efficiency and flexibility.
Patent Information
- Application Number
- CN202510815505.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-11-18
AI Technical Summary
Existing map-making technologies struggle to customize and automate map color styles to meet individual user needs, especially geographic information system platforms like Mapbox and ArcGIS, where manual configuration is cumbersome and inefficient.
By using a map color matching method based on image color feature extraction, user-uploaded images are acquired, their color distribution characteristics are analyzed, color matching modes and priority orders are determined, and map color schemes are automatically generated by combining map element categories. Real-time color matching is then achieved through the interface of the map service platform.
It enables customized and automated adjustment of map color styles, improving the efficiency and flexibility of map color matching, quickly responding to users' personalized style needs, and supporting rapid updates of map color styles.
Smart Images

Figure CN120976333A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of map drawing and computer graphics, in particular to a map color matching method and system based on image color feature extraction. BACKGROUND
[0002] In the field of map drawing, map color matching is crucial for information transmission, visual expression effect and user experience. In the traditional map drawing process, map color matching usually relies on pre-set fixed style templates or general color boards. Although such methods have certain universality in standardized mapping scenarios, they often lack flexibility and expression in the face of user personalized needs and diversified application scenarios, making it difficult to achieve customized adjustment of map color style.
[0003] Currently, some mainstream geographic information system (GIS) platforms, such as Mapbox, ArcGIS and Google Maps, have provided map style editing functions, allowing users to manually configure style parameters such as color, line type and transparency of map layers. However, this approach often relies on user manual operation, which is not only tedious and inefficient, but also has a high learning and usage threshold for non-professional users.
[0004] Taking Mapbox as an example, although it provides rich layer style API interfaces, users need to specify the color parameters of each layer one by one, and lacks the ability to automatically generate color matching schemes according to user's personalized style needs.
[0005] Therefore, it is urgent to provide a method that can automatically generate a map color matching scheme according to the user's personalized style needs and apply it to the map layer, so as to realize the customization and automatic dynamic adjustment of the map color style. SUMMARY
[0006] The present disclosure provides a map color matching method and system based on image color feature extraction, which can automatically generate a map color matching scheme according to the user's personalized style needs and apply it to the map layer, thereby realizing the customization and automatic dynamic adjustment of the map color style, greatly improving the efficiency and flexibility of map color matching.
[0007] In a first aspect, the present disclosure provides a map color matching method based on image color feature extraction, comprising: Step S1, obtaining an image uploaded by a user; Step S2, determining an image color matching mode based on the color distribution features of the image, the image color matching mode including a color matching type and a color matching priority order; Step S3, setting a map feature category priority, matching the extracted image color matching with the map feature categories one by one in priority order, and generating a map color matching mode; Step S4: calling a layer style configuration interface provided by the map service platform, and performing real-time color matching on the map based on a map color matching mode.
[0008] In some embodiments, the step S2 comprises: Step S21: traversing all pixel points in the image, and extracting color values and spatial coordinates of each pixel point; Step S22: performing cluster analysis on the color values of the pixel points extracted in step S21, generating a plurality of color clusters, each color cluster including all pixel points assigned to the cluster, and extracting a cluster center of the color cluster as a representative color of the color cluster; Step S23: determining whether the number of color clusters after clustering is not less than N, if yes, proceeding to step S24; if no, selecting a representative color of a color cluster with the largest spatial distribution proportion as a primary color system, and a representative color of a color cluster with the smallest spatial distribution proportion as an auxiliary color, to form a color matching type set of the image, setting the priority of the primary color system to be higher than that of the auxiliary color, generating an image color matching priority order, and then proceeding to step S3; Step S24: selecting color clusters with top N proportions according to spatial distribution proportions of the color clusters in the image, as target color clusters; and defining a set of representative colors of the target color clusters as a color matching type set of the image. Step S25: selecting a representative color of a target color cluster with the largest spatial distribution proportion as a primary color system, and selecting representative colors of the remaining target color clusters as auxiliary colors; obtaining an auxiliary color priority according to spatial distribution characteristics of the remaining target color clusters, setting the priority of the primary color system to be higher than that of any auxiliary color, and finally generating an image color matching priority order.
[0009] In some embodiments, the step S25 comprises: selecting a representative color of a target color cluster with the largest spatial distribution proportion as a primary color system, and selecting representative colors of the remaining target color clusters as auxiliary colors; calculating spatial distribution dispersion of each remaining target color cluster; calculating spatial shapes of discrete blocks in the remaining target color clusters; determining an auxiliary color priority order according to the dispersion and spatial shapes of the remaining target color clusters; setting the priority of the primary color system to be higher than that of any auxiliary color, and finally generating an image color matching priority order.
[0010] In some embodiments, the calculation of the spatial distribution dispersion of each remaining target color cluster comprises: performing DBSCAN clustering based on spatial coordinate data of pixel points of the current target color cluster, to obtain a plurality of discrete blocks; and the number of discrete blocks is the dispersion of the current target color cluster.
[0011] In some embodiments, the determining the priority of the auxiliary colors according to the dispersion and spatial shape of the remaining target color clusters comprises: obtaining the dispersion of each of the remaining target color clusters, and the total number of the rectangular and strip-shaped discrete blocks in the color cluster; arranging the priority of the auxiliary colors corresponding to the remaining target color clusters in ascending order of the dispersion; if the dispersion is the same, further comparing the total number of the rectangular and strip-shaped discrete blocks included in the color cluster, and assigning a higher priority to the auxiliary color corresponding to the color cluster with a larger total number of the rectangular and strip-shaped discrete blocks.
[0012] In some embodiments, the parameter N is the number of the map element categories.
[0013] In some embodiments, in step S22, the K-means clustering algorithm is used to generate a plurality of color clusters. In some embodiments, the setting the priority of the map element categories comprises: dividing the map elements into N different categories, setting the map element with the largest spatial distribution proportion as the highest priority, and setting the priority order of the remaining map element categories.
[0014] In some embodiments, the matching the extracted image color matching with the map element categories in the priority order to generate the map color matching mode comprises: if the number of the color clusters after clustering is not less than N, matching the color matching with the map element categories in the priority order to generate the map color matching mode; if the number of the color clusters after clustering is less than N, applying the primary color system to the map element category with the highest priority, and applying the same auxiliary color to the remaining map element categories.
[0015] In a second aspect, the present disclosure provides a map color matching system based on image color feature extraction, which is used to execute the map color matching method based on image color feature extraction, and has the following characteristics: an image acquisition module, configured to acquire an image uploaded by a user; an image color matching extraction module, configured to determine an image color matching mode based on the color distribution characteristics of the image, the image color matching mode comprising a color matching type and a color matching priority order; a map color matching determination module, configured to set the priority of the map element categories, and match the extracted image color matching with the map element categories in the priority order to generate the map color matching mode; a map color matching execution module, configured to use a layer style configuration interface provided by a map service platform, and perform real-time color matching on a map based on the map color matching mode.
[0016] The present disclosure has the following advantages compared with the prior art: 1. The present disclosure proposes a map color matching method and system based on image color feature extraction. Users only need to upload a style reference image, and the system can automatically extract image color feature information, determine the image color matching style, and render the color matching style of the image to the map layer by calling the layer style configuration interface provided by the map service platform, realizing fast response to map color matching. This process can automatically generate a map color matching scheme according to the user's personalized style requirements and apply it to the map layer, thereby realizing customized and automated adjustment of the map color style, and realizing fast update and switching of the map color matching style based on the switching of the style reference image, greatly improving the efficiency and flexibility of map color matching.
[0017] 2. The present disclosure provides an image color matching style determination method, which can quickly identify the main color type in the image by analyzing the color space distribution ratio. For images with relatively single color type, only the main color system and single auxiliary color system are selected to highlight the visual features of the overall simple style of the image. For images with relatively rich color types, the priority order of auxiliary color systems is determined by further combining the spatial distribution characteristics (i.e. texture characteristics) of different colors based on the identification of the main color system. This comprehensive analysis method takes into account the color ratio while also considering the spatial distribution characteristics of the colors, thereby more accurately capturing the color matching style of the image and ensuring that the map color matching scheme can highly restore the desired style effect of the user.
[0018] 3. Seamless docking is achieved through deep integration with the map service platform (e.g. Mapbox) API. Without changing the original map drawing architecture of the map service platform, the new color matching scheme can be conveniently applied to the map layer, and the extension of the map color style customization function can be realized only by simple configuration. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] Figure 1 A map color matching method based on image color feature extraction provided by an embodiment of the present disclosure; Figure 2 A method for extracting an image color matching mode provided by an embodiment of the present disclosure; Figure 3 A map color matching system based on image color feature extraction provided by an embodiment of the present disclosure.
[0021] The specific embodiments of the present disclosure have been shown by the above drawings, and will be described in more detail hereinafter. These drawings and the written description are not intended to restrict the scope of the present disclosure in any way, but to illustrate the concept of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0022] The present disclosure will be further described below in conjunction with the drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present disclosure, and cannot be used to limit the protection scope of the present disclosure.
[0023] Figure 1 is a flowchart of a map color matching method based on image color feature extraction provided according to an embodiment of the present disclosure.
[0024] As Figure 1 shown, the map color matching method based on image color feature extraction provided by the present embodiment can include: Step S1, obtaining an image uploaded by a user; The user can select a favorite style reference image and upload it to the system, and the system will automatically extract the color matching style of the image and generate real-time color matching of the map accordingly. The image can be in a common format, including standard image formats such as JPG, PNG, etc.
[0025] Step S2, determining an image color matching mode based on color distribution features of the image, the image color matching mode including a color matching type and a color matching priority order; Specifically, the image color matching mode is usually determined by two parts: one is the color matching type, i.e., a representative color set extracted from the image; the other is the color matching priority order, i.e., the visual importance ordering of each color matching type in the overall color matching scheme, for example, including identification and priority determination of the primary color system and the auxiliary color system.
[0026] In one embodiment, as Figure 2 shown, the step S2 includes the following steps: Step S21, traversing all pixel points in the image to extract color values and spatial coordinates of each pixel point; In a specific implementation, a Python image processing library is used to perform color extraction processing on the image. First, the image file at a specified path is loaded by using the cv2.imread() method in the OpenCV library, and each pixel point in the image is traversed to extract its color value and spatial coordinates (H, W) in the image, where H represents the vertical position of the pixel (image height direction), and W represents the horizontal position of the pixel (image width direction); the pixel origin coordinate is the origin coordinate (0, 0) of the upper left corner of the image.
[0027] The extracted pixel color values and pixel coordinate data are stored in the color_array variable, which is returned to the system as a result of the color extraction.
[0028] In step S22, the pixel color values extracted in step S21 are subjected to cluster analysis to generate a plurality of color clusters, each of which includes all the pixel points assigned to the cluster, and the cluster center of the color cluster is extracted as the representative color of the color cluster. Since a large number of similar colors can be generated in the color space of an image, the color types need to be "simplified". In this embodiment, the K-means clustering algorithm is used to classify similar colors to achieve rapid classification of colors. For the K-means clustering algorithm, the value of K is determined according to the number of color types to be extracted, and K is usually greater than N (representing the number of map element categories). Preferably, K = 10 is selected.
[0029] In a specific implementation, the color extraction result in step S21 is imported, and then K values in the color array are randomly selected as color cluster centers according to the set K value, and each center is also called a color cluster value. Using the OpenCV algorithm library, the cv2.kmeans() function is used for clustering operation, each pixel point is assigned to the cluster to which the color value is closest, and preliminary classification is formed.
[0030] The color mean value of each cluster is recalculated as a new cluster center, and the cv2.kmeans() calculation method is repeated until the cluster center variation of the two iteration clustering results is less than or equal to the convergence threshold or the maximum iteration number is reached.
[0031] If the difference between the cluster centers of the two iterations is less than the convergence threshold, it is considered that the clustering result has stabilized and does not need to be calculated continuously.
[0032] In step S23, it is determined whether the number of color clusters after clustering is not less than N, if yes, it is transferred to step S24; if not, the representative color of the color cluster with the largest spatial distribution ratio is selected as the primary color system, and the representative color of the color cluster with the smallest spatial distribution ratio is selected as the auxiliary color to form the color matching type set of the image, and the primary color system is set to have a higher priority than the auxiliary color, the image color matching priority order is generated, and then it is transferred to step S3. In step S24, according to the spatial distribution ratio of each color cluster in the image, the top N color clusters in the ratio are selected as target color clusters, and the set of representative colors of the target color clusters is defined as the color matching type set of the image.
[0033] In this embodiment, the parameter N represents the number of map element categories, and N = 5 is preferably selected. The spatial distribution ratio of a color cluster is defined as the ratio of the number of pixel points included in the color cluster to the total number of pixel points in the image.
[0034] Step S25, selecting the representative color of the target color cluster with the largest spatial distribution proportion as the main color system, and the representative colors of the remaining target color clusters as auxiliary colors; obtaining the auxiliary color priority according to the spatial distribution characteristics of the remaining target color clusters, setting the priority of the main color system to be higher than any auxiliary color, and finally generating the image color matching priority order. Specifically, the following steps are included: Step S251, selecting the representative color of the target color cluster with the largest spatial distribution proportion as the main color system, and the representative colors of the remaining target color clusters as auxiliary colors; Step S252, calculating the spatial distribution dispersion of each remaining target color cluster; Step S253, calculating the spatial shape of each discrete block in the remaining target color cluster; Step S254, determining the auxiliary color priority order according to the dispersion and spatial shape of the remaining target color clusters; Step S255, setting the priority of the main color system to be higher than any auxiliary color, and finally generating the image color matching priority order.
[0035] Specifically, in step S251, considering that the image usually contains a main color system that has a dominant effect on the overall color style, the representative color of the color cluster with the largest spatial distribution proportion is selected as the main color system, and the remaining color types are selected as auxiliary color systems, which are used to provide supplementation and refinement in the overall color matching, to enrich the visual effect and enhance the level of color matching.
[0036] In one embodiment, the step S252, calculating the spatial distribution dispersion of each remaining target color cluster, specifically: Setting the minimum sample number k of DBSCAN clustering; Obtaining the "k-neighbor distance" of all pixel points in the current target color cluster in sequence, and finding the average of the two values with the largest distance value difference after the "k-neighbor distance" of all pixel points forms a global sequence, which is the neighborhood radius required for DBSCAN clustering of the current target color cluster; Performing DBSCAN clustering based on the spatial coordinate data of the pixel points of the current target color cluster to obtain a plurality of discrete blocks; the number of discrete blocks is the dispersion of the current target color cluster.
[0037] Wherein, the "k-neighbor distance" represents a set of distance values between the current pixel point and the nearest k-neighbor pixel point.
[0038] In a specific implementation, first, the spatial coordinates [h, w] of all pixel points contained in the current target color cluster identified in step S24 are determined; the minimum sample number k of DBSCAN clustering is set, and k is generally set as 10 by default. The field radius D is calculated, and the field radius is a key parameter for defining the clustering range. The NearestNeighbors method of the sklearn library is called to calculate the “k-neighbor distance” of each pixel point in the current target color cluster. After all the “k-neighbor distances” of the pixel points are sorted in ascending order, the average of the two largest values obtained by comparing the sorted results two by two is calculated, and the average is the field radius value.
[0039] The DBSCAN method of the sklearn library is called, the minimum sample number k and the calculated field radius D are input into the DBSCAN method, the spatial clustering calculation of the current target color cluster is performed, and the clustering result clusters (i.e., discrete blocks) are generated. The clusters contain the spatial coordinates of the pixel points. Finally, the number of clusters (i.e., discrete blocks) in the current target color cluster is obtained, and the number is the discrete degree value of the current target color cluster. It can be understood that if the discrete degree value is large, it means that the color cluster is discretely distributed in different regions of the image, and the distribution is relatively discrete.
[0040] In an embodiment, the step S253 calculates the spatial shape of each discrete block in the remaining target color cluster, specifically: The discrete blocks in each remaining target color cluster determined in step S252 are extracted, and the area and geometric center point of each discrete block are calculated. The minimum circumscribed rectangle area of each discrete block is calculated, and the rectangular degree of each discrete block is obtained based on the ratio of the area of the discrete block to the minimum circumscribed rectangle area. When the rectangular degree is greater than a first preset threshold, it is determined that the discrete block is rectangular. When the rectangular degree is not greater than the first preset threshold, the aspect ratio of the discrete block is calculated, and when the “aspect ratio” is greater than a second preset threshold, it is determined that the discrete block is strip-shaped; otherwise, it is determined that the discrete block is circular or irregular.
[0041] Finally, the total number of rectangular and strip-shaped discrete blocks included in each remaining target color cluster is counted.
[0042] Preferably, the first preset threshold has a value range of 0.6 to 0.9, and the second preset threshold has a value range of 4 to 6.
[0043] In a specific implementation, first, the shape features of each region are extracted based on the clustering results clusters of step S252. In addition to obtaining the pixel point set of the cluster, the DBSCAN method can also calculate the basic parameters of the aggregation point, such as the area area and the geometric center point. The rectangularity is calculated, the minAreaRect method of the OpenCV library is introduced to calculate the minimum circumscribed rectangle of the region, and then the formula: rectangularity = region area / minimum circumscribed rectangle area is used to calculate the rectangularity of the region; According to the rectangularity, the shape of the discrete block is determined. When the rectangularity is greater than a first preset threshold (for example, 0.8), it is determined that the discrete block is rectangular. When the rectangularity is not greater than the first preset threshold, the aspect ratio of the discrete block is further calculated. The covariance of the discrete block is calculated by introducing the NumPy library. First, the coordinate values [h, w] of all pixel points in the cluster are subtracted from the geometric center coordinate values , so that the coordinate data is centered on the origin. Then, the covariance matrix algorithm np.cov() is used to calculate the distribution and correlation of data in each dimension. The np.linalg.eigh() method is used to calculate the eigenvalues and eigenvectors of the covariance matrix. The longest axis and the shortest axis of the region are calculated using the maximum eigenvalue and the minimum eigenvalue, where the longest axis = , and the shortest axis = . Finally, the aspect ratio = longest axis / shortest axis is calculated.
[0044] If the aspect ratio is greater than a second preset threshold (for example, 4), it is determined that the discrete block is strip-shaped. Otherwise, it is determined that the discrete block is circular or irregularly shaped. Finally, the total number of rectangular and strip-shaped discrete blocks included in each remaining target color cluster is counted.
[0045] In an embodiment, the step S254 determines the priority ranking of the auxiliary colors according to the dispersion and spatial shape of the remaining target color clusters, specifically: The dispersion of each remaining target color cluster is obtained, as well as the total number of rectangular and strip-shaped discrete blocks in the color cluster; The auxiliary colors corresponding to the remaining target color clusters are prioritized in ascending order of dispersion; If the dispersion is the same, the total number of rectangular and strip-shaped discrete blocks included is further compared, and the auxiliary color corresponding to the color cluster with more rectangular and strip-shaped discrete blocks is assigned a higher priority.
[0046] It should be noted that in the present embodiment, the priority of the auxiliary color is determined according to the Gestalt perceptual organization principle. According to this principle, elements that are close to each other in space, have similar features (such as color, shape, size), and are smoothly continuous (interrupted parts are ignored) are easily perceived as a unified visual whole. In addition, visual attention tends to perceive images along continuous, smooth paths rather than broken or abrupt directions, i.e., linear structures such as rectangles / bands have directionality in vision.
[0047] That is, the dispersion of colors and spatial shapes will affect the distribution of visual attention, and visual attention will preferentially focus on colors with more concentrated color space distribution and more rectangular and strip-shaped colors in the image.
[0048] Therefore, in the present embodiment, the overall priority of the auxiliary color is calculated based on the spatial dispersion of each color cluster and the total number of rectangular and strip-shaped dispersed blocks formed by it in the image, so as to determine the priority order of each auxiliary color in the color matching scheme.
[0049] Finally, in step S255, the priority of the main color system is set to be higher than that of any auxiliary color, and the priority order of the image color matching is main color system, auxiliary color 1, auxiliary color 2, auxiliary color 3, …, auxiliary color N-1 in turn.
[0050] In summary, the present embodiment provides an image color matching style determination method, which can quickly identify the main color type in the image by analyzing the color space distribution ratio. For images with a single color type, the color type with the largest spatial distribution ratio is selected as the main color system, and the color type with the smallest ratio is selected as the auxiliary color system to highlight the visual features of the overall simple style of the image. For images with a rich color type, the priority order of the auxiliary color system is further determined based on the identification of the main color system and the spatial distribution characteristics (i.e., texture characteristics) of different colors. This comprehensive analysis method takes into account the color ratio while also considering the spatial distribution characteristics of the colors, thereby more accurately capturing the color matching style of the image and ensuring that the map color matching scheme can highly restore the desired style effect of the user. For example, if the color with the largest image ratio is pink, yellow, and light caramel, it is a warm-toned macaron style; if dark blue and dark purple are the main colors, black, gray, and ice blue are the most commonly used extreme night blue style for technology style maps.
[0051] Step S3, set the priority of the map element category, and match the extracted image color matching with the map element category in priority order to generate a map color matching mode.
[0052] Specifically, first, the map elements are divided into N different categories, and the map element with the largest spatial distribution ratio is set as the highest priority, and the priority order of the remaining map element categories is set.
[0053] It should be noted that the system can default the priority order of the remaining map element categories, or set the priority order of the remaining map element categories according to user needs.
[0054] Then, the extracted image color matching is matched with the map element categories one by one in the priority order, and a map color matching mode is generated, specifically: If the number of color clusters after clustering is not less than N, the color matching is matched with the map element categories one by one in the priority order, and a map color matching mode is generated; If the number of color clusters after clustering is less than N, the main color system is applied to the map element category with the highest priority, and the same auxiliary color is applied to the remaining map element categories.
[0055] In an example, as the system default configuration, the map elements are divided into five main categories in the priority order: 1) administrative division; 2) road, including main road and secondary road; 3) water system, including lake, river, reservoir, etc.; 4) ecological land, including green land, farmland, forest land, etc.; 5) other special facilities or sites.
[0056] According to the image color matching mode determined in step S2, if the number of color clusters is not less than 5, the image color matching priority order is main color system, auxiliary color 1, auxiliary color 1, auxiliary color 3, and auxiliary color 4 in turn.
[0057] The main color system is used for administrative division; auxiliary color 1 is used for road, including main road and secondary road; auxiliary color 2 is used for water system, including lake, river, reservoir, etc.; auxiliary color 3 is used for ecological land, including green land, farmland, forest land, etc.; auxiliary color 4 is used for other special facilities or sites; If the number of color clusters is less than 5, the main color system is used for administrative division, and the same auxiliary color is matched for other map element categories.
[0058] In another embodiment, step S3 includes: setting the priority of the map element categories, matching the extracted image color with the map element categories one by one in the priority order, and respectively using the transparency variation color based on the matched color and / or the same color system gradient color of the color type for each element in the map element categories to generate a map color matching mode.
[0059] As an example, the main color system is used for administrative division, the main color system + transparency 30% is used for construction land, and the main color system + transparency 60% is used for building; Auxiliary color 1 is used for main road, auxiliary color 1 + transparency 30% is used for secondary road, and auxiliary color 1 + transparency 60% is used for auxiliary road; The auxiliary color 2 is used for water systems including lakes, rivers, reservoirs, etc. In order to realize the layered display of different map elements, a plurality of same color system gradient colors can be generated based on the auxiliary color 2 and applied to lakes, rivers, reservoirs, etc. respectively. The auxiliary color 3 is used for ecological land including green land, farmland, forest land, etc. In order to realize the layered display of different map elements, a plurality of same color system gradient colors can be generated based on the auxiliary color 3 and applied to green land, farmland, forest land, etc. respectively. The auxiliary color 4 is used for other special facilities or sites. In order to realize the layered display of different map elements, a plurality of same color system gradient colors can be generated based on the auxiliary color 4 and applied to different map elements respectively.
[0060] In step S4, a layer style configuration interface provided by the map service platform is called, and real-time color matching is performed on the map based on the map color matching mode.
[0061] Specifically, the map service platform can be any geographic information system (GIS) platform supporting map layer loading and style configuration interface, such as Mapbox, ArcGIS, and Google Maps, etc.
[0062] Taking Mapbox as an example, in the specific implementation, first, the Mapbox map object is initialized, and after waiting for the map object data to be completely loaded, the map style is configured.
[0063] The setStyle method in the layer style configuration interface API provided by mapbox is called, the color value of different map element categories is set based on the map color matching mode confirmed in step S3, and is rendered to the map layer to realize the quick setting of map color matching.
[0064] In this embodiment, through deep integration with the API of the map service platform (such as Mapbox), the new color matching scheme can be conveniently applied to the map layer without changing the original map drawing architecture of the map service platform. Only simple configuration is needed to realize the extension of the map color style customization function.
[0065] As shown in Figure 3 The second embodiment of the present disclosure proposes a map color matching system 100 based on image color feature extraction, which is used to execute the map color matching method based on image color feature extraction as described in the above embodiments. The system comprises: An image acquisition module 101 is configured to acquire an image uploaded by a user. An image color matching extraction module 102 is configured to determine an image color matching mode based on the color distribution characteristics of the image, wherein the image color matching mode comprises a color matching type and a color matching priority order. The map color matching determining module 103 is configured to set a map element category priority, match the extracted image color matching with the map element categories in order of priority, and generate a map color matching mode. The map color matching executing module 104 is configured to call a layer style configuration interface provided by a map service platform, and perform real-time color matching on the map based on the map color matching mode.
[0066] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment scheme according to actual needs. Those skilled in the art can understand and implement it without creative labor.
[0067] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software and the necessary general hardware platform, and of course, can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0068] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A map color matching method based on image color feature extraction, characterized in that, The method comprises the following steps: S1, acquiring an image uploaded by a user; S2, determining an image color matching mode based on color distribution characteristics of the image, the image color matching mode comprising a color matching type and a color matching priority order; S3, setting a map element category priority, and matching the extracted image color matching with the map element category in the priority order to generate a map color matching mode; S4, calling a layer style configuration interface provided by a map service platform, and performing real-time color matching on the map based on the map color matching mode.
2. The image color feature extraction based map color matching method according to claim 1, characterized in that, The step S2 comprises the following steps: S21, extracting color values and spatial coordinates of all pixel points in the image; S22, performing cluster analysis on the color values of the pixel points extracted in step S21 to generate a plurality of color clusters, each color cluster comprising all pixel points assigned to the cluster, and extracting a cluster center of the color cluster as a representative color of the color cluster; S23, determining whether the number of the color clusters after clustering is not less than N, if yes, proceeding to step S24, and if no, selecting a representative color of a color cluster with the largest spatial distribution proportion as a primary color system, a representative color of a color cluster with the smallest spatial distribution proportion as an auxiliary color, constructing a color matching type set of the image, setting the priority of the primary color system to be higher than that of the auxiliary color, generating an image color matching priority order, and then proceeding to step S3; S24, selecting the top N color clusters in terms of spatial distribution proportion in the image as target color clusters, and defining a set of representative colors of the target color clusters as a color matching type set of the image; S25, selecting a representative color of a target color cluster with the largest spatial distribution proportion as a primary color system, and selecting representative colors of the remaining target color clusters as auxiliary colors, obtaining auxiliary color priorities according to spatial distribution characteristics of the remaining target color clusters, setting the priority of the primary color system to be higher than that of any auxiliary color, and finally generating an image color matching priority order.
3. The image color feature extraction based map color matching method according to claim 2, characterized in that, The step S25 comprises the following steps: selecting a representative color of a target color cluster with the largest spatial distribution proportion as a primary color system, and selecting representative colors of the remaining target color clusters as auxiliary colors; calculating spatial distribution dispersion of each remaining target color cluster; calculating spatial shapes of each dispersion block in the remaining target color clusters; determining auxiliary color priority order according to the dispersion and spatial shapes of the remaining target color clusters; setting the priority of the primary color system to be higher than that of any auxiliary color, and finally generating an image color matching priority order.
4. The image color feature extraction based map color matching method according to claim 3, characterized in that, The calculation of the spatial distribution dispersion of each remaining target color cluster comprises the following steps: performing DBSCAN clustering based on spatial coordinate data of pixel points of the current target color cluster to obtain a plurality of dispersion blocks, and the number of the dispersion blocks is the dispersion of the current target color cluster.
5. The image color feature extraction based map color matching method according to claim 3, characterized in that, The determination of the auxiliary color priority order according to the dispersion and spatial shapes of the remaining target color clusters comprises the following steps: obtaining the dispersion of each remaining target color cluster, and the total number of rectangular and strip-shaped dispersion blocks in the color cluster; arranging the auxiliary colors of the remaining target color clusters in ascending order of the dispersion; if the dispersion is the same, further comparing the total number of rectangular and strip-shaped dispersion blocks included in the color cluster, and assigning a higher priority to the auxiliary color corresponding to the color cluster with a larger total number of rectangular and strip-shaped dispersion blocks.
6. The image color feature extraction based map color matching method according to claim 2, characterized in that, The parameter N is the number of map element categories.
7. The image color feature extraction based map color matching method according to claim 2, characterized in that, In step S22, the K-means clustering algorithm is used to generate a plurality of color clusters.
8. The image color feature extraction based map color matching method according to claim 1, characterized in that, The priority of the map element category is set, including: The map elements are divided into N different categories, the map element with the largest spatial distribution proportion is set as the highest priority, and the priority order of the remaining map element categories is set.
9. The image color feature extraction based map color matching method according to claim 1, characterized in that, The extracted image color matching is matched with the map element category one by one in the priority order to generate the map color matching mode, including: If the number of color clusters after clustering is not less than N, the color matching is matched with the map element category one by one in the priority order to generate the map color matching mode; If the number of color clusters after clustering is less than N, the main color system is applied to the map element category with the highest priority, and the same auxiliary color is applied to the remaining map element categories.
10. An image color feature extraction based map color matching system for performing the image color feature extraction based map color matching method according to any one of claims 1-9, characterized in that, The system comprises: An image acquisition module configured to acquire an image uploaded by a user; An image color matching extraction module configured to determine an image color matching mode based on color distribution characteristics of the image, the image color matching mode comprising a color matching type and a color matching priority order; A map color matching determination module configured to set a priority of a map element category, and match the extracted image color matching with the map element category one by one in the priority order to generate a map color matching mode; A map color matching execution module configured to call a layer style configuration interface provided by a map service platform, and perform real-time color matching on a map based on the map color matching mode.