Terrain hybrid map generation method, device, equipment and storage medium
By determining and sorting effective areas in multi-layer terrain mixed layers and performing embedding processing, the problem of inter-channel faults is solved and the picture quality is improved.
Patent Information
- Application Number
- CN202311723775.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2043-12-14
AI Technical Summary
In the existing technology, the index mark sorting method of multi-layered terrain mixed layers causes inter-channel gaps and thin lines to appear, which reduces the quality of the picture.
By obtaining multi-layered terrain mixed layers, the effective area is determined, and the effective area is sorted from large to small according to the total area of the effective area, and the effective area is embedded in the terrain mixed layer with a small total area of the effective area to a terrain mixed layer with a large area. , generate a terrain blend map to avoid gaps between channels.
Effectively remove thin lines in hybrid maps, improve picture quality, and make hybrid maps coherent.
Smart Images

Figure CN117808928B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a terrain mixed map generation method, device, equipment and storage medium. Background Art
[0002] In the related art, complex terrain can be blended by using a multi-layer terrain blending layer. Terrain blending can be achieved through an index identification map (IDMap) and a blending value map (BlendMap), and the premise of using this solution is that the valid blending values corresponding to each pixel point need to be limited to a certain number, such as 3 layers. Among them, the valid blending value is a value greater than 0. On this basis, the valid blending values in each layer of terrain blending layer can be extracted, and the index identification and blending value of the current pixel point can be written into the RGB three channels of the index identification map and the blending value map in the order of the index identification.
[0003] like Figure 1 As shown, assuming there are 6 terrain blending layers, take two pixels as an example, including pixel A in the first row and first column and pixel B in the first row and second column. Their corresponding blending values in different terrain blending layers are as follows Figure 1 As shown, the solid dots indicate that the current mixed value is valid, and the hollow dots indicate that the current mixed value is invalid. As can be seen from the figure, in layer 0: the mixed value corresponding to pixel A is invalid, and the mixed value corresponding to pixel B is valid; in layer 1: the mixed value corresponding to pixel A is valid, and the mixed value corresponding to pixel B is valid; in layer 2: the mixed value corresponding to pixel A is invalid, and the mixed value corresponding to pixel B is invalid; in layer 3: the mixed value corresponding to pixel A is valid, and the mixed value corresponding to pixel B is invalid; in layer 4: the mixed value corresponding to pixel A is valid, and the mixed value corresponding to pixel B is invalid; in layer 5: the mixed value corresponding to pixel A is invalid, and the mixed value corresponding to pixel B is invalid.
[0004] According to the solution provided by the related technology, the index identifiers of the pixels with valid mixed values in each layer are arranged in sequence in the three RGB channels. Figure 1 In the example shown, the values recorded in the three RGB channels are:
[0005] R: 1 0
[0006] G: 3 1
[0007] B: 4 0
[0008] It can be seen from the above example that for a 1-layer terrain hybrid layer, due to the problem of index identifier sorting, the index identifiers of the two adjacent pixels A and B have a channel fault. As a result, when the hybrid map is rendered by sampling the corresponding hybrid value through the index identifier with the channel fault, thin lines will appear in the hybrid map, reducing the quality of the picture. Summary of the invention
[0009] The embodiment of the present invention provides a terrain hybrid map generation method, device, equipment and storage medium, which are used to remove channel discontinuities, remove fine lines in a hybrid map, and improve picture quality.
[0010] In a first aspect, an embodiment of the present invention provides a method for generating a terrain hybrid map, the method comprising:
[0011] Acquire a multi-layer terrain hybrid layer, wherein each of the multi-layer terrain hybrid layers records terrain hybrid layer information of a corresponding terrain hybrid layer, and the number of valid hybrid layers recorded by any pixel point in the multi-layer terrain hybrid layer is less than or equal to a preset threshold;
[0012] Determine the valid area in each terrain mixed layer based on the mixed value corresponding to each pixel point in each terrain mixed layer;
[0013] Sorting the plurality of terrain blending layers in descending order of the total area of the effective regions;
[0014] Based on the sorting results and the preset embedding rules, the effective areas in the terrain hybrid layer with a smaller total area of the effective areas are embedded into a first preset number of terrain hybrid layers with a larger total area of the effective areas;
[0015] Based on the first preset number of terrain blending layers that have been embedded, a terrain blending map is generated.
[0016] Optionally, determining the valid area in each terrain mixed layer based on the mixed value corresponding to each pixel point in each terrain mixed layer includes:
[0017] For a first terrain hybrid layer among the multiple terrain hybrid layers, sequentially traverse the pixel points in the first terrain hybrid layer to determine whether the hybrid value corresponding to the currently traversed pixel point is valid, wherein the first terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers;
[0018] Determine multiple adjacent pixel points with valid mixing values in the first terrain mixing layer as areas to be validated, and obtain at least one area to be validated contained in the first terrain mixing layer;
[0019] At least one valid area in the first terrain blending layer is determined based on the at least one area to be validated.
[0020] Optionally, the determining, based on the at least one area to be effective, at least one effective area in the first terrain hybrid layer comprises:
[0021] For any area to be validated among the at least one area to be validated, determining surrounding pixel points adjacent to the area to be validated in the first terrain hybrid layer;
[0022] Any of the to-be-validated areas and the surrounding pixel points are determined as valid areas in the first terrain hybrid layer.
[0023] Optionally, before sorting the plurality of terrain hybrid layers in descending order of the total area of the effective regions, the method further comprises:
[0024] For a second terrain hybrid layer among the multiple terrain hybrid layers, determining a small effective area whose area does not meet a preset area requirement among all effective areas in the second terrain hybrid layer, wherein the second terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers;
[0025] The small valid region is removed from all valid regions in the second terrain blending layer.
[0026] Optionally, embedding the effective areas in the terrain hybrid layer with a smaller total area of effective areas into a first preset number of terrain hybrid layers with a larger total area of effective areas based on the sorting result and the preset embedding rule includes:
[0027] According to the sorting results, obtain the target terrain mixed layer with the largest total area in the current sorting;
[0028] Embedding valid areas of a plurality of other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer, and removing valid areas of the plurality of other terrain hybrid layers that have been embedded into the target terrain hybrid layer, wherein the plurality of other terrain hybrid layers are terrain hybrid layers other than the target terrain hybrid layer in the plurality of terrain hybrid layers;
[0029] The embedded target terrain hybrid layer is removed from the multiple terrain hybrid layers and output, and execution is performed according to the sorting result to obtain the target terrain hybrid layer with the largest total area in the current sorting until the first preset number of cycles are executed.
[0030] Optionally, embedding valid areas of a plurality of other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer includes:
[0031] For any other terrain hybrid layer among the multiple other terrain hybrid layers, sequentially obtaining valid areas in the any other terrain hybrid layer according to a preset order;
[0032] Whenever a valid area in any other terrain hybrid layer is obtained, determining whether the currently obtained valid area coincides with any valid area in the target terrain hybrid layer in position;
[0033] If the currently acquired valid area does not overlap with any valid area in the target terrain hybrid layer in terms of position, the currently acquired valid area is embedded into a corresponding position in the target terrain hybrid layer.
[0034] Optionally, the first preset number is 4, and generating a terrain blending map based on the first preset number of terrain blending layers that have been embedded includes:
[0035] The index identifiers of the terrain blending layers corresponding to the pixels with valid blending values in the first preset number of terrain blending layers that have been embedded and the corresponding blending values are output to two terrain blending maps respectively, wherein the terrain blending maps are four-channel ARGB maps.
[0036] In a second aspect, an embodiment of the present invention provides a terrain hybrid map generating device, comprising:
[0037] An acquisition module, used for acquiring a multi-layer terrain hybrid layer, wherein each of the multi-layer terrain hybrid layers records terrain hybrid layer information of a corresponding terrain hybrid layer, and the number of valid hybrid layers recorded by any pixel point in the multi-layer terrain hybrid layer is less than or equal to a preset threshold;
[0038] A determination module, used to determine the valid area in each terrain mixed layer based on the mixed value corresponding to each pixel point in each terrain mixed layer;
[0039] A sorting module, used for sorting the plurality of terrain hybrid layers in descending order of the total area of the effective regions;
[0040] An embedding module, for embedding the effective areas in the terrain hybrid layer with a smaller total area of the effective areas into a first preset number of terrain hybrid layers with a larger total area of the effective areas based on the sorting result and the preset embedding rule;
[0041] A generation module is used to generate a terrain blending map based on the first preset number of terrain blending layers that have been embedded.
[0042] Optionally, the determining module is used to:
[0043] For a first terrain hybrid layer among the multiple terrain hybrid layers, sequentially traverse the pixel points in the first terrain hybrid layer to determine whether the hybrid value corresponding to the currently traversed pixel point is valid, wherein the first terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers;
[0044] Determine multiple adjacent pixel points with valid mixing values in the first terrain mixing layer as areas to be validated, and obtain at least one area to be validated contained in the first terrain mixing layer;
[0045] At least one valid area in the first terrain blending layer is determined based on the at least one area to be validated.
[0046] Optionally, the determining module is used to:
[0047] For any area to be validated among the at least one area to be validated, determining surrounding pixel points adjacent to the area to be validated in the first terrain hybrid layer;
[0048] Any of the to-be-validated areas and the surrounding pixel points are determined as valid areas in the first terrain hybrid layer.
[0049] Optionally, the device further comprises a removal module, wherein the removal module is configured to:
[0050] For a second terrain hybrid layer among the multiple terrain hybrid layers, determining a small effective area whose area does not meet a preset area requirement among all effective areas in the second terrain hybrid layer, wherein the second terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers;
[0051] The small valid region is removed from all valid regions in the second terrain blending layer.
[0052] Optionally, the embedded module is used to:
[0053] According to the sorting results, obtain the target terrain mixed layer with the largest total area in the current sorting;
[0054] Embedding valid areas of a plurality of other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer, and removing valid areas of the plurality of other terrain hybrid layers that have been embedded into the target terrain hybrid layer, wherein the plurality of other terrain hybrid layers are terrain hybrid layers other than the target terrain hybrid layer in the plurality of terrain hybrid layers;
[0055] The embedded target terrain hybrid layer is removed from the multiple terrain hybrid layers and output, and execution is performed according to the sorting result to obtain the target terrain hybrid layer with the largest total area in the current sorting until the first preset number of cycles are executed.
[0056] Optionally, the embedded module is used to:
[0057] For any other terrain hybrid layer among the multiple other terrain hybrid layers, sequentially obtaining valid areas in the any other terrain hybrid layer according to a preset order;
[0058] Whenever a valid area in any other terrain hybrid layer is obtained, determining whether the currently obtained valid area coincides with any valid area in the target terrain hybrid layer in position;
[0059] If the currently acquired valid area does not overlap with any valid area in the target terrain hybrid layer in terms of position, the currently acquired valid area is embedded into a corresponding position in the target terrain hybrid layer.
[0060] Optionally, the first preset number is 4, and the generating module is used to:
[0061] The index identifiers of the terrain blending layers corresponding to the pixels with valid blending values in the first preset number of terrain blending layers that have been embedded and the corresponding blending values are output to two terrain blending maps respectively, wherein the terrain blending maps are four-channel ARGB maps.
[0062] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the terrain hybrid map generation method in the first aspect.
[0063] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the terrain hybrid map generation method in the first aspect.
[0064] By adopting the present invention, effective areas can be divided in different terrain mixed layers according to whether the mixed values of each pixel point in different terrain mixed layers are effective, and then the effective areas in the terrain mixed layers with a small total area of the effective areas are embedded into a first preset number of terrain mixed layers with a large total area of the effective areas, and finally a terrain mixed map is output based on the first preset number of terrain mixed layers. In this way, since multiple pixel points with effective mixed values and continuous positions in the same terrain mixed layer have been merged into one effective area in advance, the embedding process is also performed according to the effective area as a unit, so the generation of channel discontinuities can be avoided, and the thin lines in the mixed map can be effectively removed, so that the mixed map is coherent, and the picture quality is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0066] Figure 1 A schematic diagram of a terrain hybrid layer provided by an embodiment of the present invention;
[0067] Figure 2 A schematic diagram of a flow chart of a method for generating a terrain hybrid map provided by an embodiment of the present invention;
[0068] Figure 3 A schematic diagram of a method for screening a small effective area provided by an embodiment of the present invention;
[0069] Figure 4 A schematic diagram of a flow chart of an embedding process provided by an embodiment of the present invention;
[0070] Figure 5 A schematic diagram of a scenario of an embedding process provided by an embodiment of the present invention;
[0071] Figure 6 A schematic diagram of the structure of a terrain hybrid map generating device provided by an embodiment of the present invention;
[0072] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0074] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0075] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0076] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0077] Figure 2 The present invention provides a flow chart of a method for generating a terrain hybrid map, which can be applied to electronic devices. Figure 2 As shown, the method comprises the following steps:
[0078] 201. Obtain a multi-layer terrain hybrid layer, wherein each of the multi-layer terrain hybrid layers records terrain hybrid layer information of a corresponding terrain hybrid layer, and the number of valid hybrid layers recorded by any pixel point in the multi-layer terrain hybrid layer is less than or equal to a preset threshold.
[0079] 202. Determine a valid area in each terrain mixed layer based on the mixed value corresponding to each pixel point in each terrain mixed layer.
[0080] 203. Sort multiple terrain blending layers in descending order of the total area of the effective area.
[0081] 204. Based on the sorting result and the preset embedding rule, embed the effective areas in the terrain hybrid layer with a smaller total effective area into a first preset number of terrain hybrid layers with a larger total effective area.
[0082] 205. Generate a terrain blending map based on the first preset number of terrain blending layers that have been embedded.
[0083] In practical applications, complex terrain structures can be drawn by using multi-layer terrain blending layers. In the embodiment of the present invention, the number of layers of the multi-layer terrain blending layers can be set within a certain range, such as at least four layers and at most sixteen layers.
[0084] It should be noted that the size of each terrain blending layer in the multi-layer terrain blending layer is consistent, and the terrain blending layer is used to store blending values (terrain blending layer information). Based on this, each pixel point can correspond to different blending values in different terrain blending layers. For example, the effective value corresponding to the pixel point i in the first row and first column in the first layer of terrain blending layer is A, the effective value corresponding to the pixel point i in the second layer of terrain blending layer is B, and the effective value corresponding to the pixel point i in the third layer of terrain blending layer is C...
[0085] It is understandable that not all mixed values of pixels in all terrain mixed layers are valid values. Specifically, it can be defined that when the mixed value is greater than 0, the mixed value is considered valid, and when the mixed value is equal to 0, the mixed value is considered invalid. Based on this, for any terrain mixed layer, there are some areas where the mixed values of pixels are valid, and there are other areas where the mixed values of pixels are invalid. This is equivalent to that for any pixel, not all its mixed values in all terrain mixed layers are valid.
[0086] In fact, when designing terrain blending layers, artists can be required to design according to the following requirements: ensure that the number of layers of effective blending values of any pixel in all terrain blending layers is less than or equal to a preset threshold. The preset threshold can be 3, for example. That is to say, for any pixel, the number of layers of effective blending values in all terrain blending layers needs to be less than or equal to 3. For example, assuming there is a pixel i, the total number of layers of terrain blending layers is 16, and the blending values corresponding to pixel i in the 13th to 15th layers of terrain blending layers are valid, and the corresponding blending values in other layers are invalid, then it can be considered that the number of layers of effective blending values corresponding to pixel i in all terrain blending layers is 3.
[0087] Alternatively, an embodiment of the present invention also provides another method to ensure that the number of layers in which the mixed value of any pixel point in all terrain mixed layers is valid is less than or equal to a preset threshold. In this method, the artist is not required to strictly design according to the aforementioned requirements. After the artist designs multiple layers of terrain mixed layers, for any pixel point i, the mixed value corresponding to the pixel point i in all terrain mixed layers can be obtained, and the invalid mixed values can be removed therefrom. Then, the remaining mixed values can be sorted in order from large to small, and then the mixed values ranked in the top 3 can be taken, and the mixed values ranked outside the top 3 can be removed. This method can be executed for each pixel point, so that the number of layers in which the mixed value of any pixel point in all terrain mixed layers is valid is less than or equal to the preset threshold.
[0088] After obtaining multiple layers of terrain blending layers and ensuring that the number of layers in which the blending value of any pixel point in all terrain blending layers is valid is less than or equal to a preset threshold, the valid area in each terrain blending layer can be determined based on the blending value corresponding to each pixel point in each terrain blending layer.
[0089] In some optional embodiments, the process of determining the valid areas in each terrain hybrid layer can be implemented as follows: for a first terrain hybrid layer among multiple terrain hybrid layers, traverse the pixel points in the first terrain hybrid layer in turn, and determine whether the mixing value corresponding to the currently traversed pixel point is valid, wherein the first terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers; determine multiple adjacent pixel points in the first terrain hybrid layer whose mixing values are valid as areas to be effective, and obtain at least one area to be effective contained in the first terrain hybrid layer; based on the at least one area to be effective, determine at least one valid area in the first terrain hybrid layer.
[0090] In practical applications, multiple pixels with valid and continuous mixed values in the first terrain mixed layer can be determined as a waiting effective area. In a possible implementation, the process can be implemented as follows: starting from the first row and first column of pixels, determine whether the mixed value of the current pixel in the first terrain mixed layer is valid. If valid, obtain the pixel adjacent to the current pixel in the first terrain mixed layer, where the adjacent pixel can be, for example, a pixel located above, below, to the right, to the left, diagonally above, or diagonally below the current pixel. After obtaining the adjacent pixel, determine whether the mixed value of any adjacent pixel in the first terrain mixed layer is valid. If valid, put the pixel with valid mixed value into the pre-created target queue. Obtain the pixel from the target queue in turn, use the obtained pixel as the above-mentioned current pixel, and then go to execute the acquisition of the pixel adjacent to the current pixel in the first terrain mixed layer, and execute from this step until there are no more pixels in the target queue. In this process, all the pixels with valid mixed values found can be recorded.
[0091] Finally, the area formed by the pixels with valid mixed values is a waiting area. After finding a waiting area, you can start looking for pixels with valid mixed values that have not been included in any waiting area from the first row and the first column, and then determine the next waiting area in accordance with the above method until all pixels in the first terrain mixed layer are traversed and no new waiting area can be found.
[0092] At least one valid area in the first terrain hybrid layer can be determined based on at least one area to be validated in the first terrain hybrid layer. Optionally, the process can be implemented as follows: for any area to be validated in the at least one area to be validated, surrounding pixels adjacent to any area to be validated in the first terrain hybrid layer are determined; any area to be validated and surrounding pixels are determined as valid areas in the first terrain hybrid layer.
[0093] In practical applications, for any area s to be effective in the first terrain hybrid layer, the surrounding pixel points adjacent to the area s to be effective can be determined, that is, the surrounding pixel points surrounding the area s to be effective. For example, to give a simple example, assuming that the area s to be effective is a square, a circle of pixel points surrounding the square can be used as the above-mentioned surrounding pixel points. Finally, the area s to be effective and its corresponding surrounding pixel points can be determined together as a corresponding effective area. In this way, the effective areas corresponding to each area to be effective in the first terrain hybrid layer can be found one by one to obtain all the effective areas in the first terrain hybrid layer.
[0094] Optionally, the method provided by the embodiment of the present invention may further include: for a second terrain hybrid layer among multiple terrain hybrid layers, determining a small-area valid area whose area does not meet a preset area requirement among all valid areas in the second terrain hybrid layer, wherein the second terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers; and removing the small-area valid area from all valid areas in the second terrain hybrid layer.
[0095] It should be noted that, for the second terrain hybrid layer among the multiple terrain hybrid layers, the small effective areas whose areas do not meet the preset area requirements in all the effective areas in the second terrain hybrid layer can be determined. Generally speaking, the effective areas that do not meet the preset area requirements are effective areas with smaller effective areas, which can be called small effective areas. These small effective areas will interfere with the subsequent merging process of multiple terrain hybrid layers. Therefore, the small effective areas in each terrain hybrid layer can be found first, and these small effective areas can be temporarily removed. After the remaining effective areas are processed, these small effective areas can be processed in reverse.
[0096] The following describes a method for determining a small effective area in the second terrain hybrid layer. Optionally, for any effective area n in the second terrain hybrid layer, edge pixels of the effective area n can be determined, and then the edge pixels can be removed; the aforementioned steps can be repeated for a preset number of times; the remaining area portion is compared with the original effective area n, and based on the remaining area portion, the remaining area portion is restored along the removed edge.
[0097] It should be noted that only valid areas that still have some remaining area before restoration can be restored, and those valid areas that have been completely removed have no remaining area and therefore cannot be restored. Based on this, the number of removals can be set, so that after executing the number of removals, valid areas with small areas will have no remaining area, that is, the area is empty, so that the original valid areas cannot be restored later, and only valid areas with large areas can be restored and retained, and valid areas with small areas will be removed.
[0098] like Figure 3 As shown, for a simple example, assuming that there are two hexagonal valid areas A and B, and the removal process is performed four times, it can be seen that the valid area B has no remaining area when the third removal process is performed. Therefore, in the subsequent recovery process, only the valid area A can be recovered, and the valid area B is completely removed.
[0099] Next, multiple terrain hybrid layers can be sorted in descending order of the total area of the valid areas. For example, assuming that terrain hybrid layer p is a terrain hybrid layer among multiple terrain hybrid layers, the terrain hybrid layer p contains three valid areas, namely, valid areas a, b, and c, and the areas of the three valid areas are s1, s2, and s3 respectively, then the total area of the valid areas in the terrain hybrid layer p is s1+s2+s3. In this way, the total area of the valid areas in each terrain hybrid layer can be calculated one by one, and then the multiple terrain hybrid layers can be sorted in descending order of the total area of the valid areas.
[0100] Next, based on the sorting result and the preset embedding rule, the effective areas in the terrain hybrid layer with a small total effective area can be embedded into a first preset number of terrain hybrid layers with a large total effective area.
[0101] Alternatively, if Figure 4 As shown, the above embedding process can be implemented as follows:
[0102] 401. According to the sorting result, obtain the target terrain mixed layer with the largest total area in the current sorting.
[0103] 402. Embed valid areas of multiple other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer, and remove valid areas of multiple other terrain hybrid layers that have been embedded in the target terrain hybrid layer, wherein the multiple other terrain hybrid layers are terrain hybrid layers other than the target terrain hybrid layer in the multiple terrain hybrid layers.
[0104] 403. Remove and output the embedded target terrain hybrid layer from the multiple terrain hybrid layers, and go to step 401 to continue executing until the first preset number of loops are completed.
[0105] In practical applications, after sorting multiple terrain hybrid layers in descending order according to the total area of the valid areas, the target terrain hybrid layer with the largest total area in the current sorting can be obtained according to the sorting results. Then, the other terrain hybrid layers except the target terrain hybrid layer can be traversed one by one, and the valid areas in the other terrain hybrid layers that meet the preset embedding conditions can be embedded into the target terrain hybrid layer. It can be understood that this method can embed the invalid area in the target terrain hybrid layer into the valid area of other terrain hybrid layers, wherein the invalid area refers to the area other than the valid area in the target terrain hybrid layer.
[0106] Not all valid areas in other terrain hybrid layers can be embedded into the target terrain hybrid layer. Only valid areas whose locations meet the preset embedding conditions can be embedded into the target terrain hybrid layer. Therefore, if a valid area in other terrain hybrid layers is embedded into the target terrain hybrid layer, the valid area can be removed from the other terrain hybrid layer. In this way, there are still valid areas in other terrain hybrid layers that have not been embedded.
[0107] After traversing all other terrain hybrid layers, all valid areas that can be embedded in the target terrain hybrid layer have been embedded in the target terrain hybrid layer, and the remaining are valid areas that cannot be embedded. After completing this process, the embedded target terrain hybrid layer can be output, and the target terrain hybrid layer can be removed from the current sorting, so that the terrain hybrid layer whose total area of the valid area is sorted after the target terrain hybrid layer can be used as the target terrain hybrid layer of a new round, and then the process can be turned to step 401 to continue execution from step 401.
[0108] Referring to the above method, the first preset number of times of loop execution can be performed, and each loop can output a target terrain hybrid layer that has been embedded, so that the first preset number of target terrain hybrid layers that have been embedded can be output. The first preset number can be, for example, 4, and after completing 4 loop processes, 4 layers of target terrain hybrid layers that have been embedded can be output.
[0109] In some optional embodiments, the process of embedding valid areas in multiple other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer can be implemented as follows: for any other terrain hybrid layer among the multiple other terrain hybrid layers, the valid areas in any other terrain hybrid layer are obtained in sequence according to a preset order; whenever a valid area in any other terrain hybrid layer is obtained, it is determined whether the currently obtained valid area coincides with any valid area in the target terrain hybrid layer in position; if the currently obtained valid area does not coincide with any valid area in the target terrain hybrid layer in position, the currently obtained valid area is embedded into the corresponding position in the target terrain hybrid layer.
[0110] The above-mentioned according to a preset order may refer to according to the position order or according to the total area size of the effective area, etc.
[0111] Assuming that the other terrain hybrid layer i is currently being processed, a valid area in the other terrain hybrid layer i can be obtained in sequence according to a preset order. Assuming that the currently obtained valid area is p, it is possible to detect whether the valid area p coincides with any valid area in the target terrain hybrid layer while keeping the absolute position of the valid area p unchanged. If the valid area p does not coincide with any valid area in the target terrain hybrid layer, the valid area p can be embedded into the target terrain hybrid layer according to the absolute position of the valid area p.
[0112] The above absolute position means that the position of the effective area p in other terrain blending layers is exactly the same as the position in the target terrain blending layer. For example, if the effective area p contains two pixels a and b, and the effective area p is located at pixels a and b in other terrain blending layers, then it should also be set at the positions of pixels a and b in the target terrain blending layer.
[0113] For ease of understanding, the embedding process is explained below with a specific example. Here we only use a simple example to illustrate the embedding process. In actual processing, the terrain blending layer is much more complicated. Figure 5 As shown in the figure, it is assumed that there are three terrain hybrid layers, including terrain hybrid layers A1, A2, and A3, which are sorted from large to small according to the total area of the effective area: A2, A3, and A1. It is assumed that the effective area in terrain hybrid layer A1 is p1, the effective area in terrain hybrid layer A2 is p2, and the effective area in terrain hybrid layer A3 is p3. According to the sorting result of the total area of the effective area, the terrain hybrid layer A2 can be used as a template, and the effective areas in terrain hybrid layers A1 and A3 can be embedded into the terrain hybrid layer A2 according to the rules.
[0114] Based on this, the valid area p1 in the terrain hybrid layer A1 can be obtained to detect whether the valid area p1 overlaps with the valid area p2 in the terrain hybrid layer A2. Assuming that the two do not overlap, the valid area p1 can be embedded in the terrain hybrid layer A2 according to the absolute position of the valid area p1. Similarly, the valid area p3 in the terrain hybrid layer A3 can be obtained to detect whether the valid area p3 overlaps with the valid area p2 and the valid area p1 in the terrain hybrid layer A2. Assuming that the valid area p3 does not overlap with the valid area p2 and the valid area p1, the valid area p3 can be embedded in the terrain hybrid layer A2 according to the absolute position of the valid area p3.
[0115] In another optional embodiment, the process of embedding the effective area in the terrain hybrid layer with a small total effective area into the first preset number of terrain hybrid layers with a large total effective area can also be understood as merging the effective areas in all terrain hybrid layers into the first preset number of terrain hybrid layers as much as possible. However, not all situations are ideal. In some cases, after the first preset number of merging processes, there are still effective areas in the terrain hybrid layers other than the first preset number of terrain hybrid layers that cannot be directly merged into the first preset number of terrain hybrid layers. For these remaining effective areas, they can be cut so that the cut effective areas can still be embedded in different terrain hybrid layers in the first preset number of terrain hybrid layers according to the absolute positions of each part.
[0116] In another optional embodiment, as described above, before sorting each terrain hybrid layer according to the total area of their respective effective areas, small effective areas in each terrain hybrid layer can be identified and removed. After completing the above process of embedding the effective areas in the terrain hybrid layer with a small total effective area into the first preset number of terrain hybrid layers with a large total effective area, the small effective areas removed previously can be embedded in reverse. The specific embedding method is consistent with the embedding method of the effective area with a larger area, and can be implemented with reference to the description above. In addition, for a small part of the small effective area that still cannot be embedded into the first preset number of terrain hybrid layers, it can also be cut so that the cut small effective area can be embedded into different terrain hybrid layers in the first preset number of terrain hybrid layers according to the absolute position of each part.
[0117] Referring to the above method, the effective area in the terrain hybrid layer with a small total area of the effective area can be embedded into the first preset number of terrain hybrid layers with a large total area of the effective area. After the embedding is completed, a terrain hybrid map can be generated based on the first preset number of terrain hybrid layers that have been embedded.
[0118] In some optional embodiments, the process of generating a terrain blending map can be implemented as follows: the index identifiers of the terrain blending layers corresponding to the pixel points with valid blending values in the first preset number of terrain blending layers that have been embedded and the corresponding blending values are output to two terrain blending maps respectively, wherein the terrain blending map is a four-channel ARGB map.
[0119] In an embodiment of the present invention, the above-mentioned first preset number can be set to 4, for example. Accordingly, 4 completely embedded terrain blending layers can be obtained, and then the index identifiers of the terrain blending layers corresponding to the pixel points with valid blending values in the 4 completely embedded terrain blending layers and the corresponding blending values can be output to two ARGB maps respectively.
[0120] For example, assuming that the terrain blending layer i is one of the four terrain blending layers that have been embedded, and the blending value corresponding to the pixel point in the first row and the fifth column of the terrain blending layer i is valid, the valid blending value can be output to the corresponding channel of an ARGB map, and at the same time, the index identifier of the terrain blending layer i is output to the corresponding channel of another ARGB map. The index identifier can be, for example, the layer number of the corresponding terrain blending layer, which is used to uniquely identify the terrain blending layer.
[0121] By adopting the present invention, effective areas can be divided in different terrain mixed layers according to whether the mixed values of each pixel point in different terrain mixed layers are effective, and then the effective areas in the terrain mixed layers with a small total area of the effective areas are embedded into a first preset number of terrain mixed layers with a large total area of the effective areas, and finally a terrain mixed map is output based on the first preset number of terrain mixed layers. In this way, since multiple pixel points with effective mixed values and continuous positions in the same terrain mixed layer have been merged into one effective area in advance, the embedding process is also performed according to the effective area as a unit, so the generation of channel discontinuities can be avoided, and the thin lines in the mixed map can be effectively removed, so that the mixed map is coherent, and the picture quality is improved.
[0122] The following will describe in detail the terrain hybrid map generation device of one or more embodiments of the present invention. Those skilled in the art will appreciate that these terrain hybrid map generation devices can be configured using commercially available hardware components through the steps taught in this solution.
[0123] Figure 6 A schematic diagram of a structure of a terrain hybrid map generating device provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the device comprises:
[0124] An acquisition module 61 is used to acquire a multi-layer terrain hybrid layer, wherein each of the multi-layer terrain hybrid layers records terrain hybrid layer information of a corresponding terrain hybrid layer, and the number of valid hybrid layers recorded by any pixel point in the multi-layer terrain hybrid layer is less than or equal to a preset threshold;
[0125] A determination module 62, configured to determine a valid area in each terrain mixed layer based on a mixed value corresponding to each pixel point in each terrain mixed layer;
[0126] A sorting module 63, used to sort the multiple terrain hybrid layers in descending order of the total area of the effective area;
[0127] An embedding module 64 is used to embed the effective areas in the terrain mixed layer with a smaller total area of the effective areas into a first preset number of terrain mixed layers with a larger total area of the effective areas based on the sorting result and the preset embedding rule;
[0128] The generating module 65 is used to generate a terrain blending map based on the first preset number of terrain blending layers that have been embedded.
[0129] Optionally, the determining module 62 is used to:
[0130] For a first terrain hybrid layer among the multiple terrain hybrid layers, sequentially traverse the pixel points in the first terrain hybrid layer to determine whether the hybrid value corresponding to the currently traversed pixel point is valid, wherein the first terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers;
[0131] Determine multiple adjacent pixel points with valid mixing values in the first terrain mixing layer as areas to be validated, and obtain at least one area to be validated contained in the first terrain mixing layer;
[0132] At least one valid area in the first terrain blending layer is determined based on the at least one area to be validated.
[0133] Optionally, the determining module 62 is used to:
[0134] For any area to be validated among the at least one area to be validated, determining surrounding pixel points adjacent to the area to be validated in the first terrain hybrid layer;
[0135] Any of the to-be-validated areas and the surrounding pixel points are determined as valid areas in the first terrain hybrid layer.
[0136] Optionally, the device further comprises a removal module, wherein the removal module is configured to:
[0137] For a second terrain hybrid layer among the multiple terrain hybrid layers, determining a small effective area whose area does not meet a preset area requirement among all effective areas in the second terrain hybrid layer, wherein the second terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers;
[0138] The small valid region is removed from all valid regions in the second terrain blending layer.
[0139] Optionally, the embedding module 64 is used to:
[0140] According to the sorting results, obtain the target terrain mixed layer with the largest total area in the current sorting;
[0141] Embedding valid areas of a plurality of other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer, and removing valid areas of the plurality of other terrain hybrid layers that have been embedded into the target terrain hybrid layer, wherein the plurality of other terrain hybrid layers are terrain hybrid layers other than the target terrain hybrid layer in the plurality of terrain hybrid layers;
[0142] The embedded target terrain hybrid layer is removed from the multiple terrain hybrid layers and output, and execution is performed according to the sorting result to obtain the target terrain hybrid layer with the largest total area in the current sorting until the first preset number of cycles are executed.
[0143] Optionally, the embedding module 64 is used to:
[0144] For any other terrain hybrid layer among the multiple other terrain hybrid layers, sequentially obtaining valid areas in the any other terrain hybrid layer according to a preset order;
[0145] Whenever a valid area in any other terrain hybrid layer is obtained, determining whether the currently obtained valid area coincides with any valid area in the target terrain hybrid layer in position;
[0146] If the currently acquired valid area does not overlap with any valid area in the target terrain hybrid layer in terms of position, the currently acquired valid area is embedded into a corresponding position in the target terrain hybrid layer.
[0147] Optionally, the first preset number is 4, and the generating module 65 is used to:
[0148] The index identifiers of the terrain blending layers corresponding to the pixels with valid blending values in the first preset number of terrain blending layers that have been embedded and the corresponding blending values are output to two terrain blending maps respectively, wherein the terrain blending maps are four-channel ARGB maps.
[0149] Figure 6 The device shown can perform the aforementioned Figures 1 to 5 The terrain hybrid map generation method provided in the illustrated embodiment, the detailed execution process and technical effects are described in the aforementioned embodiment, which will not be repeated here.
[0150] In one possible design, the above Figure 6The structure of the terrain hybrid map generating device shown can be implemented as an electronic device, such as Figure 7 As shown, the electronic device may include: a processor 71 and a memory 72. The memory 72 stores executable code, and when the executable code is executed by the processor 71, the processor 71 can at least implement the above-mentioned Figures 1 to 5 The terrain hybrid map generation method provided in the illustrated embodiment.
[0151] Optionally, the electronic device may further include a communication interface 73 for communicating with other devices.
[0152] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, wherein an executable code is stored on the non-transitory machine-readable storage medium. When the executable code is executed by a processor of an electronic device, the processor can at least implement the above-mentioned Figures 1 to 5 The terrain hybrid map generation method provided in the illustrated embodiment.
[0153] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0154] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0155] The terrain hybrid map generation method provided in the embodiment of the present invention can be executed by a certain program / software, and the program / software can be provided by the network side. The electronic device mentioned in the above embodiment can download the program / software to a local non-volatile storage medium, and when it needs to execute the above terrain hybrid map generation method, the program / software is read into the memory by the CPU, and then the CPU executes the program / software to implement the terrain hybrid map generation method provided in the above embodiment. The execution process can refer to the above Figures 1 to 5 Instructions in .
[0156] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating a terrain hybrid map, characterized in that: include: Acquire multiple terrain hybrid layers, wherein each of the multiple terrain hybrid layers records terrain hybrid layer information of a corresponding terrain hybrid layer, and the number of valid hybrid layers recorded by any pixel point in the multiple terrain hybrid layers is less than or equal to a preset threshold; For a first terrain hybrid layer among the multiple terrain hybrid layers, sequentially traverse the pixel points in the first terrain hybrid layer to determine whether the hybrid value corresponding to the currently traversed pixel point is valid, wherein the first terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers; Determine multiple adjacent pixel points with valid mixing values in the first terrain mixing layer as areas to be validated, and obtain at least one area to be validated contained in the first terrain mixing layer; For any area to be validated among the at least one area to be validated, determining surrounding pixel points adjacent to the area to be validated in the first terrain hybrid layer; Determine any of the to-be-validated areas and the surrounding pixel points as valid areas in the first terrain hybrid layer; Sorting the plurality of terrain hybrid layers in descending order of the total area of the effective regions; According to the sorting results, obtain the target terrain mixed layer with the largest total area in the current sorting; Embedding valid areas of a plurality of other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer, and removing valid areas of the plurality of other terrain hybrid layers that have been embedded into the target terrain hybrid layer, wherein the plurality of other terrain hybrid layers are terrain hybrid layers other than the target terrain hybrid layer in the plurality of terrain hybrid layers; Removing and outputting the embedded target terrain hybrid layer from the multiple terrain hybrid layers, and switching to executing according to the sorting result, obtaining the target terrain hybrid layer with the largest total area in the current sorting, until the first preset number of times of looping are completed; Based on the first preset number of terrain blending layers that have been embedded, a terrain blending map is generated.
2. The method according to claim 1, characterized in that Before sorting the plurality of terrain hybrid layers in descending order of the total area of the effective regions, the method further includes: For a second terrain hybrid layer among the multiple terrain hybrid layers, determining a small effective area whose area does not meet a preset area requirement among all effective areas in the second terrain hybrid layer, wherein the second terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers; The small valid region is removed from all valid regions in the second terrain blending layer.
3. The method according to claim 1, characterized in that The embedding of valid areas in multiple other terrain hybrid layers whose positions meet preset embedding conditions into the target terrain hybrid layer includes: For any other terrain hybrid layer among the multiple other terrain hybrid layers, sequentially obtaining valid areas in the any other terrain hybrid layer according to a preset order; Whenever a valid area in any other terrain hybrid layer is obtained, determining whether the currently obtained valid area coincides with any valid area in the target terrain hybrid layer in position; If the currently acquired valid area does not overlap with any valid area in the target terrain hybrid layer in terms of position, the currently acquired valid area is embedded into a corresponding position in the target terrain hybrid layer.
4. The method according to claim 1, characterized in that: The first preset number is 4, and the step of generating a terrain blending map based on the first preset number of terrain blending layers that have been embedded includes: The index identifiers of the terrain blending layers corresponding to the pixels with valid blending values in the first preset number of terrain blending layers that have been embedded and the corresponding blending values are output to two terrain blending maps respectively, wherein the terrain blending maps are four-channel ARGB maps.
5. A terrain mixed map generating device, characterized in that: include: An acquisition module, used for acquiring a plurality of terrain hybrid layers, wherein each of the plurality of terrain hybrid layers records terrain hybrid layer information of a corresponding terrain hybrid layer, and the number of valid hybrid layers recorded by any pixel point in the plurality of terrain hybrid layers is less than or equal to a preset threshold; A determination module is used for, for a first terrain hybrid layer among the multiple terrain hybrid layers, sequentially traversing the pixel points in the first terrain hybrid layer, and determining whether the mixing value corresponding to the currently traversed pixel point is valid, wherein the first terrain hybrid layer is any terrain hybrid layer among the multiple terrain hybrid layers; determining multiple adjacent pixel points with valid mixing values in the first terrain hybrid layer as areas to be taken into effect, and obtaining at least one area to be taken into effect contained in the first terrain hybrid layer; for any area to be taken into effect among the at least one area to be taken into effect, determining the surrounding pixel points in the first terrain hybrid layer adjacent to the any area to be taken into effect; determining the any area to be taken into effect and the surrounding pixel points as the valid area in the first terrain hybrid layer; A sorting module, used for sorting the plurality of terrain hybrid layers in descending order of the total area of the effective regions; The embedding module is used to obtain the target terrain hybrid layer with the largest total area in the current sorting according to the sorting result; embed the valid areas of multiple other terrain hybrid layers whose positions meet the preset embedding conditions into the target terrain hybrid layer, and remove the valid areas of the multiple other terrain hybrid layers that have been embedded in the target terrain hybrid layer, wherein the multiple other terrain hybrid layers are terrain hybrid layers other than the target terrain hybrid layer in the multiple terrain hybrid layers; remove and output the embedded target terrain hybrid layer from the multiple terrain hybrid layers, and proceed to obtain the target terrain hybrid layer with the largest total area in the current sorting according to the sorting result, until the first preset number of times of looping are completed; A generation module is used to generate a terrain blending map based on the first preset number of terrain blending layers that have been embedded.
6. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the terrain hybrid map generation method as described in any one of claims 1 to 4.
7. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the terrain hybrid map generation method according to any one of claims 1 to 4.
