CN110335205B - Landform smoothing method and device, computer equipment and storage medium - Google Patents
Landform smoothing method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110335205B CN110335205B CN201910383384.2A CN201910383384A CN110335205B CN 110335205 B CN110335205 B CN 110335205B CN 201910383384 A CN201910383384 A CN 201910383384A CN 110335205 B CN110335205 B CN 110335205B
- Authority
- CN
- China
- Prior art keywords
- brush
- map
- area
- image frame
- pixel point
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 72
- 238000009499 grossing Methods 0.000 title claims abstract description 70
- 230000008569 process Effects 0.000 claims abstract description 34
- 230000001960 triggered effect Effects 0.000 claims abstract description 23
- 238000010586 diagram Methods 0.000 claims description 20
- 238000004364 calculation method Methods 0.000 claims description 10
- 238000004422 calculation algorithm Methods 0.000 claims description 8
- 238000001914 filtration Methods 0.000 claims description 6
- 238000004590 computer program Methods 0.000 claims description 5
- 238000013507 mapping Methods 0.000 claims description 5
- 230000000694 effects Effects 0.000 abstract description 12
- 230000006870 function Effects 0.000 description 26
- 230000003287 optical effect Effects 0.000 description 6
- 230000000873 masking effect Effects 0.000 description 3
- 239000013307 optical fiber Substances 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000007704 transition Effects 0.000 description 2
- 238000004804 winding Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
- Processing Or Creating Images (AREA)
Abstract
The embodiment of the invention discloses a landform smoothing method, a device, equipment and a medium, wherein the method comprises the following steps: when detecting that the brush drawing function is triggered in the process of playing the image frames frame by frame, determining and recording the area information covered in each image frame in the moving process of the brush drawing after the brush drawing function is triggered; aiming at each image frame, adjusting the earth surface height value of each pixel point in the area covered by the brush image in the current image frame based on the attenuation information corresponding to the brush image; when the brush map function is released, determining the edge sub-area of the area covered by the brush map according to the recorded area information, and smoothing the ground surface height value corresponding to the edge sub-area to finish the landform smoothing. The technical scheme of the embodiment of the invention solves the problem of poor smooth processing effect for special landforms in the prior art; the effect of smoothing the landform area in the image can be improved, so that the landform in the image better conforms to the actual landform condition.
Description
Technical Field
The embodiment of the invention relates to the technical field of image processing, in particular to a method and a device for smoothing a landform, computer equipment and a storage medium.
Background
In image processing, it is necessary to perform detail processing on some objects in an image, such as smoothing or sharpening an image containing landscape elements, so that various different landscapes are more suitable for an actual scene. For example, detail images in a game scene are processed. Specifically, the game scene refers to usable elements such as buildings, trees, sky, roads and the like in the game restored according to the requirements of the game plan. For road elements, the relief features in the road need to be smoothed.
At present, the existing geomorphic smooth transition algorithm achieves the required effect by carrying out average calculation on the ground surface height information within a certain range around a target point. However, this method is not suitable for all terrains, for some specific terrains, such operations destroy some specific properties of the terrains. For example, the travertine requires that both sides of the road are kept at substantially the same level, and during the carving of the travertine on the cliff, if the existing smooth transition algorithm is used, the side close to the mountain is higher, the side close to the valley is lower, and the whole road is inclined.
Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for smoothing a landform, a computer device, and a storage medium, so as to improve an effect of smoothing a landform area in an image, so that the landform in the image better conforms to an actual landform situation.
In a first aspect, an embodiment of the present invention provides a method for smoothing a terrain, where the method includes:
when detecting that a brush drawing function is triggered in the process of playing image frames frame by frame, determining and recording the area information covered by the brush drawing in each image frame in the moving process after the brush drawing function is triggered;
adjusting the earth surface height value of each pixel point in the area covered by the brush map in the current image frame based on attenuation information corresponding to the brush map for each image frame, wherein the attenuation information is a parameter for adjusting the height of each pixel point;
when the function of the brush map is released, determining an edge sub-area of an area covered by the brush map according to the recorded area information, and smoothing a ground surface height value corresponding to the edge sub-area to finish terrain smoothing.
Optionally, the determining and recording area information covered by the brush map in each image frame in the moving process of the brush map after the brush map function is triggered includes:
for each image frame, mapping the center of the brush map to a target carving area in the current image frame, and determining the coordinate of the center point of the brush map in the current image frame, wherein each image frame comprises the same target carving area;
and determining the area information covered by the brush map in the current image frame according to the coordinates of the center point of the brush map and the parameters of the brush map so as to obtain the area covered by the brush map in each image frame.
Optionally, adjusting the surface height value of each pixel point in the area covered by the brush map in the current image frame based on the attenuation information corresponding to the brush map includes:
calculating target height values of all pixel points of which attenuation information is not zero in an area covered by the brush image in the current image frame;
and calculating a final ground height value of each pixel point with non-zero attenuation information according to the attenuation information, the original height and the target height of each pixel point with non-zero attenuation information, wherein the original height is the final ground height value obtained by calculation of each pixel point in a previous image frame of the current image frame.
Optionally, calculating a final ground height value of each pixel point with non-zero attenuation information according to the attenuation information, the original height and the target height of each pixel point with non-zero attenuation information, including:
and carrying out interpolation calculation on the original height and the target height of each pixel point with attenuation information not being zero according to the attenuation information corresponding to the pixel point to obtain a final surface height value.
Optionally, calculating a target height value of each pixel point of which attenuation information is not zero in an area covered by the brush map in the current image frame, specifically includes:
when the landform is smooth and is a carved mountain road, calculating the average height of each pixel point with non-zero attenuation information in a preset range as a target height value;
when the landform is smooth and raised, adding a preset height value on the basis of the original height of each pixel point with attenuation information not being zero as a target height value;
when the landform smoothness is the landform flattening, a preset height value is used as a target height value of each pixel point of which the attenuation information is not zero.
Optionally, determining an edge sub-region of the region covered by the brush map according to the recorded region information, and performing smoothing processing on a ground surface height value corresponding to the edge sub-region, including:
determining a set of edge pixels of a pixel region with attenuation information not being zero as an edge sub-region in the region covered by the region information;
and smoothing the surface height value corresponding to the edge sub-region through a filtering algorithm.
Optionally, the shape of the brush map is a preset shape, or a brush map shape generated according to brush parameters, where the brush parameters include an attenuation information curve and at least one of a brush radius or a brush side length.
Optionally, determining and recording area information covered by the brush map in each image frame in the moving process of the brush map after the brush map function is triggered, further comprising:
creating a covering masking plate graph with the same size as the target engraving area;
recording the numerical value of a covering mask map corresponding to a pixel point which is covered by the brush map and corresponding to which attenuation information is not zero in each image frame as 1 so as to record the region information; accordingly, the method can be used for solving the problems that,
adjusting the earth surface height value of each pixel point in the area covered by the brush map in the current image frame based on the attenuation information corresponding to the brush map, including:
adjusting the earth surface height value of a pixel point with the covering mask diagram value of 1 in the current image frame based on attenuation information corresponding to the brush diagram;
determining the edge sub-area of the area covered by the brush map according to the recorded area information, wherein the determining includes:
and taking the edge pixel points of the pixel point region with the value of 1 in the covering mask image as edge sub-regions.
In a second aspect, an embodiment of the present invention further provides a terrain smoothing apparatus, including:
the brush map coverage area determining module is used for determining and recording area information covered in each image frame in the moving process of the brush map after the brush map function is triggered when the brush map function is detected to be triggered in the process of playing the image frames frame by frame;
the ground surface internal height adjusting module is used for adjusting the ground surface height value of each pixel point in the area covered by the brush map in the current image frame based on the attenuation information corresponding to the brush map aiming at each image frame;
and the ground surface edge height adjusting module is used for determining an edge sub-area of the area covered by the brush map according to the recorded area information when the function of the brush map is released, and smoothing a ground surface height value corresponding to the edge sub-area to finish terrain smoothing.
Optionally, the brush map coverage area determining module is specifically configured to:
for each image frame, mapping the center of the brush map to a target carving area in the current image frame, and determining the coordinate of the center point of the brush map in the current image frame, wherein each image frame comprises the same target carving area;
and determining the area information covered by the brush map in the current image frame according to the coordinates of the center point of the brush map and the parameters of the brush map so as to obtain the area covered by the brush map in each image frame.
Optionally, the ground surface internal height adjusting module includes:
the target height value calculating unit is used for calculating the target height value of each pixel point of which the attenuation information is not zero in the area covered by the brush image in the current image frame;
and the final earth surface height value calculating unit is used for calculating a final earth surface height value of each pixel point of which the attenuation information is not zero according to the attenuation information, the original height and the target height of each pixel point of which the attenuation information is not zero, wherein the original height is the final earth surface height value obtained by calculating each pixel point in a previous image frame of the current image frame.
Optionally, the final surface height value calculating unit is specifically configured to:
and carrying out interpolation calculation on the original height and the target height of each pixel point with attenuation information not being zero according to the attenuation information corresponding to the pixel point to obtain a final surface height value.
Optionally, the target height value calculating unit is specifically configured to:
when the landform is smooth and is a carved mountain road, calculating the average height of each pixel point with non-zero attenuation information in a preset range as a target height value;
when the landform is smooth and raised, adding a preset height value on the basis of the original height of each pixel point with attenuation information not being zero as a target height value;
when the landform smoothness is the landform flattening, a preset height value is used as a target height value of each pixel point of which the attenuation information is not zero.
Optionally, the surface edge height adjusting module is specifically configured to:
determining a set of edge pixels of a pixel region with attenuation information not being zero as an edge sub-region in the region covered by the region information;
and smoothing the surface height value corresponding to the edge sub-region through a filtering algorithm.
Optionally, the shape of the brush map is a preset shape, or a brush map shape generated according to brush parameters, where the brush parameters include an attenuation information curve and at least one of a brush radius or a brush side length.
Optionally, the brush map coverage area determining module is further configured to:
creating a covering masking plate graph with the same size as the target engraving area;
recording the numerical value of a covering mask map corresponding to a pixel point which is covered by the brush map and corresponding to which attenuation information is not zero in each image frame as 1 so as to record the region information; accordingly, the method can be used for solving the problems that,
the earth surface internal height adjusting module is also used for:
adjusting the earth surface height value of a pixel point with the covering mask diagram value of 1 in the current image frame based on attenuation information corresponding to the brush diagram;
the earth surface edge height adjusting module is also used for:
and taking the edge pixel points of the pixel point region with the value of 1 in the covering mask image as edge sub-regions.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
storage means for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors implement the terrain smoothing method according to any of the embodiments of the present invention.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the terrain smoothing method according to any one of the embodiments of the present invention.
According to the embodiment of the invention, the brush map is used for processing the landform area to be smoothed in a plurality of continuous image frames, the earth surface height value of each pixel point in the coverage area of the brush map is firstly adjusted, and then the earth surface height values of the edges of the coverage area of all the brush maps are smoothed, so that the smoothing of the landform is completed, and the problem of poor smoothing effect for special landform in the prior art is solved; the effect of smoothing the landform area in the image can be improved, so that the landform in the image better conforms to the actual landform condition.
Drawings
FIG. 1a is a flow chart of a terrain smoothing method according to a first embodiment of the present invention;
FIG. 1b is a schematic diagram of a brush diagram according to a first embodiment of the present invention;
FIG. 2 is a flow chart of a terrain smoothing method according to a second embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a terrain smoothing device according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device in the fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described through embodiments with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention. In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution.
Example one
Fig. 1a is a flowchart of a method for smoothing a terrain according to an embodiment of the present invention, where the embodiment is applicable to a case where a terrain element in an image is processed, and the method can be implemented by a terrain smoothing apparatus, which is configured in a computer device, and can be implemented by software and/or hardware in the device. As shown in fig. 1a, the terrain smoothing method specifically includes:
s110, when the brush-drawing function is detected to be triggered in the process of playing the image frames frame by frame, determining and recording the area information covered in each image frame in the moving process of the brush-drawing after the brush-drawing function is triggered.
Specifically, the process of smoothing the terrain and the like can be called a process of carving the terrain, the carving operation of the terrain is completed through a terrain brush, after a user selects a brush diagram, a mouse can be displayed in the shape of the brush diagram on the interface of the terrain carving, the user presses the mouse to indicate that the function of the brush diagram is triggered, and the process from the moment the user drags the mouse to the moment the user releases the mouse is a complete carving process. The result of one engraving is a result of superimposing after engraving a plurality of successive image frames.
The image frames played frame by frame are a plurality of continuous image frames with the same target landform area to be carved, different parts of the same target landform area to be carved are carved in different image frames in one carving, then the carved landform coordinates in each image frame are converted to a world coordinate system X-Z coordinate system of a game scene by a game engine, and then corresponding brush image coverage area operation and/or earth surface height operation are/is carried out. This is because, in general, in a relief area to be engraved, a brush figure cannot form a target relief shape in one engraving process. If the relief carving is to be completed in the same image frame, multiple shapes of brush drawings need to be made for multiple times of carving, the process is troublesome, and the made brush drawings in all shapes are difficult to reuse.
The brush graph can be in a shape of a circle, a square, a star or a cross, the size of the brush graph can be preset, each position point in the brush graph is provided with corresponding attenuation information, and the attenuation information represents height adjustment parameters of pixel points of an image frame covered by each position point of the brush graph. FIG. 1b schematically shows a circular brush map with corresponding gray values at different points of the map, indicating corresponding attenuation information at the different points.
In the process of determining the coverage of the brush map, for each image frame, mapping the center of the brush map (and the position corresponding to the mouse) to a target engraving area in the current image frame, determining the coordinates of the center point of the brush map in the current image frame, and further determining the area information covered by the brush map in the current image frame according to the coordinates of the center point of the brush map and the parameters of the brush map so as to obtain the area covered by the brush map in each image frame, wherein the parameters of the brush map include the size information of the brush map and the like.
In one embodiment, it is assumed that in each image frame, the target engraving area to be engraved is a rectangular area with length and width of M and N, respectively, and the ground height map of each pixel point in the rectangular area is h (x, y), where x is 1, 2, …, and M, y is 1, 2, …, N. Firstly, the position of the mouse is mapped into the rectangular area, and the coordinate range of an XZ plane of a target carving area to be carved in a game world coordinate system is assumed to be (x)start,zstart) To (x)end,zend) Corresponding to (1, 1) to (M, N) of the target engraving area, respectively, and the position of the mouse is (x, z), the corresponding coordinate point of the height map is
(x, y) — (Round ([ x-xstart ]/[ xend-xstart ] × M), Round ([ z-zstart ]/[ zend-zstart ] × N)), and the Round operation represents rounding the input decimal down back to the corresponding integer. And obtaining the covered area in the ground surface height map according to the size of the brush map. Because the center point of the brush map corresponds to the height map point of the mouse, the brush coverage range S is (x-U/2, y-U/2) to (x + U/2, y + U/2), which respectively corresponds to (1, 1) to (U, V) of the brush map, and U and V respectively represent the length and width of the brush map.
S120, aiming at each image frame, adjusting the earth surface height value of each pixel point in the area covered by the brush map in the current image frame based on attenuation information corresponding to the brush map, wherein the attenuation information is a parameter for adjusting the height of each pixel point.
Wherein the attenuation information may be represented as b (i, j), where i is 1, 2, …, U, j is 1, 2, …, V, U and V represent the length and width of the brush map, respectively; the value range of b (i, j) is [0, 1], 0 represents that the original height value is completely used when the height data is updated, namely the height data is not changed, 1 represents that the new height value is obtained by calculation and is completely used, and the two data are mixed according to a certain rule when the value range of b (i, j) is between 0 and 1.
In the process of adjusting the surface height value of each pixel point, firstly, calculating the target height value of each pixel point of which attenuation information is not zero in the area covered by the brush map in the current image frame; specifically, the target height value is a set value of the ground surface height, and the determination methods of the target height value are different for different types of landform sculptures, for example, when the landform is smooth and sculptured mountain roads, the average height within a preset range of each pixel point with attenuation information not being zero is calculated as the target height value; when the landform is smooth and raised, adding a preset height value on the basis of the original height of each pixel point with attenuation information not being zero as a target height value; when the landform smoothness is the landform flattening, a preset height value is used as a target height value of each pixel point of which the attenuation information is not zero.
And calculating a final ground height value of each pixel point with non-zero attenuation information according to the attenuation information, the original height and the target height of each pixel point with non-zero attenuation information, wherein the original height is the final ground height value obtained by calculation of each pixel point in a previous image frame of the current image frame. And if the current image frame is the first image frame, the original height of each pixel point in the target carving area to be carved in the image frame is the initial earth surface height when the image frame is not carved. The original height and the target height of each pixel point of which the attenuation information is not zero may be interpolated according to the attenuation information corresponding to the pixel point to obtain a final surface height value.
For example, taking a winding mountain road as an example, the target height value of each pixel point in the winding mountain road terrain corresponds to the average height value of each pixel point in the preset range, which can be expressed as htargetAnd (x, y) avg (h) Σ h (x, y)/n, (x, y) is an S, n is the number of data points, and S is the brush coverage. Then it is. The final table height value of each pixel may be expressed as h' (x, y) ═ 1-b (x, y)) × h (x, y) + b (x, y) × htarget(x,y),(x,y)∈S。
S130, when the function of the brush map is released, determining an edge sub-area of the area covered by the brush map according to the recorded area information, and smoothing the ground surface height value corresponding to the edge sub-area to finish terrain smoothing.
The area information is the area information obtained after overlapping the areas covered in each image frame in the moving process of the brush image, and in the area covered by the area information, determining a set of edge pixel points of a pixel point area with attenuation information not being zero as an edge sub-area; furthermore, the surface height values corresponding to the edge sub-regions can be smoothed by a filtering algorithm. Thereby finishing the smoothness of the landform of the target engraving area to be engraved.
According to the technical scheme of the embodiment, the brush map is used for processing the terrain area to be smoothed in the continuous multiple image frames, the height value of the ground surface of each pixel point in the coverage area of the brush map is adjusted, and then the height values of the ground surface of the edges of the coverage area of all the brush maps are smoothed, so that the terrain smoothing is completed, and the problem of poor smoothing effect for special terrain in the prior art is solved; the effect of smoothing the landform area in the image can be improved, so that the landform in the image better conforms to the actual landform condition.
Example two
Fig. 2 is a flowchart of a terrain smoothing method according to a second embodiment of the present invention. The present embodiment provides a method for determining and recording a brush map coverage area based on the various alternatives in the above embodiments. As shown in fig. 2, the method for smoothing a terrain provided in the embodiment of the present invention includes the following steps:
s210, when the brush drawing function is triggered in the process of playing the image frames frame by frame, an overlay stencil drawing is created.
Similarly, it is assumed that in each image frame, the target engraving area to be engraved is a rectangular area with length and width M and N, respectively, and the ground height map of each pixel point in the rectangular area is h (x, y), where x is 1, 2, …, and M, y is 1, 2, …, N. The overlay mask map is a map having the same size as the target area to be engraved, and may be represented as M (x, y), where x is 1, 2, …, M, y is 1, 2, …, N. The initial value of each pixel point of m (x, y) is 0, which represents that the pixel point with the coordinate (x, y) is not covered by the brush image.
The brush map includes two designated manners, one of which is to directly take a gray scale map as the brush map, and the other is to use a fixed-shape brush map, which may be generated by parameters, for example, the circular brush in fig. 1b may be generated by parameters such as radius or attenuation curve.
S220, recording the numerical value of a covering mask map corresponding to the pixel point which is covered by the brush map and corresponding to which attenuation information is not zero in each image frame as 1 so as to record the region information.
Since the attenuation information of any pixel point is 0, which means that the pixel point completely uses the original value when updating the height data, that is, the height data cannot be changed, and the height value corresponding to each pixel point with the attenuation information of 0 cannot be adjusted, the pixel point is not taken as the pixel point covered by the brush image. And recording the numerical value of a covering mask image corresponding to the pixel point which is covered by the brush image and corresponding to which the attenuation information is not zero in each image frame as 1, wherein the pixel point with the representative coordinate (x, y) is covered by the brush image at least once.
And S230, aiming at each image frame, adjusting the earth surface height value of the pixel point with the covering mask diagram value of 1 in the current image frame based on attenuation information corresponding to the brush diagram, wherein the attenuation information is a parameter for adjusting the height of each pixel point.
Wherein, the pixel point with the covering mask graph value of 1 is each pixel point with attenuation information not being zero. For each image frame, firstly, calculating a target height value of a pixel point with a covering mask map value of 1 in an area covered by the brush map in the current image frame; specifically, the target height value is a set value of the ground surface height, and the determination methods of the target height value are different for different types of landform sculptures, for example, when the landform is smooth and is a sculptured mountain road, the average height within a preset range of pixel points covering a mask map with the numerical value of 1 is calculated as the target height value; when the landform is smooth and raised, adding a preset height value as a target height value on the basis of covering the original height of the pixel point with the mask map value of 1; when the landform smoothness is the landform flattening, a preset height value is used as a target height value of the pixel point with the covering mask map value of 1.
And according to attenuation information of the pixel with the covering mask map value of 1, the original height and the final surface height value of the pixel with the covering mask map value of 1, wherein the original height is the final surface height value obtained by calculation of each pixel in the previous image frame of the current image frame. And if the current image frame is the first image frame, the original height of each pixel point in the target carving area to be carved in the image frame is the initial earth surface height when the image frame is not carved. The original height and the target height of the pixel point with the covering mask map value of 1 may be interpolated according to attenuation information corresponding to the pixel point to obtain a final surface height value.
S240, when the function of the brush map is released, taking the edge pixel point of the pixel point area with the value of 1 in the coverage mask map as an edge sub-area, and smoothing the ground surface height value corresponding to the edge sub-area to finish the landform smoothing.
Specifically, after the function of the brush map is released, the area covering the pixel points with the value of 1 in the mask map is an area after the pixel points with the value of 1 in the mask map are overlapped in each image frame in the moving process of the brush map, and the set of the edge pixel points in the area is used as an edge sub-area; furthermore, the surface height values corresponding to the edge sub-regions can be smoothed by a filtering algorithm. Thereby finishing the smoothness of the landform of the target engraving area to be engraved.
According to the technical scheme of the embodiment, the covering mask map is created to record the pixel points which are covered by the brush map in the landscape smoothing process and correspond to which attenuation information is not 0, the brush map is utilized to process a landscape area to be smoothed in a plurality of continuous image frames, the height value of the earth surface of each pixel point in the coverage area of the brush map is adjusted, and then the height values of the earth surface of the edges of the areas covered by the brush map are smoothed, so that the landscape smoothing is completed, and the problem of poor smoothing effect for special landscapes in the prior art is solved; the effect of smoothing the landform area in the image can be improved, so that the landform in the image better conforms to the actual landform condition.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a terrain smoothing apparatus according to a third embodiment of the present invention, which is applicable to a case where a terrain element in an image is processed.
As shown in fig. 3, the terrain smoothing apparatus according to the embodiment of the present invention includes: a brush map coverage area determination module 310, a ground surface interior height adjustment module 320, and a ground surface edge height adjustment module 330.
The brush map coverage area determining module 310 is configured to determine and record area information covered in each image frame in the moving process of the brush map after the brush map function is triggered when it is detected that the brush map function is triggered in the process of playing the image frames frame by frame; the ground surface internal height adjusting module 320 is configured to, for each image frame, adjust a ground surface height value of each pixel point in an area covered by the brush map in the current image frame based on attenuation information corresponding to the brush map; and a surface edge height adjusting module 330, configured to determine, according to the recorded region information, an edge sub-region of the region covered by the brush map when the brush map function is released, and perform smoothing processing on a surface height value corresponding to the edge sub-region to complete landform smoothing.
According to the technical scheme of the embodiment, the brush map is used for processing the terrain area to be smoothed in the continuous multiple image frames, the height value of the ground surface of each pixel point in the coverage area of the brush map is adjusted, and then the height values of the ground surface of the edges of the coverage area of all the brush maps are smoothed, so that the terrain smoothing is completed, and the problem of poor smoothing effect for special terrain in the prior art is solved; the effect of smoothing the landform area in the image can be improved, so that the landform in the image better conforms to the actual landform condition.
Optionally, the brush map coverage area determining module 310 is specifically configured to:
for each image frame, mapping the center of the brush map to a target carving area in the current image frame, and determining the coordinate of the center point of the brush map in the current image frame, wherein each image frame comprises the same target carving area;
and determining the area information covered by the brush map in the current image frame according to the coordinates of the center point of the brush map and the parameters of the brush map so as to obtain the area covered by the brush map in each image frame.
Optionally, the ground surface internal height adjusting module 320 includes:
the target height value calculating unit is used for calculating the target height value of each pixel point of which the attenuation information is not zero in the area covered by the brush image in the current image frame;
and the final earth surface height value calculating unit is used for calculating a final earth surface height value of each pixel point of which the attenuation information is not zero according to the attenuation information, the original height and the target height of each pixel point of which the attenuation information is not zero, wherein the original height is the final earth surface height value obtained by calculating each pixel point in a previous image frame of the current image frame.
Optionally, the final surface height value calculating unit is specifically configured to:
and carrying out interpolation calculation on the original height and the target height of each pixel point with attenuation information not being zero according to the attenuation information corresponding to the pixel point to obtain a final surface height value.
Optionally, the target height value calculating unit is specifically configured to:
when the landform is smooth and is a carved mountain road, calculating the average height of each pixel point with non-zero attenuation information in a preset range as a target height value;
when the landform is smooth and raised, adding a preset height value on the basis of the original height of each pixel point with attenuation information not being zero as a target height value;
when the landform smoothness is the landform flattening, a preset height value is used as a target height value of each pixel point of which the attenuation information is not zero.
Optionally, the surface edge height adjusting module 330 is specifically configured to:
determining a set of edge pixels of a pixel region with attenuation information not being zero as an edge sub-region in the region covered by the region information;
and smoothing the surface height value corresponding to the edge sub-region through a filtering algorithm.
Optionally, the shape of the brush map is a preset shape, or a brush map shape generated according to brush parameters, where the brush parameters include an attenuation information curve and at least one of a brush radius or a brush side length.
Optionally, the brush map coverage area determining module 310 is further configured to:
creating a covering masking plate graph with the same size as the target engraving area;
recording the numerical value of a covering mask map corresponding to a pixel point which is covered by the brush map and corresponding to which attenuation information is not zero in each image frame as 1 so as to record the region information; accordingly, the method can be used for solving the problems that,
the ground surface internal height adjusting module 320 is further configured to:
adjusting the earth surface height value of a pixel point with the covering mask diagram value of 1 in the current image frame based on attenuation information corresponding to the brush diagram;
the surface edge height adjustment module 330 is further configured to:
and taking the edge pixel points of the pixel point region with the value of 1 in the covering mask image as edge sub-regions.
The terrain smoothing device provided by the embodiment of the invention can execute the terrain smoothing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 4 is a schematic structural diagram of a computer device in the fourth embodiment of the present invention. FIG. 4 illustrates a block diagram of an exemplary computer device 412 suitable for use in implementing embodiments of the present invention. The computer device 412 shown in FIG. 4 is only one example and should not impose any limitations on the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 4, computer device 412 is in the form of a general purpose computing device. Components of computer device 412 may include, but are not limited to: one or more processors or processing units 416, a system memory 428, and a bus 418 that couples the various system components including the system memory 428 and the processing unit 416.
The system memory 428 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)430 and/or cache memory 432. The computer device 412 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 434 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 418 by one or more data media interfaces. Memory 428 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 440 having a set (at least one) of program modules 442 may be stored, for instance, in memory 428, such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. The program modules 442 generally perform the functions and/or methodologies of the described embodiments of the invention.
The computer device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing device, display 424, etc.), with one or more devices that enable a user to interact with the computer device 412, and/or with any devices (e.g., network card, modem, etc.) that enable the computer device 412 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 422. Also, computer device 412 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) through network adapter 420. As shown, network adapter 420 communicates with the other modules of computer device 412 over bus 418. It should be appreciated that although not shown in FIG. 4, other hardware and/or software modules may be used in conjunction with the computer device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 416 executes programs stored in the system memory 428 to execute various functional applications and data processing, for example, to implement the terrain smoothing method provided by the embodiment of the present invention, which mainly includes:
when detecting that a brush drawing function is triggered in the process of playing image frames frame by frame, determining and recording the area information covered by the brush drawing in each image frame in the moving process after the brush drawing function is triggered;
adjusting the earth surface height value of each pixel point in the area covered by the brush map in the current image frame based on attenuation information corresponding to the brush map for each image frame, wherein the attenuation information is a parameter for adjusting the height of each pixel point;
when the function of the brush map is released, determining an edge sub-area of an area covered by the brush map according to the recorded area information, and smoothing a ground surface height value corresponding to the edge sub-area to finish terrain smoothing.
EXAMPLE five
The fifth embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for terrain smoothing provided by the fifth embodiment of the present invention, where the method mainly includes:
when detecting that a brush drawing function is triggered in the process of playing image frames frame by frame, determining and recording the area information covered by the brush drawing in each image frame in the moving process after the brush drawing function is triggered;
adjusting the earth surface height value of each pixel point in the area covered by the brush map in the current image frame based on attenuation information corresponding to the brush map for each image frame, wherein the attenuation information is a parameter for adjusting the height of each pixel point;
when the function of the brush map is released, determining an edge sub-area of an area covered by the brush map according to the recorded area information, and smoothing a ground surface height value corresponding to the edge sub-area to finish terrain smoothing.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (9)
1. A terrain smoothing method, comprising:
when detecting that a brush-drawing function is triggered in the process of playing image frames frame by frame, determining and recording the area information covered in each image frame in the moving process of the brush-drawing after the brush-drawing function is triggered, wherein the area information comprises a covering mask drawing which is the same as the size of a target engraving area; recording the numerical value of a covering mask map corresponding to a pixel point which is covered by the brush map and corresponding to which attenuation information is not zero in each image frame as 1 so as to record the region information;
aiming at each image frame, adjusting the earth surface height value of a pixel point with the coverage mask map value of 1 in the current image frame based on attenuation information corresponding to the brush map, wherein the attenuation information is a parameter for adjusting the height of each pixel point;
when the function of the brush map is released, taking an edge pixel of a pixel area with a value of 1 in the coverage mask map as an edge sub-area, and smoothing a ground surface height value corresponding to the edge sub-area to complete terrain smoothing, wherein the shape of the brush map is a preset shape or a brush map shape generated according to brush parameters, and the brush parameters comprise an attenuation information curve and at least one of brush radius or brush side length.
2. The method according to claim 1, wherein the determining and recording the area information covered by the brush map in each image frame during the movement of the brush map after the brush map function is triggered comprises:
for each image frame, mapping the center of the brush map to a target carving area in the current image frame, and determining the coordinate of the center point of the brush map in the current image frame, wherein each image frame comprises the same target carving area;
and determining the area information covered by the brush map in the current image frame according to the coordinates of the center point of the brush map and the parameters of the brush map so as to obtain the area covered by the brush map in each image frame.
3. The method of claim 1, wherein adjusting the surface height value of each pixel point in the region covered by the brush map in the current image frame based on the attenuation information corresponding to the brush map comprises:
calculating target height values of all pixel points of which attenuation information is not zero in an area covered by the brush image in the current image frame;
and calculating a final ground height value of each pixel point with non-zero attenuation information according to the attenuation information, the original height and the target height of each pixel point with non-zero attenuation information, wherein the original height is the final ground height value obtained by calculation of each pixel point in a previous image frame of the current image frame.
4. The method of claim 3, wherein calculating a final surface height value of each pixel point with non-zero attenuation information according to the attenuation information of each pixel point with non-zero attenuation information, the original height and the target height comprises:
and carrying out interpolation calculation on the original height and the target height of each pixel point with attenuation information not being zero according to the attenuation information corresponding to the pixel point to obtain a final surface height value.
5. The method according to claim 3, wherein calculating a target height value of each pixel point whose attenuation information is not zero in the area covered by the brush map in the current image frame comprises:
when the landform is smooth and is a carved mountain road, calculating the average height of each pixel point with non-zero attenuation information in a preset range as a target height value;
when the landform is smooth and raised, adding a preset height value on the basis of the original height of each pixel point with attenuation information not being zero as a target height value;
when the landform smoothness is the landform flattening, a preset height value is used as a target height value of each pixel point of which the attenuation information is not zero.
6. The method according to claim 1, wherein determining an edge sub-region of the region covered by the brush map according to the recorded region information, and performing a smoothing process on a ground surface height value corresponding to the edge sub-region comprises:
determining a set of edge pixels of a pixel region with attenuation information not being zero as an edge sub-region in the region covered by the region information;
and smoothing the surface height value corresponding to the edge sub-region through a filtering algorithm.
7. A terrain smoothing device, comprising:
the brush map coverage area determining module is used for determining and recording area information covered in each image frame in the moving process of the brush map after the brush map function is triggered when detecting that the brush map function is triggered in the process of playing the image frames frame by frame, and the area information comprises a coverage mask map which is the same as the target engraving area in size; recording the numerical value of a covering mask map corresponding to a pixel point which is covered by the brush map and corresponding to which attenuation information is not zero in each image frame as 1 so as to record the region information;
the ground surface internal height adjusting module is used for adjusting the ground surface height value of a pixel point which covers a mask diagram value of 1 in the current image frame based on attenuation information corresponding to the brush diagram aiming at each image frame, wherein the attenuation information is a parameter for adjusting the height of each pixel point;
and the ground surface edge height adjusting module is used for taking the edge pixel points of the pixel point region with the value of 1 in the coverage mask image as edge sub-regions when the function of the brush image is released, and smoothing the ground surface height value corresponding to the edge sub-regions so as to finish the landform smoothing.
8. A computer device, characterized in that the computer device comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the terrain smoothing method of any of claims 1-6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the terrain smoothing method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910383384.2A CN110335205B (en) | 2019-05-09 | 2019-05-09 | Landform smoothing method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910383384.2A CN110335205B (en) | 2019-05-09 | 2019-05-09 | Landform smoothing method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110335205A CN110335205A (en) | 2019-10-15 |
CN110335205B true CN110335205B (en) | 2021-09-14 |
Family
ID=68140071
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910383384.2A Active CN110335205B (en) | 2019-05-09 | 2019-05-09 | Landform smoothing method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110335205B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111784790B (en) * | 2020-06-22 | 2024-08-20 | 上海米哈游天命科技有限公司 | Landform generating method and device, computer equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109448078A (en) * | 2018-10-19 | 2019-03-08 | 珠海金山网络游戏科技有限公司 | A kind of image editing system, method and apparatus |
-
2019
- 2019-05-09 CN CN201910383384.2A patent/CN110335205B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109448078A (en) * | 2018-10-19 | 2019-03-08 | 珠海金山网络游戏科技有限公司 | A kind of image editing system, method and apparatus |
Non-Patent Citations (1)
Title |
---|
基于Unity3D的三维游戏场景设计与实践;张策;《中国优秀硕士学位论文全文数据库 信息科技辑》;20170215;第27-28页 * |
Also Published As
Publication number | Publication date |
---|---|
CN110335205A (en) | 2019-10-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10593098B2 (en) | Smooth draping layer for rendering vector data on complex three dimensional objects | |
CN112581629B (en) | Augmented reality display method, device, electronic equipment and storage medium | |
CN109771951B (en) | Game map generation method, device, storage medium and electronic equipment | |
CN110378947B (en) | 3D model reconstruction method and device and electronic equipment | |
CN109191554B (en) | Super-resolution image reconstruction method, device, terminal and storage medium | |
CN111870953B (en) | Altitude map generation method, device, equipment and storage medium | |
CN112766027A (en) | Image processing method, device, equipment and storage medium | |
CN113178013A (en) | Triangular mesh filtering method and device, electronic equipment and storage medium | |
CN110335205B (en) | Landform smoothing method and device, computer equipment and storage medium | |
CN112308768B (en) | Data processing method, device, electronic equipment and storage medium | |
CN112132845B (en) | Method, device, electronic equipment and readable medium for singulating three-dimensional model | |
CN110378948B (en) | 3D model reconstruction method and device and electronic equipment | |
CN117132744A (en) | Virtual scene construction method, device, medium and electronic equipment | |
JPH0636013A (en) | Method and device for generating topographic data | |
CN108520259B (en) | Foreground target extraction method, device, equipment and storage medium | |
CN112465692A (en) | Image processing method, device, equipment and storage medium | |
CN107452046B (en) | Texture processing method, device and equipment of three-dimensional city model and readable medium | |
CN113838199B (en) | Three-dimensional terrain generation method | |
CN115797533A (en) | Model edge tracing method, device, equipment and storage medium | |
CN111506680B (en) | Terrain data generation and rendering method and device, medium, server and terminal | |
CN113157835B (en) | Image processing method, device and platform based on GIS platform and storage medium | |
CN116109758B (en) | Method and device for positioning projection position of light source and rendering scene | |
CN116704151B (en) | Three-dimensional reconstruction method and device, and vehicle, equipment and medium based on three-dimensional reconstruction method and device | |
CN108062793A (en) | Processing method, device, equipment and storage medium at the top of object based on elevation | |
CN116188668B (en) | Shadow rendering method, medium and electronic device based on IOS platform |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |