Methods, devices, electronic equipment and storage media for generating surface vegetation
By acquiring terrain elevation maps and generating vegetation masks through natural language parsing, the problem of rigid vegetation morphology in virtual environments was solved, achieving customization and enhanced realism of vegetation.
Patent Information
- Application Number
- CN202411116536.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2044-08-14
AI Technical Summary
In existing technologies, the methods used to generate surface vegetation in virtual environments result in rigid vegetation morphology, which cannot achieve customization and lacks realism.
By acquiring terrain height maps and determining pixel area orientation information, the system parses the user's natural language input to extract key vegetation information, generates vegetation masks, and generates vegetation based on the masks, including customized settings for vegetation type and density.
It achieves greater flexibility and realism in vegetation, improves generation efficiency, allows for more flexible adjustments in the later stages, and results in more natural vegetation morphology.
Smart Images

Figure CN119131191B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to a method, apparatus, electronic device, and storage medium for generating surface vegetation. Background Technology
[0002] In some games, it is often necessary to generate vegetation on the surface of the virtual environment to make the virtual environment more similar to the real natural environment.
[0003] Currently, when generating vegetation on the ground, templates corresponding to different vegetation types are pre-created, and the generation of vegetation on the ground is achieved by calling the fixed templates corresponding to the vegetation.
[0004] However, generating vegetation using a fixed template results in a rigid and unrealistic overall vegetation shape, and it also fails to achieve customized vegetation generation. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of the prior art by providing a method, apparatus, electronic device, and storage medium for generating surface vegetation, so as to achieve customized vegetation generation while improving the realism of the generated vegetation.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows:
[0007] In a first aspect, embodiments of this application provide a method for generating surface vegetation, including:
[0008] Obtain a terrain elevation map and determine the orientation information corresponding to each pixel region in the terrain elevation map;
[0009] The vegetation key information is extracted from the natural language input by the user. The vegetation key information is used to indicate the location of the vegetation to be generated in the topographic height map and the attribute information of the vegetation, including: vegetation type and vegetation density.
[0010] Based on the key vegetation information and the directional information corresponding to each pixel region in the terrain elevation map, vegetation is generated and displayed in the terrain elevation map.
[0011] Secondly, embodiments of this application also provide a surface vegetation generation device, including: an acquisition module, an analysis module, and a generation module;
[0012] The acquisition module is used to acquire a terrain height map and determine the orientation information corresponding to each pixel region in the terrain height map;
[0013] The analysis module is used to extract key vegetation information based on the natural language input by the user. The key vegetation information is used to indicate the location of the vegetation to be generated on the topographic elevation map and the attribute information of the vegetation, including: vegetation type and vegetation density.
[0014] The generation module is used to generate and display vegetation in the terrain height map based on the key vegetation information and the directional information corresponding to each pixel area in the terrain height map.
[0015] Thirdly, embodiments of this application provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to implement the surface vegetation generation method provided in the first aspect.
[0016] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the surface vegetation generation method as provided in the first aspect.
[0017] The beneficial effects of this application are:
[0018] This application provides a method, apparatus, electronic device, and storage medium for generating surface vegetation, including: acquiring a topographic height map and determining the directional information corresponding to each pixel region in the topographic height map; extracting key vegetation information based on natural language input by the user; and generating and displaying vegetation on the topographic height map based on the key vegetation information and the directional information corresponding to each pixel region in the topographic height map. In this method, the user only needs to input relevant information about the vegetation to be generated in natural language to customize the generated vegetation according to their own ideas. Specifically, information such as the generation location, vegetation type, and vegetation density of the vegetation to be generated can be extracted through natural language, thereby controlling the shape and density of the generated vegetation, resulting in higher flexibility and realism of the generated vegetation.
[0019] Furthermore, during the vegetation generation process, a vegetation mask that best matches the vegetation to be generated is generated based on the key vegetation information. The effect of the vegetation mask is improved through a series of enhancement processing methods. Then, vegetation is generated based on the vegetation mask, making the generated vegetation more natural and closer to real vegetation. Moreover, the vegetation generation method of generating vegetation through vegetation masking improves the vegetation generation efficiency and makes subsequent vegetation adjustments more flexible. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A schematic flowchart illustrating a method for generating surface vegetation according to an embodiment of this application;
[0022] Figure 2 A schematic flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0023] Figure 3 This application provides a schematic diagram of terrain elevation map region division.
[0024] Figure 4 A schematic diagram illustrating the orientation definition of a pixel region provided in an embodiment of this application;
[0025] Figure 5 A flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0026] Figure 6 A schematic flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0027] Figure 7 A flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0028] Figure 8 A schematic flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0029] Figure 9 A schematic flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0030] Figure 10 A schematic flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0031] Figure 11 A schematic diagram of particle distribution provided in an embodiment of this application;
[0032] Figure 12 A flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0033] Figure 13 A schematic diagram of an initial vegetation cover provided in an embodiment of this application;
[0034] Figure 14 A schematic flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0035] Figure 15 A flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0036] Figure 16 This is another schematic diagram of vegetation covering provided in an embodiment of this application;
[0037] Figure 17 A flowchart illustrating another method for generating surface vegetation provided in this application embodiment;
[0038] Figure 18 A schematic diagram of a surface vegetation generation device provided in an embodiment of this application;
[0039] Figure 19 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0041] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0042] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0043] In some game virtual environments, it's often necessary to generate vegetation on the surface to make the virtual environment more similar to a real natural environment. In related technologies, vegetation patches at different locations within the target surface area of the virtual environment are generated from templates. However, this approach results in a rigid and unrealistic overall form of vegetation covering the target surface area. Developers are also unable to customize the vegetation according to their own ideas, leading to a lack of stylistic variation and distinctive features in the final generated vegetation.
[0044] Based on this, this solution provides a method for generating surface vegetation. By parsing the user's input in natural language, key vegetation information can be obtained. Then, based on this key vegetation information and the attribute information of each pixel region in the topographic height map, the desired vegetation is generated and displayed on the topographic height map, realizing vegetation generation in a virtual environment. With this method, users only need to input the relevant information of the vegetation to be generated in natural language to achieve automated vegetation generation, thus realizing personalized vegetation generation. Furthermore, during the vegetation generation process, a vegetation mask that best matches the vegetation to be generated is first generated based on the key vegetation information, and then vegetation generation is performed based on the vegetation mask, making the generated vegetation morphology more natural and closer to real vegetation.
[0045] Figure 1 This is a flowchart illustrating a method for generating surface vegetation according to an embodiment of this application; the execution subject of this method can be a computer device, such as... Figure 1 As shown, the method may include:
[0046] S101. Obtain the terrain height map and determine the orientation information corresponding to each pixel area in the terrain height map.
[0047] Virtual terrain in games is usually generated from terrain elevation maps and landform data. Landform data can refer to surface vegetation data. By overlaying surface vegetation on the terrain elevation map, a game virtual terrain that closely resembles reality can be generated.
[0048] Topographic elevation maps can visually represent the undulating characteristics of terrain. Topographic elevation maps can be generated in various ways, including but not limited to manual drawing using professional drawing software (such as Photoshop), extraction from real-world geographic data (such as SRTM (Shuttle Radar Topography Mission) data), and automatic generation through program algorithms.
[0049] Optionally, since vegetation generation requires a topographic elevation map as a basis, and the virtual terrain containing vegetation is generated in conjunction with the topographic elevation map, the vegetation layout should be based on the size of the topographic elevation map.
[0050] Since the topographic elevation map may be large in size, in order to facilitate subsequent vegetation generation and improve the accuracy of vegetation generation, the topographic elevation map can be divided into regions to determine the directional information corresponding to different pixel regions in the topographic elevation map.
[0051] S102. Extract key vegetation information based on the natural language input by the user.
[0052] Key vegetation information is used to indicate the location of the vegetation to be generated on the topographic elevation map and the attribute information of the vegetation, including vegetation type and vegetation density.
[0053] In this embodiment, the user only needs to describe the relevant information of the vegetation to be generated in the form of natural language. By parsing and analyzing the natural language, the key information of the vegetation can be extracted.
[0054] Among them, by inputting through natural language, users can personalize their input and control information such as the density and orientation of the vegetation to be generated, no longer limited to the fixed and rigid vegetation template generation method.
[0055] In one feasible approach, the user-input natural language can contain long strings that may indicate information about generating different vegetation at different locations on a topographic elevation map. In this case, multiple sets of key vegetation information can be extracted by parsing the natural language.
[0056] In another possible approach, the user-input natural language could consist of only a single string indicating information about generating specific vegetation at a given location on a topographic elevation map. In this case, a set of key vegetation information can be extracted by parsing the natural language.
[0057] In this embodiment, the solution is illustrated using any set of extracted vegetation key information as an example. In practical applications, when there are multiple sets of vegetation key information, the method of generating vegetation based on each set of vegetation key information is the same, only the location, type, and shape of the final generated vegetation are different.
[0058] Optionally, the vegetation key information can indicate the location of the vegetation to be generated on the topographic height map and the vegetation attribute information. That is, the vegetation key information can determine the location on the topographic height map where the vegetation will be generated. The vegetation attribute information includes: vegetation type and vegetation density. The vegetation attribute information can determine what kind of vegetation to be generated and its distribution density, etc.
[0059] Of course, in some embodiments, the vegetation attribute information may also include: vegetation color, vegetation height, etc.
[0060] S103. Based on the key vegetation information and the azimuth information corresponding to each pixel area in the terrain elevation map, generate and display vegetation in the terrain elevation map.
[0061] Optionally, based on the extracted key vegetation information and the directional information corresponding to each pixel region in the terrain height map, the generation position of the vegetation indicated by the key vegetation information in the terrain height map can be determined. Then, based on the generation position, vegetation can be generated and displayed in the terrain height map, thereby generating a virtual terrain image.
[0062] In summary, the surface vegetation generation method provided in this embodiment includes: acquiring a topographic height map and determining the directional information corresponding to each pixel region in the topographic height map; extracting key vegetation information based on natural language input by the user; and generating and displaying vegetation on the topographic height map based on the key vegetation information and the directional information corresponding to each pixel region in the topographic height map. In this method, the user only needs to input relevant information about the vegetation to be generated in natural language to customize the generated vegetation according to their own ideas. Specifically, natural language can be used to extract information such as the generation location, vegetation type, and vegetation density of the vegetation to be generated, thereby controlling the shape and density of the generated vegetation, resulting in higher flexibility and realism of the generated vegetation.
[0063] Figure 2 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S101, determining the azimuth information corresponding to each pixel region in the topographic height map may include:
[0064] S201. Divide the terrain elevation map according to the preset area division method and determine at least one pixel area.
[0065] In some embodiments, the terrain height map may have a large resolution, making it difficult to pinpoint precise locations for vegetation generation without partitioning. Therefore, the entire terrain height map can be divided into multiple pixel regions, each with non-overlapping pixel ranges. After dividing the terrain height map into multiple pixel regions, a specific location can be quickly located within the map.
[0066] Figure 3 This application provides a schematic diagram of terrain elevation map region division, as shown in the embodiment of the present application. Figure 3 As shown, the terrain height map can be divided into 9 pixel regions according to a 9*9 size, namely pixel region 1, pixel region 2, pixel region 3, pixel region 4, pixel region 5, pixel region 6, pixel region 7, pixel region 8, and pixel region 9.
[0067] Of course, this is just one possible way of dividing the map. In practical applications, the division size can be adjusted according to the specific dimensions of the terrain elevation map. When the terrain elevation map is large, the division size can also be set to be large, so that the division result is more refined.
[0068] S202. Determine the orientation information corresponding to each pixel region according to the preset orientation definition method.
[0069] Based on the segmentation results, the location information of each pixel region in the terrain height map can be determined. Then, based on the location information and according to the preset orientation definition method, the orientation information corresponding to each pixel region can be determined.
[0070] Figure 4 This is a schematic diagram illustrating the orientation definition of a pixel region provided in an embodiment of this application. Based on the above... Figure 3 Based on the pixel region division method, the orientation information of pixel region 1 can be defined as upper left (also known as northwest), pixel region 2 as upper (also known as north), pixel region 3 as upper right (also known as northeast), pixel region 4 as left (also known as west), pixel region 5 as center, pixel region 6 as right (also known as east), pixel region 7 as lower left (also known as southwest), pixel region 8 as lower (also known as south), and pixel region 9 as lower right (also known as southeast).
[0071] Of course, when the pixel region division method of the terrain elevation map changes, the corresponding orientation information definition can also be changed to accurately describe the position of the pixel region in the terrain elevation map.
[0072] Figure 5 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, step S102, extracting key vegetation information based on natural language input by the user, may include:
[0073] S501. Parse the natural language to obtain multiple sets of query information.
[0074] Optionally, the input natural language can be segmented into words to divide the continuous text into a series of meaningful units, such as words, symbols, or phrases, to obtain multiple sets of query information.
[0075] Each set of query information obtained here is still in the form of natural language, except that the complete natural language input is divided into multiple sets of strings.
[0076] S502. Match each group of query information with the standard information in the pre-created template library, and obtain the key vegetation information indicated by each group of query information based on the matching results.
[0077] Optionally, each set of query information can be matched with standard information in a pre-created template library. The template library can store standard orientation information, standard vegetation density information, etc. By matching the query information with the standard information in the template library, key vegetation information can be extracted from the query information.
[0078] One set of query information can be matched to obtain a set of vegetation key information, and a set of vegetation key information indicates the vegetation generation information in a specified pixel area of the topographic height map.
[0079] For example, suppose the user inputs the natural language "generate some trees in the upper left position, generate a large number of sunflowers in the middle position, and a normal amount of grass at the bottom". After parsing and segmenting the natural language, three sets of query information can be obtained: "generate some trees in the upper left position", "generate a large number of sunflowers in the middle position", and "a normal amount of grass at the bottom". By matching each set of query information with the template library, three sets of vegetation key information can be obtained: "upper left, some trees", "middle, a large number of sunflowers in the middle", and "bottom, a normal amount of grass".
[0080] Figure 6 A flowchart illustrating another method for generating surface vegetation provided in this application embodiment; optionally, the creation process of the above-mentioned template library may include:
[0081] S601. Based on the orientation definition method of the topographic elevation map, generate at least one standard orientation description information corresponding to each orientation.
[0082] The data in the template library can include: orientation information describing location and vegetation density information describing density; of course, it can also include vegetation color information describing color, etc.
[0083] To ensure consistency in orientation, the orientation classification in the template library must be consistent with that in the topographic elevation map. This ensures that the key vegetation information obtained after matching the template library accurately indicates the planting orientation of vegetation in the topographic elevation map. If the orientation definitions in the template library are inconsistent with those in the topographic elevation map, the same orientation information may represent different orientations, making it impossible to determine the specific orientation.
[0084] Based on the same orientation definition method as topographic height maps, standard orientation descriptions from the template library can be generated. Each orientation can correspond to multiple standard orientation descriptions. For example, "up" and "north" both describe the same orientation, and "upper right" and "northeast" both describe the same orientation.
[0085] S602. Based on the vegetation density classification method, generate at least one standard density description information corresponding to each density level.
[0086] Vegetation density can be classified into sparse, medium, and dense, with each density level corresponding to one or more standard density descriptions. For example, "few, sparse, a little" all describe a sparse density level; "medium, moderate, ordinary" all describe a medium density level; and "abundant, many, a lot" all describe a dense density level.
[0087] S603. Generate a template library based on at least one standard orientation description information corresponding to each orientation and at least one standard orientation description information corresponding to each density level.
[0088] Optionally, a template library can be generated based on the above-mentioned standard orientation description information and standard density description information.
[0089] Table 1 below provides an example of the contents of the template library:
[0090] Table 1
[0091]
[0092] Figure 7 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S103, generating and displaying vegetation on the topographic height map based on key vegetation information and the azimuth information corresponding to each pixel region in the topographic height map may include:
[0093] S701. Based on the location indicated by the key vegetation information and the azimuth information corresponding to each pixel area in the topographic elevation map, determine the target pixel area corresponding to the location.
[0094] Optionally, based on the location indicated by the key vegetation information, the directional information indicated by the key vegetation information in the topographic height map can be determined. Furthermore, based on the mapping relationship between the directional information and pixel regions, the target pixel region indicated by the key vegetation information can be determined. Here, each piece of directional information in the topographic height map uniquely corresponds to one pixel region. Figure 3 and Figure 4 For example, the orientation information corresponding to pixel region 1 is the upper left (or northwest).
[0095] For example, if the location indicated by the vegetation key information is the upper left, it can be determined that the vegetation key information indicates the upper left position in the topographic height map. Since the upper left position corresponds to pixel region 1, it can be determined that the target pixel region indicated by the vegetation key information is pixel region 1.
[0096] S702. Based on the attribute information indicated by the key vegetation information, generate a corresponding vegetation mask in the target pixel area, and generate the corresponding vegetation on the vegetation mask.
[0097] The vegetation type and density can be determined based on the attribute information in the vegetation key information. The vegetation density determines the area and shape of the vegetation mask, thus generating a vegetation mask corresponding to the vegetation key information in the determined target pixel area. Furthermore, corresponding vegetation can be generated on the vegetation mask according to the vegetation type.
[0098] It's worth noting that generating vegetation masks before generating vegetation offers the following advantages: First, reduced computational load: By pre-generating vegetation masks, detailed vegetation generation and rendering can be performed only within the corresponding masked areas, eliminating the need for indiscriminate calculations across the entire terrain. This significantly reduces computational load and improves rendering efficiency. Second, optimized resource allocation: With limited computational resources, prioritizing the processing of terrain and vegetation within the vegetation masked areas ensures more refined rendering in these areas while avoiding wasting computational resources in non-vegetated areas. Third, enhanced realism of vegetation distribution: In nature, vegetation distribution is often influenced by various factors such as terrain, climate, and soil. Vegetation masks can more accurately simulate the impact of these factors on vegetation distribution, resulting in a more natural vegetation distribution. Controlling vegetation density: Vegetation masks can control vegetation density by adjusting the masking values in different areas. Higher masking values are set in densely vegetated areas, while lower masking values or complete transparency are set in sparsely vegetated or nonexistent areas, achieving a more realistic vegetation distribution effect. Fourth: Facilitates subsequent editing and adjustments, allowing for flexible modification: If editing or adjusting the vegetation in the virtual terrain is required (such as changing vegetation types or adjusting vegetation distribution), vegetation masking makes this process much easier. Simply modifying the vegetation mask quickly updates the generated vegetation results without requiring a complex recalculation of the entire terrain. Layered management is also supported.
[0099] Figure 8 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S702, generating a corresponding vegetation mask in the target pixel area based on the attribute information indicated by the key vegetation information, and generating corresponding vegetation on the vegetation mask, may include:
[0100] S801. Generate an initial vegetation mask within the target pixel area of the terrain height map based on the vegetation density.
[0101] In some embodiments, the area and shape of the vegetation mask can be determined based on the vegetation density in the vegetation key information, thereby generating an initial vegetation mask within the target pixel area of the topographic height map.
[0102] S802. Enhance the initial vegetation mask to generate a vegetation mask corresponding to the target pixel region.
[0103] This embodiment can also enhance the initial vegetation cover through some enhancement processing methods to improve the realism and detail of the final vegetation distribution, so that the vegetation is not too rigid and stiff, and the intersection between the vegetation and the ground surface is more natural.
[0104] A vegetation mask can be generated by enhancing the initial vegetation mask.
[0105] S803. Generate the corresponding vegetation on the vegetation mask according to the vegetation type.
[0106] Based on the vegetation type, the specific type of vegetation to be generated can be determined. For example, the vegetation can be trees or flowers; it can also be specified to what kind of trees or flowers. Thus, the corresponding type of vegetation can be generated on the vegetation mask.
[0107] Figure 9 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S801, generating an initial vegetation mask within the target pixel area of the topographic height map based on vegetation density may include:
[0108] S901. Determine the area and shape of the initial vegetation cover based on the vegetation density.
[0109] Optionally, the DLA (Diffusion Limited Aggregation) algorithm can be used to calculate and determine the area and shape of the initial vegetation cover to be generated based on the vegetation density.
[0110] S902. Generate an initial vegetation mask within the target pixel area based on the area and shape of the initial vegetation mask.
[0111] Based on the determined area and shape of the initial vegetation mask, an initial vegetation mask matching the area and shape can be generated within the target pixel area.
[0112] Figure 10 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S901, determining the area and shape of the initial vegetation cover based on the vegetation density may include:
[0113] S1001. The vegetation density is used as input data and input into the diffusion-limited cohesion algorithm. The diffusion-limited cohesion algorithm is used to calculate and determine the number of particles at each key point in the target pixel area.
[0114] Vegetation density can be used as input data for the DLA algorithm, and the area and shape of the initial vegetation cover can be calculated based on the DLA algorithm.
[0115] In many physical processes, the interactions between particles (such as electromagnetic forces and van der Waals forces) become significant when they approach each other. When one particle approaches another or a group of particles, they may attract each other and eventually combine. In simulations, this natural phenomenon can be effectively modeled by stopping and marking particles as they approach each other. This simulation method is often used to generate fractal structures or specific patterns that are ubiquitous in nature, such as snowflakes, corals, and lightning. By allowing particles to stop and mark themselves as they approach each other, simulations can produce complex and interesting patterns whose formation principles are similar to those of natural processes.
[0116] Optionally, the center point of the target pixel region can be marked as fixed. Then, a particle starting position is randomly selected within the target pixel region, and the particle continues to wander randomly until it gets close to other particles. At the current position, the particle stops and is marked. The number of particles at the current position is determined based on the vegetation density at the current position and a pre-created correspondence between vegetation density and particle number. The current position can serve as a key point.
[0117] The correspondence between vegetation density and vegetation quantity can be, for example, as follows: a vegetation density of "small amount" corresponds to a particle count of "100"; a vegetation density of "medium" corresponds to a particle count of "300"; and a vegetation density of "large amount" corresponds to a particle count of "800".
[0118] S1002. Determine the area and shape of the initial vegetation cover based on the number of particles at each key point.
[0119] Based on the number of particles at each key point, the area and shape of the initial vegetation cover can be determined. And based on the area and shape of the initial vegetation cover, the corresponding initial vegetation cover can be generated through simulation.
[0120] Figure 11 This is a schematic diagram of particle distribution provided for an embodiment of this application. Figure 11 This diagram illustrates the particle distribution of the initial vegetation cover, determined by vegetation density. The particle distribution determines the area and shape of the initial vegetation cover.
[0121] Figure 12 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S902, generating an initial vegetation mask within the target pixel area based on the area and shape of the initial vegetation mask may include:
[0122] S1201. Generate the current vegetation cover based on the area and shape of the initial vegetation cover.
[0123] In some embodiments, based on the area and shape of the initial vegetation cover determined above, a suitable vegetation cover can be generated first, and the current vegetation cover is not the final vegetation cover required.
[0124] S1202. The current vegetation mask is binarized and Gaussian blurred to obtain the initial vegetation mask.
[0125] It should be noted that the vegetation mask exists in the form of an image, i.e., a vegetation mask image. Optionally, the current vegetation mask can be binarized and Gaussian blurred to obtain an initial vegetation mask.
[0126] Image binarization involves setting the grayscale value of pixels in an image to 0 or 255, resulting in a distinct black and white image. In vegetation-masked images, binarization helps to clearly separate vegetation areas (usually white or black, depending on the threshold setting) from non-vegetation areas (usually the opposite color).
[0127] Gaussian blur is a commonly used image processing technique that softens and blurs images by obscuring their details. In vegetation masking images, Gaussian blur can be used to blur the edges of the vegetation mask, making the shape of the vegetation mask more natural.
[0128] Figure 13 This is a schematic diagram of an initial vegetation cover provided in an embodiment of this application. Figure 13 This only shows a schematic diagram of the initial vegetation mask generated within pixel region 1 of the terrain height map, such as... Figure 13 As shown, the white area is where the initial vegetation cover is located, and the black area can be understood as the background area.
[0129] Figure 14 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S802, enhancing the initial vegetation mask to generate a vegetation mask corresponding to the target pixel region may include:
[0130] S1401. Based on the pre-generated noise image, process the initial vegetation mask to generate the first processed vegetation mask.
[0131] Based on the initial vegetation mask generated above, further image enhancement processing can be performed to make the final vegetation mask more realistic and natural.
[0132] Optionally, a noise image can be generated in advance. The size of the noise image can be the same as the size of the target pixel region. That is, the size of the noise image is the same as that of any pixel region. Thus, the same noise image can be used to process the initial vegetation mask corresponding to each pixel region.
[0133] The initial vegetation mask is obtained by processing the noisy image.
[0134] In nature, vegetation is often affected by various factors, such as changes in light, shadows, occlusion, and noise. By processing the initial vegetation mask with noisy images, these interference factors in the real environment can be simulated, making the processed vegetation mask more realistic.
[0135] S1402. Apply Gaussian blur to the vegetation mask after the first processing to generate the vegetation mask after the second processing.
[0136] Optionally, the vegetation mask after the first processing can be subjected to Gaussian blur again. This is because the vegetation mask obtained after the first processing of the noisy image will become unnatural. Gaussian blur can make the generated vegetation mask after the second processing more natural.
[0137] S1403. Extract the edge data corresponding to the target pixel area in the terrain height map, and process the second-processed vegetation mask according to the edge data to generate the vegetation mask corresponding to the target pixel area.
[0138] Next, the second-processed vegetation mask can be calculated with the edge data extracted from the topographic elevation map to obtain the final vegetation mask.
[0139] Figure 15 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S1401, the process of generating the noisy image may include:
[0140] S1501. Determine the noise attribute parameters of each consecutive image region in the initial noisy image.
[0141] In this embodiment, noise can be generated cyclically, and by adjusting the noise attribute parameters, different regions in the generated noise image can have different noise effects, thereby improving the application performance of the noise image.
[0142] Optionally, each continuous image region in the initial noisy image can be determined, that is, the initial noisy image is divided into regions to obtain continuous image regions, and different noise attribute parameters are set for each continuous image region.
[0143] Among them, noise attribute parameters may include, but are not limited to: noise scaling, complexity, persistence and fractal dimension, etc.
[0144] Optionally, the noise attribute parameters of each consecutive image region can be set to different values, so that the noise effect generated in each consecutive image region is different.
[0145] S1502. Based on the noise attribute parameters of each continuous image region, generate noise information for each continuous image region in sequence; the noise attribute parameters of each continuous image region are not completely the same.
[0146] Based on the noise attribute parameters of each continuous image region, the Perlin noise algorithm can be used to generate noise information for each continuous image region sequentially.
[0147] S1503. Generate an intermediate noise image based on the noise information of each continuous image region.
[0148] Based on the noise information of each consecutive image region, an intermediate noise image can be generated. The generated intermediate noise image can be composed of dense small dots, and may contain different pixels such as black, white, and gray.
[0149] S1504. Based on the size of each pixel value in the intermediate noise image and the preset threshold number, perform color conversion on the intermediate noise image to obtain a noise image, which includes black areas and white areas.
[0150] Optionally, the intermediate noise image can be color-converted based on the size of each pixel value in the intermediate noise image and a preset threshold data to generate a black and white noise image.
[0151] The preset threshold can be 140. Through the above processing, pixels with a value greater than 140 can be set to white, and the remaining pixels can be set to black, resulting in a black and white noise image.
[0152] Optionally, in step S1401, processing the initial vegetation mask based on the pre-generated noise image to generate a first processed vegetation mask may include: subtracting the pixels in the white area of the initial vegetation mask from the pixels in the black area of the noise image that fall into the white area to generate the first processed vegetation mask.
[0153] In one feasible approach, the white areas of the initial vegetation mask can be superimposed on the noisy image. This superimposition involves subtracting the pixels of the white areas in the initial vegetation mask from the pixels of the black areas in the noisy image that fall within those white areas, thus making the white areas in the initial vegetation mask no longer appear as black as they were in the noisy image. Figure 13 The image shown is a single, continuous piece.
[0154] Figure 16 This is another schematic diagram of vegetation covering provided for an embodiment of this application. Figure 16 This diagram illustrates the second vegetation mask obtained after applying Gaussian blur to the first processed vegetation mask. It can be seen that compared to... Figure 13 The initial vegetation mask, after processing the noisy image and applying Gaussian blur, changes the white areas within it. The white areas are no longer a single, solid mass, but rather resemble cotton wool. The vegetation mask is no longer rigid and stiff, and the vegetation generated based on it is no longer a single, monolithic patch, effectively simulating the growth patterns of vegetation in real nature. For example, much vegetation exhibits a pattern of sparse and dense areas, or flowers and grasses are interspersed among trees, rather than all trees in a given area growing identically and with uniform density, which would create an unrealistic appearance.
[0155] Figure 17 This is a flowchart illustrating another method for generating surface vegetation provided in an embodiment of this application; optionally, in step S1403, extracting the edge data corresponding to the target pixel region in the topographic height map may include:
[0156] S1701. Perform Gaussian blur processing on the terrain elevation map to generate the processed terrain elevation map.
[0157] Optionally, the obtained terrain height map can first be processed by Gaussian blurring to remove noise, and then an edge detection algorithm, such as the Canny algorithm, can be used to perform edge detection on the terrain height map, extract edge information, and obtain edge data.
[0158] This can involve performing edge detection processing on each pixel region after azimuth segmentation, or it can involve performing edge detection processing on the entire terrain height map. However, when performing calculations with the edge data and vegetation masking, the vegetation masking corresponding to the target pixel region is only calculated with the edge data corresponding to the target pixel region to ensure the accuracy of the data calculation.
[0159] S1702. An edge processing algorithm is used to perform edge calculation on the target pixel region in the processed terrain height map to obtain the edge data corresponding to the target pixel region. The edge data is used to indicate the contour information of the object in the target pixel region.
[0160] Typically, the edge data obtained after edge detection processing of a terrain elevation map can include, but is not limited to: terrain edge strength: This indicates the significance of changes in terrain elevation. In a terrain elevation map, areas with abrupt changes in elevation (such as cliffs or ridges) will appear as areas with high edge strength in the edge detection results.
[0161] Terrain edge direction: This provides information about the direction of terrain changes. For example, the orientation of a valley or ridge can be identified by its edge direction.
[0162] Topographic edge locations: These specifically indicate which locations (coordinates) on the topographic elevation map show significant changes in elevation. This is very useful for identifying topographic features such as mountains, valleys, and slopes.
[0163] For example, if we have a height map representing the terrain of a certain area, after processing it using the Canny algorithm, we can clearly see:
[0164] (1) The outlines of mountains and valleys, because the height of these areas varies relatively greatly, will show high edge intensity in the edge detection results.
[0165] (2) The direction of the river, because the banks of the river are often areas of high elevation change, will be shown in the edge detection results.
[0166] (3) Man-made structures, such as roads and dams, will also be displayed in the edge detection results due to the height difference between these structures and the surrounding natural terrain.
[0167] In this embodiment, the edge data of interest is mainly the outline information of objects with large variations, such as mountains and valleys, that is, the outline information of objects is extracted from the terrain height map.
[0168] The purpose of calculating the vegetation mask after the second processing with the corresponding edge data is to eliminate the interference of edge data on the vegetation mask. If it is not calculated with the edge data, the generated vegetation mask will be interfered with, and the intersection between the edge of the generated vegetation and the ground surface will not be smooth and natural enough, resulting in poor realism.
[0169] Optionally, in step S1403, processing the second processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region may include: performing a difference operation between the second processed vegetation mask and the edge data to obtain the vegetation mask corresponding to the target pixel region.
[0170] In some embodiments, the second-processed vegetation mask and the corresponding edge data can be compared to obtain the vegetation mask corresponding to the target pixel region. Essentially, this can be understood as subtracting the second-processed vegetation mask from the edge data image and the corresponding edge image to obtain the vegetation mask corresponding to the target pixel region.
[0171] Optionally, based on the above method steps, similar processing can be performed on each pixel region in the terrain height map to obtain the vegetation mask corresponding to each pixel region. Of course, in some cases, the user's requirement may only be to generate vegetation in a portion of the pixel region, in which case it is sufficient to generate the vegetation mask for the corresponding pixel region.
[0172] Finally, through image rendering or art production techniques, vegetation can be generated and displayed on the generated vegetation mask according to the vegetation type indicated by the key vegetation information, thus obtaining the final virtual terrain.
[0173] In summary, the surface vegetation generation method provided in this embodiment includes: acquiring a topographic height map and determining the directional information corresponding to each pixel region in the topographic height map; extracting key vegetation information based on natural language input by the user; and generating and displaying vegetation on the topographic height map based on the key vegetation information and the directional information corresponding to each pixel region in the topographic height map. In this method, the user only needs to input relevant information about the vegetation to be generated in natural language to customize the generated vegetation according to their own ideas. Specifically, natural language can be used to extract information such as the generation location, vegetation type, and vegetation density of the vegetation to be generated, thereby controlling the shape and density of the generated vegetation, resulting in higher flexibility and realism of the generated vegetation.
[0174] Furthermore, during the vegetation generation process, a vegetation mask that best matches the vegetation to be generated is generated based on the key vegetation information. The effect of the vegetation mask is improved through a series of enhancement processing methods. Then, vegetation is generated based on the vegetation mask, making the generated vegetation more natural and closer to real vegetation. Moreover, the vegetation generation method of generating vegetation through vegetation masking improves the vegetation generation efficiency and makes subsequent vegetation adjustments more flexible.
[0175] The following describes the apparatus, equipment, and storage medium used to implement the surface vegetation generation method provided in this application. The specific implementation process and technical effects are described above and will not be repeated below.
[0176] Figure 18 This is a schematic diagram of a surface vegetation generation device provided in an embodiment of this application. The function of this surface vegetation generation device corresponds to the steps performed by the above-described method. This device can be understood as the aforementioned computer equipment, such as... Figure 18 As shown, the device may include: an acquisition module 180, an analysis module 181, and a generation module 182;
[0177] The acquisition module 180 is used to acquire the terrain height map and determine the orientation information corresponding to each pixel area in the terrain height map;
[0178] The analysis module 181 is used to extract key vegetation information based on the natural language input by the user. The key vegetation information is used to indicate the location of the vegetation to be generated in the topographic height map and the attribute information of the vegetation, including: vegetation type and vegetation density.
[0179] The generation module 182 is used to generate and display vegetation in the terrain height map based on key vegetation information and the directional information corresponding to each pixel area in the terrain height map.
[0180] Optionally, the acquisition module 180 is specifically used to divide the terrain height map according to a preset area division method and determine at least one pixel area;
[0181] Based on the preset orientation definition method, determine the orientation information corresponding to each pixel region.
[0182] Optionally, the analysis module 181 is specifically used to parse natural language to obtain multiple sets of query information;
[0183] The query information of each group is matched with the standard information in the pre-created template library, and the key vegetation information indicated by each group of query information is obtained based on the matching results.
[0184] Optionally, it also includes: creating modules;
[0185] Create a module to generate at least one standard orientation description for each orientation based on the orientation definition method of the terrain height map;
[0186] Based on the vegetation density classification method, generate at least one standard density description information corresponding to each density level;
[0187] A template library is generated based on at least one standard orientation description for each orientation and at least one standard orientation description for each density level.
[0188] Optionally, the generation module 182 is specifically used to determine the target pixel region corresponding to the location based on the location indicated by the key vegetation information and the azimuth information corresponding to each pixel region in the topographic height map.
[0189] Based on the attribute information indicated by the key vegetation information, a corresponding vegetation mask is generated in the target pixel area, and the corresponding vegetation is generated on the vegetation mask.
[0190] Optionally, the generation module 182 is specifically used to generate an initial vegetation mask within the target pixel area of the terrain height map based on the vegetation density.
[0191] The initial vegetation mask is enhanced to generate a vegetation mask corresponding to the target pixel region.
[0192] Based on the vegetation type, generate the corresponding vegetation on the vegetation mask.
[0193] Optionally, the generation module 182 is specifically used to determine the area and shape of the initial vegetation cover based on the vegetation density;
[0194] Based on the area and shape of the initial vegetation mask, an initial vegetation mask is generated within the target pixel area.
[0195] Optionally, the generation module 182 is specifically used to input vegetation density as input data into the diffusion-limited cohesion algorithm, and to calculate the number of particles at each key point in the target pixel area through the diffusion-limited cohesion algorithm.
[0196] The area and shape of the initial vegetation cover are determined based on the number of particles at each key point.
[0197] Optionally, the generation module 182 is specifically used to generate the current vegetation cover based on the area and shape of the initial vegetation cover;
[0198] The current vegetation mask is binarized and Gaussian blurred to obtain the initial vegetation mask.
[0199] Optionally, the generation module 182 is specifically used to process the initial vegetation mask based on the pre-generated noise image to generate a first processed vegetation mask.
[0200] Gaussian blur is applied to the vegetation mask after the first processing to generate the vegetation mask after the second processing.
[0201] Extract the edge data corresponding to the target pixel region from the terrain height map, and process the second-processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region.
[0202] Optionally, the generation module 182 is also used to determine the noise attribute parameters of each consecutive image region in the initial noisy image;
[0203] Based on the noise attribute parameters of each consecutive image region, noise information for each consecutive image region is generated sequentially; the noise attribute parameters of each consecutive image region are not completely the same.
[0204] Based on the noise information of each consecutive image region, an intermediate noise image is generated;
[0205] Based on the size of each pixel value in the intermediate noise image and a preset threshold, the intermediate noise image is color-converted to obtain a noise image, which includes black and white regions.
[0206] Optionally, the generation module 182 is specifically used to subtract the pixels of the white area in the initial vegetation mask from the pixels of the black area in the noise image that fall into the white area to generate the first processed vegetation mask.
[0207] Optionally, the generation module 182 is specifically used to perform Gaussian blur processing on the terrain height map to generate a processed terrain height map;
[0208] An edge processing algorithm is used to perform edge calculations on the target pixel region in the processed terrain height map to obtain the edge data corresponding to the target pixel region. The edge data is used to indicate the contour information of the object in the target pixel region.
[0209] Optionally, the generation module 182 is specifically used to perform a difference operation between the second processed vegetation mask and the edge data to obtain the vegetation mask corresponding to the target pixel region.
[0210] The above-described device is used to execute the method provided in the foregoing embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0211] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more digital signal processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0212] The modules described above can be connected or communicate with each other via wired or wireless connections. Wired connections can include metal cables, optical fibers, hybrid cables, or any combination thereof. Wireless connections can include connections via LAN, WAN, Bluetooth, ZigBee, or NFC, or any combination thereof. Two or more modules can be combined into a single module, and any module can be divided into two or more units. Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here.
[0213] Figure 19 A schematic diagram of an electronic device provided in this application embodiment includes: a processor 801, a storage medium 802, and a bus 803. The storage medium 802 stores machine-readable instructions executable by the processor 801. When the electronic device runs a surface vegetation generation method as described in the embodiment, the processor 801 communicates with the storage medium 802 via the bus 803. The processor 801 executes the machine-readable instructions to perform the following steps:
[0214] Obtain the terrain elevation map and determine the orientation information corresponding to each pixel region in the terrain elevation map;
[0215] The vegetation key information is extracted from the natural language input by the user. The vegetation key information is used to indicate the location of the vegetation to be generated in the topographic height map and the attribute information of the vegetation, including: vegetation type and vegetation density.
[0216] Based on key vegetation information and the directional information corresponding to each pixel area in the terrain elevation map, vegetation is generated and displayed in the terrain elevation map.
[0217] In one feasible implementation, when the processor 801 executes the determination of the orientation information corresponding to each pixel region in the terrain height map, it is specifically used to: divide the terrain height map according to a preset region division method and determine at least one pixel region.
[0218] Based on the preset orientation definition method, determine the orientation information corresponding to each pixel region.
[0219] In one feasible implementation, when the processor 801 extracts key vegetation information based on the natural language input by the user, it is specifically used to: parse the natural language to obtain multiple sets of query information;
[0220] The query information of each group is matched with the standard information in the pre-created template library, and the key vegetation information indicated by each group of query information is obtained based on the matching results.
[0221] In one feasible implementation, when the processor 801 executes the creation of the template library, it is specifically used to: generate at least one standard orientation description information corresponding to each orientation according to the orientation definition method of the terrain height map;
[0222] Based on the vegetation density classification method, generate at least one standard density description information corresponding to each density level;
[0223] A template library is generated based on at least one standard orientation description for each orientation and at least one standard orientation description for each density level.
[0224] In one feasible implementation, when the processor 801 generates and displays vegetation on the terrain height map based on the vegetation key information and the azimuth information corresponding to each pixel area in the terrain height map, it is specifically used to: determine the target pixel area corresponding to the location based on the location indicated by the vegetation key information and the azimuth information corresponding to each pixel area in the terrain height map.
[0225] Based on the attribute information indicated by the key vegetation information, a corresponding vegetation mask is generated in the target pixel area, and the corresponding vegetation is generated on the vegetation mask.
[0226] In one feasible implementation, when the processor 801 executes the generation of a corresponding vegetation mask in the target pixel area based on the attribute information indicated by the vegetation key information, and the generation of corresponding vegetation on the vegetation mask, it is specifically used to: generate an initial vegetation mask in the target pixel area of the terrain height map based on the vegetation density.
[0227] The initial vegetation mask is enhanced to generate a vegetation mask corresponding to the target pixel region.
[0228] Based on the vegetation type, generate the corresponding vegetation on the vegetation mask.
[0229] In one feasible implementation, when the processor 801 generates an initial vegetation mask within a target pixel region of a topographic height map based on vegetation density, it specifically determines the area and shape of the initial vegetation mask based on the vegetation density.
[0230] Based on the area and shape of the initial vegetation mask, an initial vegetation mask is generated within the target pixel area.
[0231] In one feasible implementation, when the processor 801 is executing the determination of the area and shape of the initial vegetation cover based on the vegetation density, it is specifically used to: input the vegetation density as input data into the diffusion-limited cohesion algorithm, and calculate the number of particles at each key point in the target pixel area through the diffusion-limited cohesion algorithm.
[0232] The area and shape of the initial vegetation cover are determined based on the number of particles at each key point.
[0233] In one feasible implementation, when the processor 801 performs the action of generating an initial vegetation mask within a target pixel region based on the area and shape of the initial vegetation mask, it is specifically used to: generate a current vegetation mask based on the area and shape of the initial vegetation mask.
[0234] The current vegetation mask is binarized and Gaussian blurred to obtain the initial vegetation mask.
[0235] In one feasible implementation, when the processor 801 performs enhancement processing on the initial vegetation mask to generate the vegetation mask corresponding to the target pixel region, it specifically performs the following:
[0236] Based on the pre-generated noisy image, the initial vegetation mask is processed to generate the first processed vegetation mask.
[0237] Gaussian blur is applied to the vegetation mask after the first processing to generate the vegetation mask after the second processing.
[0238] Extract the edge data corresponding to the target pixel region from the terrain height map, and process the second-processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region.
[0239] In one feasible implementation, when the processor 801 generates the noisy image, it is specifically used to: determine the noise attribute parameters of each consecutive image region in the initial noisy image;
[0240] Based on the noise attribute parameters of each consecutive image region, noise information for each consecutive image region is generated sequentially; the noise attribute parameters of each consecutive image region are not completely the same.
[0241] Based on the noise information of each consecutive image region, an intermediate noise image is generated;
[0242] Based on the size of each pixel value in the intermediate noise image and a preset threshold, the intermediate noise image is color-converted to obtain a noise image, which includes black and white regions.
[0243] In one feasible implementation, when the processor 801 processes the initial vegetation mask according to the pre-generated noise image to generate a first processed vegetation mask, it specifically performs the following: subtracting the pixels of the white area in the initial vegetation mask from the pixels of the black area in the noise image that fall into the white area to generate the first processed vegetation mask.
[0244] In one feasible implementation, when the processor 801 extracts the edge data corresponding to the target pixel region in the terrain height map, it is specifically used to: perform Gaussian blur processing on the terrain height map to generate a processed terrain height map.
[0245] An edge processing algorithm is used to perform edge calculations on the target pixel region in the processed terrain height map to obtain the edge data corresponding to the target pixel region. The edge data is used to indicate the contour information of the object in the target pixel region.
[0246] In one feasible implementation, when the processor 801 processes the second processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region, it specifically performs the following: performs a difference operation between the second processed vegetation mask and the edge data to obtain the vegetation mask corresponding to the target pixel region.
[0247] The storage medium 802 stores program code, which, when executed by the processor 801, causes the processor 801 to perform various steps in the surface vegetation generation method according to various exemplary embodiments of this application as described in the "Exemplary Methods" section above.
[0248] The processor 801 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0249] Storage medium 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The storage medium can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type storage medium, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage medium, magnetic disk, optical disk, etc. The storage medium is any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, storage medium 802 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0250] Optionally, embodiments of this application also provide a computer-readable storage medium storing a computer program, which is executed by a processor, and the processor performs the following steps:
[0251] Obtain the terrain elevation map and determine the orientation information corresponding to each pixel region in the terrain elevation map;
[0252] The vegetation key information is extracted from the natural language input by the user. The vegetation key information is used to indicate the location of the vegetation to be generated in the topographic height map and the attribute information of the vegetation, including: vegetation type and vegetation density.
[0253] Based on key vegetation information and the directional information corresponding to each pixel area in the terrain elevation map, vegetation is generated and displayed in the terrain elevation map.
[0254] In one feasible implementation, when the processor 801 executes the determination of the orientation information corresponding to each pixel region in the terrain height map, it is specifically used to: divide the terrain height map according to a preset region division method and determine at least one pixel region.
[0255] Based on the preset orientation definition method, determine the orientation information corresponding to each pixel region.
[0256] In one feasible implementation, when the processor 801 extracts key vegetation information based on the natural language input by the user, it is specifically used to: parse the natural language to obtain multiple sets of query information;
[0257] The query information of each group is matched with the standard information in the pre-created template library, and the key vegetation information indicated by each group of query information is obtained based on the matching results.
[0258] In one feasible implementation, when the processor 801 executes the creation of the template library, it is specifically used to: generate at least one standard orientation description information corresponding to each orientation according to the orientation definition method of the terrain height map;
[0259] Based on the vegetation density classification method, generate at least one standard density description information corresponding to each density level;
[0260] A template library is generated based on at least one standard orientation description for each orientation and at least one standard orientation description for each density level.
[0261] In one feasible implementation, when the processor 801 generates and displays vegetation on the terrain height map based on the vegetation key information and the azimuth information corresponding to each pixel area in the terrain height map, it is specifically used to: determine the target pixel area corresponding to the location based on the location indicated by the vegetation key information and the azimuth information corresponding to each pixel area in the terrain height map.
[0262] Based on the attribute information indicated by the key vegetation information, a corresponding vegetation mask is generated in the target pixel area, and the corresponding vegetation is generated on the vegetation mask.
[0263] In one feasible implementation, when the processor 801 executes the generation of a corresponding vegetation mask in the target pixel area based on the attribute information indicated by the vegetation key information, and the generation of corresponding vegetation on the vegetation mask, it is specifically used to: generate an initial vegetation mask in the target pixel area of the terrain height map based on the vegetation density.
[0264] The initial vegetation mask is enhanced to generate a vegetation mask corresponding to the target pixel region.
[0265] Based on the vegetation type, generate the corresponding vegetation on the vegetation mask.
[0266] In one feasible implementation, when the processor 801 generates an initial vegetation mask within a target pixel region of a topographic height map based on vegetation density, it specifically determines the area and shape of the initial vegetation mask based on the vegetation density.
[0267] Based on the area and shape of the initial vegetation mask, an initial vegetation mask is generated within the target pixel area.
[0268] In one feasible implementation, when the processor 801 is executing the determination of the area and shape of the initial vegetation cover based on the vegetation density, it is specifically used to: input the vegetation density as input data into the diffusion-limited cohesion algorithm, and calculate the number of particles at each key point in the target pixel area through the diffusion-limited cohesion algorithm.
[0269] The area and shape of the initial vegetation cover are determined based on the number of particles at each key point.
[0270] In one feasible implementation, when the processor 801 performs the action of generating an initial vegetation mask within a target pixel region based on the area and shape of the initial vegetation mask, it is specifically used to: generate a current vegetation mask based on the area and shape of the initial vegetation mask.
[0271] The current vegetation mask is binarized and Gaussian blurred to obtain the initial vegetation mask.
[0272] In one feasible implementation, when the processor 801 performs enhancement processing on the initial vegetation mask to generate the vegetation mask corresponding to the target pixel region, it specifically performs the following:
[0273] Based on the pre-generated noisy image, the initial vegetation mask is processed to generate the first processed vegetation mask.
[0274] Gaussian blur is applied to the vegetation mask after the first processing to generate the vegetation mask after the second processing.
[0275] Extract the edge data corresponding to the target pixel region from the terrain height map, and process the second-processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region.
[0276] In one feasible implementation, when the processor 801 generates the noisy image, it is specifically used to: determine the noise attribute parameters of each consecutive image region in the initial noisy image;
[0277] Based on the noise attribute parameters of each consecutive image region, noise information for each consecutive image region is generated sequentially; the noise attribute parameters of each consecutive image region are not completely the same.
[0278] Based on the noise information of each consecutive image region, an intermediate noise image is generated;
[0279] Based on the size of each pixel value in the intermediate noise image and a preset threshold, the intermediate noise image is color-converted to obtain a noise image, which includes black and white regions.
[0280] In one feasible implementation, when the processor 801 processes the initial vegetation mask according to the pre-generated noise image to generate a first processed vegetation mask, it specifically performs the following: subtracting the pixels of the white area in the initial vegetation mask from the pixels of the black area in the noise image that fall into the white area to generate the first processed vegetation mask.
[0281] In one feasible implementation, when the processor 801 extracts the edge data corresponding to the target pixel region in the terrain height map, it is specifically used to: perform Gaussian blur processing on the terrain height map to generate a processed terrain height map.
[0282] An edge processing algorithm is used to perform edge calculations on the target pixel region in the processed terrain height map to obtain the edge data corresponding to the target pixel region. The edge data is used to indicate the contour information of the object in the target pixel region.
[0283] In one feasible implementation, when the processor 801 processes the second processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region, it specifically performs the following: performs a difference operation between the second processed vegetation mask and the edge data to obtain the vegetation mask corresponding to the target pixel region.
[0284] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.
[0285] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0286] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0287] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0288] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for generating surface vegetation, characterized in that, include: Obtain a terrain elevation map and determine the orientation information corresponding to each pixel region in the terrain elevation map; The system parses the natural language input by the user to extract key vegetation information. This key vegetation information indicates the location of the vegetation to be generated on the topographic elevation map and the attribute information of the vegetation, including vegetation type and vegetation density. The natural language input includes relevant information about the vegetation to be generated. Based on the key vegetation information and the directional information corresponding to each pixel region in the terrain elevation map, vegetation is generated and displayed in the terrain elevation map; Determining the azimuth information corresponding to each pixel region in the terrain height map includes: The terrain elevation map is divided according to a preset area division method to determine at least one pixel area; Based on the preset orientation definition method, determine the orientation information corresponding to each pixel region.
2. The method according to claim 1, characterized in that, The process of parsing the natural language and extracting key vegetation information includes: The natural language is parsed to obtain multiple sets of query information; The query information of each group is matched with the standard information in the pre-created template library, and the key vegetation information indicated by each group of query information is obtained based on the matching results.
3. The method according to claim 2, characterized in that, The creation process of the template library includes: Based on the orientation definition method of the terrain elevation map, at least one standard orientation description information corresponding to each orientation is generated; Based on the vegetation density classification method, generate at least one standard density description information corresponding to each density level; The template library is generated based on at least one standard orientation description for each orientation and at least one standard orientation description for each density level.
4. The method according to claim 1, characterized in that, The step of generating and displaying vegetation in the terrain elevation map based on the key vegetation information and the azimuth information corresponding to each pixel region in the terrain elevation map includes: Based on the location indicated by the key vegetation information and the directional information corresponding to each pixel region in the terrain elevation map, the target pixel region corresponding to the location is determined; Based on the attribute information indicated by the key vegetation information, a corresponding vegetation mask is generated in the target pixel area, and corresponding vegetation is generated on the vegetation mask.
5. The method according to claim 4, characterized in that, The step of generating a corresponding vegetation mask in the target pixel region based on the attribute information indicated by the vegetation key information, and generating corresponding vegetation on the vegetation mask, includes: Based on the vegetation density, an initial vegetation mask is generated within the target pixel area of the terrain height map; The initial vegetation mask is enhanced to generate a vegetation mask corresponding to the target pixel region. Based on the vegetation type, generate corresponding vegetation on the vegetation mask.
6. The method according to claim 5, characterized in that, The step of generating an initial vegetation mask within the target pixel region of the terrain height map based on the vegetation density includes: Based on the vegetation density, determine the area and shape of the initial vegetation cover; The initial vegetation mask is generated within the target pixel area based on the area and shape of the initial vegetation mask.
7. The method according to claim 6, characterized in that, Determining the area and shape of the initial vegetation cover based on the vegetation density includes: The vegetation density is used as input data and input into the diffusion-limited cohesion algorithm. The diffusion-limited cohesion algorithm is used to calculate and determine the number of particles at each key point in the target pixel area. The area and shape of the initial vegetation cover are determined based on the number of particles at each key point.
8. The method according to claim 6, characterized in that, The step of generating the initial vegetation mask within the target pixel area based on the area and shape of the initial vegetation mask includes: The current vegetation cover is generated based on the area and shape of the initial vegetation cover; The current vegetation mask is binarized and Gaussian blurred to obtain the initial vegetation mask.
9. The method according to claim 5, characterized in that, The enhancement process for the initial vegetation mask to generate the vegetation mask corresponding to the target pixel region includes: The initial vegetation mask is processed based on the pre-generated noise image to generate a first processed vegetation mask. Gaussian blur is applied to the first processed vegetation mask to generate the second processed vegetation mask. Extract the edge data corresponding to the target pixel region in the terrain height map, and process the second-processed vegetation mask according to the edge data to generate the vegetation mask corresponding to the target pixel region.
10. The method according to claim 9, characterized in that, The process of generating the noisy image includes: Determine the noise attribute parameters of each consecutive image region in the initial noisy image; Based on the noise attribute parameters of each consecutive image region, noise information for each consecutive image region is generated sequentially; the noise attribute parameters of each consecutive image region are not completely the same. Based on the noise information of each consecutive image region, an intermediate noise image is generated; Based on the size of each pixel value in the intermediate noise image and a preset threshold, the intermediate noise image is color-converted to obtain the noise image, which includes black areas and white areas.
11. The method according to claim 9, characterized in that, The step of processing the initial vegetation mask based on the pre-generated noise image to generate a first processed vegetation mask includes: The first processed vegetation mask is generated by subtracting the pixels in the white area of the initial vegetation mask from the pixels in the black area of the noise image that fall into the white area.
12. The method according to claim 9, characterized in that, The step of extracting the edge data corresponding to the target pixel region in the terrain height map includes: The terrain height map is subjected to Gaussian blurring to generate a processed terrain height map; An edge processing algorithm is used to perform edge calculation on the target pixel region in the processed terrain height map to obtain the edge data corresponding to the target pixel region. The edge data is used to indicate the contour information of the object in the target pixel region.
13. The method according to claim 9, characterized in that, The step of processing the second processed vegetation mask based on the edge data to generate the vegetation mask corresponding to the target pixel region includes: The difference between the second processed vegetation mask and the edge data is calculated to obtain the vegetation mask corresponding to the target pixel region.
14. A surface vegetation generation device, characterized in that, include: Acquisition module, analysis module, and generation module; The acquisition module is used to acquire a terrain height map and determine the orientation information corresponding to each pixel region in the terrain height map; The analysis module is used to parse the natural language input by the user and extract key vegetation information. The key vegetation information is used to indicate the location of the vegetation to be generated on the topographic elevation map and the attribute information of the vegetation, including: vegetation type and vegetation density; the natural language includes relevant information of the vegetation to be generated. The generation module is used to generate and display vegetation in the terrain height map based on the key vegetation information and the directional information corresponding to each pixel region in the terrain height map. The acquisition module is specifically used to divide the terrain height map according to a preset area division method and determine at least one pixel area; Based on the preset orientation definition method, determine the orientation information corresponding to each pixel region.
15. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores program instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to implement the surface vegetation generation method as described in any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which is executed by a processor to implement the surface vegetation generation method as described in any one of claims 1 to 13.
Citation Information
Patent Citations
Target vegetation model rendering display method and device, equipment and storage medium
CN112862968A
Vegetation generation method and device in virtual scene and electronic equipment
CN115518374A