A method for recognizing world country regions based on color
The color-based country identification method reduces performance consumption by using unique color values for countries on a world map, enabling efficient and simplified country recognition without individual boundary rendering.
Patent Information
- Application Number
- CN202210347261.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-01
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2042-04-01
AI Technical Summary
When identifying the world's countries and regions in three-dimensional visualization, the boundaries of each country need to be drawn separately, resulting in high performance consumption and judging the performance of the entity objects to which the country belongs.
A color recognition-based method is used to mark different color values for each country, build a country and its color value corresponding table, and use the world country map and country boundary line map during the rendering process, and use the color value to identify the selected country area to avoid drawing each country's boundary separately.
Improves the efficiency of national regional identification, reduces performance consumption, and enables accurate identification of selected national regions without mapping each country's boundaries.
Smart Images

Figure CN114943779B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of boundary recognition, and specifically to a method for identifying world country regions based on color recognition. Background Art
[0002] Currently, in 3D visualization, the distinction and recognition between countries mainly adopt the traditional method of drawing the boundaries of each country. Each country is a separate object. This method has certain requirements for country data: a: The boundary data of the country must be closed; b: For unconnected boundaries, multiple closed boundaries must be used to represent them.
[0003] Existing drawbacks:
[0004] Each time, it is necessary to draw the world map according to the data. More points are required to draw complex boundary areas, which consumes more performance.
[0005] To determine the currently clicked or selected country, it is necessary to determine the entity object to which the selected point belongs and compare it with each object, which consumes performance. Summary of the Invention
[0006] The purpose of this part is to outline some aspects of the embodiments of the present invention and briefly introduce some preferred embodiments. Simplifications or omissions may be made in this part, as well as in the abstract and title of the present application, to avoid obscuring the purpose of this part, the abstract, and the title. However, such simplifications or omissions shall not be used to limit the scope of the present invention.
[0007] In view of the above and / or existing problems in the recognition of world country regions, the present invention is proposed.
[0008] Therefore, the purpose of the present invention is to provide a method for identifying world country regions based on color recognition, which can identify and select each country region without separately drawing the boundaries of each world country. Only a world country map and a national boundary line map are required, and the recognition efficiency is higher.
[0009] To solve the above technical problems, according to one aspect of the present invention, the following technical solution is provided: A method for identifying world country regions based on color recognition, including the following method steps:
[0010] Step 1: Construct a schematic diagram of the world country map, including: coloring each country with different color values. The color of each country has a different color value, but the RGB values are all equal. Coloring each country with different color values forms regions with different color values. The equality of RGB means that the color values of red, green, and blue in the RGB color model are equal, and the same color value is taken within the range of 0 - 255.
[0011] Step 2: Organize the color values marked in different countries, construct a correspondence table between countries and their color values, and use colors with equal RGB values to represent a country, with a maximum of 256 countries represented.
[0012] Step 3: Select rendering. When a certain country is selected in the schematic diagram of the national border map, at the moment of clicking, use the world map schematic diagram of countries for rendering, and record the color value at the time of clicking. Based on the clicked color value, the currently clicked country can be reversely searched. Use a picture to record the selected country. This picture is a picture with a length of 256 pixels and a width of 1 pixel. At the corresponding pixel position of the length, change the pixel here to white, record the selected country, and obtain the picture of the selected country.
[0013] Step 4: Render again. Compare the schematic diagram of the national map, the schematic diagram of the national border map, and the picture of the selected country in the shader to obtain the selected area, and perform high - light rendering. In this way, on the basis of not separately drawing the border of each country, each country's area can be distinguished in the shader. The overlapping area of the schematic diagram of the national map, the schematic diagram of the national border map, and the picture of the selected country is the area map of the selected country. After rendering, the selected area lights up to display the area and contour information of the country.
[0014] As a preferred solution of a method for identifying world country regions based on color recognition according to the present invention, wherein: in the above - mentioned Step 2, the color value of each country corresponds to the longitude and latitude values of the corresponding capital city of the country.
[0015] As a preferred solution of a method for identifying world country regions based on color recognition according to the present invention, wherein: in the above - mentioned Step 3, when no country is selected, the picture used is a pure - black picture, and when a country is selected, the selected area changes color separately.
[0016] As a preferred solution of a method for identifying world country regions based on color recognition according to the present invention, wherein: in the above - mentioned Step 3, the selected color value is any color value within 0 - 255.
[0017] As a preferred solution of a method for identifying world country regions based on color recognition according to the present invention, wherein: in the above - mentioned Step 4, during the rendering process, the colors of the ocean and inland areas without boundaries are always black.
[0018] Compared with the prior art: The present invention marks the regions in the world country map and the national border map with different color values. Without separately drawing the border of each world country, by using a world country map and a national border map, each country's area can be recognized and selected, and the recognition efficiency is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the present invention will be described in detail below in conjunction with the accompanying drawings and detailed embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings. Among them:
[0020] Figure 1 Schematic diagrams of some countries of the present invention and their color values. Specific embodiments
[0021] To make the above objects, features, and advantages of the present invention more obvious and understandable, the specific embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings.
[0022] In the following description, many specific details are set forth in order to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Those skilled in the art can make similar promotions without departing from the connotation of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed below.
[0023] Secondly, the present invention is described in detail in conjunction with the schematic diagrams. When detailing the embodiments of the present invention, for the convenience of description, the cross-sectional views showing the device structure will be locally enlarged out of the general scale, and the schematic diagrams are only examples and should not limit the scope of protection of the present invention herein. In addition, in actual production, three-dimensional spatial dimensions including length, width, and depth should be included.
[0024] To make the purpose, technical solution, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below in conjunction with the accompanying drawings.
[0025] The present invention provides a method for identifying world country regions based on color, which marks regions in the world country map and the national boundary map with different color values. Without separately drawing the boundaries of each world country, it is possible to identify each selected country region using a world country map and a national boundary line map, with higher recognition efficiency, including the following steps.
[0026] Step 1: Construct a schematic diagram of the world country map, including: coloring each country with a different color value, and the color of each country has a different color value, but the RGB values are all equal. Coloring each country with a different color value forms regions with different color values. The equality of RGB means that the color values of red, green, and blue in the RGB color model are equal, and the same color value is taken within the range of 0 - 255;
[0027] Step 2: Organize the color values marked for different countries, construct a correspondence table between countries and their color values, and use colors with equal RGB values to represent a country, with a maximum of 256 countries represented;
[0028] Step 3: Select rendering. In the schematic diagram of the national boundary map, when a certain country is selected and clicked, at the moment of clicking, use the world country map schematic diagram for rendering, and record the color value at the time of clicking. Based on the clicked color value, the currently clicked country can be reversely searched. Use a picture to record the selected country. This picture is a picture with a length of 256 pixels and a width of 1 pixel. At the corresponding long pixel position, change the pixel here to white, record the selected country, and obtain the picture of the selected country;
[0029] Step 4: Render again. Compare the three pictures of the country map schematic diagram, the national boundary map schematic diagram, and the picture of the selected country in the shader, obtain the selected area, and perform a highlighted rendering. In this way, on the basis of not separately drawing the boundaries of each country, each country's area can be distinguished in the shader. The overlapping area of the three pictures of the country map schematic diagram, the national boundary map schematic diagram, and the picture of the selected country is the area map of the selected country. After rendering, the selected area lights up to display the area and contour information of the country.
[0030] In Step 2, the color value of each country corresponds to the longitude and latitude values of the corresponding capital city of that country.
[0031] In Step 3, when no country is selected, the picture used is a pure black picture. When a country is selected, the selected area changes color separately.
[0032] In Step 3, the selected color value is any value within 0 - 255.
[0033] In Step 4, during the rendering process, the colors of the borderless ocean and inland areas are always black.
[0034] The code of the fragment shader is as follows:
[0035] 1. "uniform sampler2D mapIndex;",
[0036] 2. "uniform sampler2D lookup;",
[0037] 3. "uniform sampler2D outline;",
[0038] 4. "uniform float outlineLevel;",
[0039] 5. "varying vec2 vUv;",
[0040] 6. "uniform vec3 surfaceColor;"
[0041] 7. "uniform float flag;"
[0042] 8. "uniform vec3 selectedColor;"
[0043] 9. "void main() {"
[0044] 10. "vec4 mapColor = texture2D( mapIndex, vUv );"
[0045] 11. "float indexedColor = mapColor.x;"
[0046] 12. "vec2 lookupUV = vec2( indexedColor, 0. );"
[0047] 13. "vec4 lookupColor = texture2D( lookup, lookupUV );"
[0048] 14. "float mask = lookupColor.x + (1.-outlineLevel) * indexedColor;"
[0049] 15. "mask = clamp(mask,0.,1.);"
[0050] 16. "float outlineColor = texture2D( outline, vUv ).x *outlineLevel;"
[0051] 17. "float diffuse = mask + outlineColor;"
[0052] 18. "vec3 earthColor = vec3(0.0, 0.0, 0.0);"
[0053] 19. "earthColor.x = flag * surfaceColor.x * diffuse + (1.0 - flag) *diffuse;"
[0054] 20. "earthColor.y = flag * surfaceColor.y * diffuse + (1.0 - flag) *diffuse;",
[0055] 21. "earthColor.z = flag * surfaceColor.z * diffuse + (1.0 - flag) *diffuse;",
[0056] 22. "if (lookupColor.x >= 1.) {",
[0057] 23. "earthColor = selectedColor * diffuse;",
[0058] 24. "}",
[0059] 25. "gl_FragColor = vec4( earthColor, 1. );",
[0060] 26. "}"
[0061] As above is the core code in the fragment shader. Among them, mapIndex is the schematic diagram of the world country map, outline is the schematic diagram of the national boundary map. When no country is selected, lookup is a pure black picture with a length of 256 pixels and a width of 1 pixel. Both outlineLevel and flag are switches set to use the same shader code when clicking on the map and during normal rendering. vUv is the uv value of the picture. surfaceColor is the color of the earth's surface, and selectedColor is the color of the selected area.
[0062] The working steps are as follows:
[0063] A. When no country is selected, both outlineLevel and flag are 1, lookup is a pure black picture, and surfaceColor is red. At this time, for line 13 of the shader, the removed color is black. That is, for line 14, the value of mask is 0. For line 16, the removed color is the color of the national boundary map schematic diagram, which is white. Therefore, for the places with boundaries in line 16, the result tends to 1.0, and the result of line 17 is 1.0. The final color is the boundary color. For the places without boundaries, the result of line 16 is 0.0, and the result of line 17 is 0.0. Therefore, the final output color is black, which is the same as the final performance, and the ocean and the interior of the land are black;
[0064] B. When a country is selected, both outlineLevel and flag are 1. Looking up the picture, according to the selected country and Figure 1 the corresponding color value, the color value of the corresponding strength will be changed to black. If the selected country is China and the color value of China is known to be 96, the final lookup picture obtained is that at 96 pixels from the start of the picture, the 1-pixel size of the length and width of the picture is changed to white. Then, for the selected country area, 13 lines of lookupColor are all white, and the 22-line judgment will be true, and the color of the selected country will be set to the selected color;
[0065] C. When clicking to select, both outlineLevel and flag need to be 0 when clicking, that is, using the mapIndex picture to render the earth. At this time, the color value at the current click position can be obtained according to the rendering result and the click position. If the click is on the China area, the obtained color value is 96, and then the steps in B can be executed to distinguish the selected area.
[0066] Although the present invention has been described with reference to the embodiments above, various improvements can be made to it and its components can be replaced with equivalents without departing from the scope of the present invention. In particular, as long as there is no structural conflict, the various features in the disclosed embodiments of the present invention can be combined with each other in any way. The exhaustive description of these combinations is not given in this specification only for the sake of saving space and resources. Therefore, the present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A method for recognizing world country regions based on color, characterized in that, Including the following method steps: Step 1: Construct a schematic diagram of the world country map, including: coloring each country with different color values. Each country has a different color value, but the RGB values are all equal. Coloring each country with different color values forms regions with different color values. Equal RGB means that the color values of red, green, and blue in the RGB color model are equal, and the same color value is taken within the range of 0 - 255; Step 2: Organize the color values of the colored countries, construct a correspondence table between countries and their color values, and use colors with equal RGB to represent a country, with a maximum of 256 countries represented; Step 3: Select rendering. When a certain country is selected in the schematic diagram of the country border map, at the moment of clicking, use the schematic diagram of the world country map for rendering and record the color value at the time of clicking. Based on the clicked color value, the currently clicked country can be inversely looked up. Use a picture to record the selected country. This picture is a picture with a length of 256 pixels and a width of 1 pixel. At the corresponding long pixel, change the pixel here to white to record the selected country and obtain a picture of the selected country; Step 4: Render again. Compare the schematic diagram of the country map, the schematic diagram of the country border map, and the picture of the selected country in the shader to obtain the selected area and perform a highlighted rendering. In this way, it is possible to distinguish the area of each country in the shader without separately drawing the border of each country. The overlapping area of the schematic diagram of the country map, the schematic diagram of the country border map, and the picture of the selected country is the area map of the selected country. After rendering, the selected area lights up to display the area and contour information of the country.
2. The method for identifying world country regions based on color recognition according to claim 1, wherein In the above Step 2, each country's color value corresponds to the longitude and latitude values of the corresponding capital city of the country.
3. A method for recognizing world country regions based on color recognition according to claim 1, characterized in that, In the above Step 3, when no country is selected, the picture used is a pure black picture, and when selected, the selected area changes color separately.
4. A method for identifying world country regions based on color recognition according to claim 1, characterized in that, In the above Step 3, the selected color value is any color value within 0 - 255.
5. A method for identifying world country regions based on color recognition according to claim 1, characterized in that, In the above Step 4, during the rendering process, the color of the borderless ocean and inland areas is always black.
Citation Information
Patent Citations
Geographical map deformation visualization method based on boundary reservation
CN107766516A
Rendering method and system for map area boundaries in game map and computer readable storage medium
CN112509131A