Image drawing method and device
By replacing the image channel parameter values in the image processor and performing terrain stretching rendering processing, the problem of low image rendering efficiency in the existing technology is solved, and efficient image rendering is achieved, especially in the use of terrain maps on large screens in digital cities. Draw quickly.
Patent Information
- Application Number
- CN201911079658.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-07
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2039-11-07
Smart Images

Figure CN112785699B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image drawing, and in particular to an image drawing method and device. Background Art
[0002] Images are important elements in multimedia. They can present the content to be expressed to users vividly and intuitively, and have become one of the effective ways for people to obtain information.
[0003] At present, when drawing images with more complex image data, it is usually necessary to obtain and process various image data in multiple steps to draw the final image. For example, in the digital city screen, terrain, as an important geographical visual element, can present the geographical features and mountain distribution of the city; at present, when drawing topographic maps, the conventional way is to first establish various geometric models to represent the objects in the terrain based on various objects in the real terrain, and then render the corresponding colors for the terrain in different areas or heights to obtain the final three-dimensional topographic map effect.
[0004] However, the above-mentioned image drawing method has a relatively complicated drawing process, and thus the overall drawing efficiency is relatively low. Summary of the invention
[0005] In view of this, the present invention provides an image drawing method and device for improving image drawing efficiency.
[0006] In order to achieve the above objective, in a first aspect, an embodiment of the present invention provides an image drawing method, comprising:
[0007] Obtaining image data corresponding to a target image to be drawn, the image data comprising pixel data of a plurality of pixels, the pixel data of the pixels comprising image channel parameter values and target parameter values, the target parameter values being obtained by replacing at least a portion of the image channel parameter values, and the target parameter values being stored in at least one image channel of the pixel points;
[0008] The corresponding target drawing points are drawn according to the target parameter values of the pixel points to obtain the target image.
[0009] As an optional implementation of the embodiment of the present invention, the target image is a three-dimensional topographic map, and the target parameter value of the pixel point in the image data is the elevation value of the corresponding target drawing point; before drawing the corresponding target drawing point according to the target parameter value of the pixel point, the method further includes:
[0010] Determine the target drawing point to be drawn according to the three-dimensional terrain data;
[0011] The step of drawing corresponding target drawing points according to the target parameter values of the pixel points to obtain the target image includes:
[0012] The target image is obtained by performing terrain stretching and rendering processing on the corresponding target drawing points according to the elevation values of the pixel points.
[0013] As an optional implementation of the embodiment of the present invention, the terrain stretching and rendering processing of the corresponding target drawing point according to the elevation value of the pixel point includes:
[0014] For each target drawing point, performing terrain stretching processing on the target drawing point according to the elevation value of the target drawing point in the image data;
[0015] When the elevation value of the target drawing point is a target elevation value, the target drawing point is rendered using a preset color value corresponding to the target elevation value to highlight the target drawing point, and the target elevation value is the elevation value of any contour line to be drawn.
[0016] As an optional implementation of the embodiment of the present invention, the image channel parameter value is a color value, and the method further includes:
[0017] When the elevation value of the target drawing point is not the target elevation value, the target drawing point is rendered using the color value of the pixel point corresponding to the target drawing point in the image data.
[0018] As an optional implementation manner of the embodiment of the present invention, the obtaining of image data corresponding to the target image to be drawn includes:
[0019] Acquire image data generated based on three-dimensional terrain data;
[0020] When the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirement, performing sampling interpolation calculation on the image data to obtain new image data;
[0021] The step of determining the target drawing point to be drawn according to the three-dimensional terrain data includes:
[0022] According to the geographical range of the three-dimensional terrain data and the accuracy requirement, a target drawing point to be drawn is determined.
[0023] As an optional implementation manner of the embodiment of the present invention, the preset accuracy requirement is that the accuracy of the three-dimensional terrain data is equal to the target accuracy, and the sampling interpolation calculation is an upsampling interpolation calculation or a downsampling interpolation calculation; when the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirement, performing sampling interpolation calculation on the image data includes:
[0024] When the accuracy of the three-dimensional terrain data is less than the target accuracy, performing upsampling interpolation calculation on the image data;
[0025] When the accuracy of the three-dimensional terrain data is greater than the target accuracy, downsampling interpolation calculation is performed on the image data.
[0026] As an optional implementation of the embodiment of the present invention, when the elevation value of the target drawing point is the target elevation value, before rendering the target drawing point using the preset color value corresponding to the target elevation value, the method further includes:
[0027] The target elevation value is determined according to the contour drawing conditions input by the user.
[0028] As an optional implementation of the embodiment of the present invention, the method further includes:
[0029] According to the contour rendering condition input by the user, a preset color value corresponding to the target elevation value is determined.
[0030] As an optional implementation of the embodiment of the present invention, the elevation value of the target drawing point corresponding to the preset terrain area in the image data is set to a preset value.
[0031] As an optional implementation of an embodiment of the present invention, at least a portion of the image channel parameter values of the pixel points in the target area in the image data are replaced with elevation values, and the image channel parameter values of the pixel points in other areas of the image data except the target area are not replaced.
[0032] As an optional implementation of the embodiment of the present invention, the target parameter value is a parameter value corresponding to the target rendering effect.
[0033] In a second aspect, an embodiment of the present invention provides an image drawing device, comprising: a memory and an image processor, wherein the memory is used to store a computer program; and the image processor is used to execute the method described in the first aspect or any embodiment of the first aspect when calling the computer program.
[0034] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method described in the first aspect or any one of the embodiments of the first aspect is implemented.
[0035] In a fourth aspect, an embodiment of the present invention provides a display screen for displaying a target image, wherein the target image is drawn according to a target parameter value of a pixel point in image data corresponding to the target image, the image data includes pixel data of a plurality of pixel points, the pixel data of the pixel points include an image channel parameter value and a target parameter value, the target parameter value is obtained by replacing at least a part of the image channel parameter value, and the target parameter value is stored in at least one image channel of the pixel point.
[0036] In the image drawing method and device provided by the embodiment of the present invention, the image processor first obtains the image data corresponding to the target image to be drawn, wherein the image data includes pixel data of multiple pixels, the pixel data of the pixel includes image channel parameter values and target parameter values, the target parameter values are obtained by replacing at least a part of the image channel parameter values, and the target parameter values are stored in at least one image channel of the pixel; then the corresponding target drawing points are drawn according to the target parameter values of the pixel points to obtain the target image. In this way, the image processor can obtain multiple image data through one image data, so that the image data can be quickly obtained for drawing, and the high parallel computing capability of the image processor can be fully utilized to process multiple image data in parallel, thereby effectively improving the drawing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a flow chart of an image drawing method provided by an embodiment of the present invention;
[0038] Figure 2 A schematic flow chart of another image drawing method provided by an embodiment of the present invention;
[0039] Figure 3 A schematic diagram of a three-dimensional terrain map rendering scene provided by an embodiment of the present invention;
[0040] Figure 4 A schematic diagram of a flow chart of another image drawing method provided by an embodiment of the present invention;
[0041] Figure 5 A schematic diagram of the corresponding relationship between image data and three-dimensional terrain data provided by an embodiment of the present invention;
[0042] Figure 6 A schematic diagram of the corresponding relationship between image data after sampling and interpolation calculation and three-dimensional terrain data provided by an embodiment of the present invention;
[0043] Figure 7 A schematic diagram of the structure of an image drawing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to solve the technical problem of low drawing efficiency of current image drawing methods, an embodiment of the present invention provides an image drawing method and device, wherein an image processor obtains image data corresponding to a target image to be drawn, wherein the image data includes pixel data of multiple pixels, the pixel data of the pixel includes image channel parameter values and target parameter values, the target parameter values are obtained by replacing at least a part of the image channel parameter values, and the target parameter values are stored in at least one image channel of the pixel; then, the corresponding target drawing points are drawn according to the target parameter values of the pixel points to obtain the target image, so that the image processor can quickly obtain the required target parameter values through the image data for drawing, and make full use of its own high parallel computing capability to process multiple image data in parallel to improve the drawing efficiency.
[0045] The technical solution provided by the embodiment of the present invention can be used for drawing topographic maps in scenes such as digital large screens or web pages, and can also be used for drawing other images, such as drawing images in e-commerce platforms.
[0046] The following first explains some of the terms involved in the embodiments of the present invention to facilitate understanding of the technical solutions in the embodiments of the present invention:
[0047] DEM data: Digital Elevation Model (DEM) data mainly describes the spatial distribution of regional landforms; specifically, it is a collection of sampling points formed after sampling at a preset sampling interval in a certain area, which contains the geographic coordinates (latitude and longitude) and elevation values of the sampling points. DEM data is generally collected in a regular grid manner, that is, sampling is performed along equally spaced rows and columns, where a regular grid is a matrix grid composed of small rectangular or square meshes, and each grid unit represents a small geographical area. For example, a square geographical area of 100m*200m is sampled at a spacing of 10m*10m (that is, each grid unit represents a geographical area of 10m*10m), and a 10*20 grid (including 10*20 grid units) can be formed; according to the geographic coordinates of the four vertices of the geographical area, the geographical area represented by each grid unit can be determined. Here, a grid unit represents a sampling point. When storing the sampling points, a two-dimensional array is generally established for the sampling points according to their corresponding positions in the grid, and the elevation value of the sampling point is stored in the two-dimensional array as the array value of the sampling point.
[0048] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0049] Figure 1 A flowchart of an image drawing method provided by an embodiment of the present invention is shown in FIG. Figure 1As shown, the method provided in this embodiment may include the following steps:
[0050] S110: Obtain image data corresponding to the target image to be drawn.
[0051] In this embodiment, the image data includes pixel data of a plurality of pixel points, and the pixel data of the pixel points includes image channel parameter values and target parameter values.
[0052] The image channel parameter value may be an RGBA four-channel parameter value, or may be other image channel parameter values such as HIS. In this embodiment, the RGBA four-channel parameter value is used as an example for illustrative description.
[0053] The target parameter value is obtained by replacing at least a part of the image channel parameter value, which is stored in at least one image channel of the pixel point. For example, part or all of the image channel parameter values of a channel in the image data are replaced with the target parameter value, and the target parameter value is correspondingly stored in the channel of the pixel point; or part or all of the image channel parameter values of multiple channels in the image data can be replaced with the target parameter value, and the target parameter value is correspondingly stored in multiple channels of the pixel point. It can be set as needed during specific implementation, and this embodiment does not specifically limit this.
[0054] In this embodiment, the target image can be a three-dimensional topographic map, and the target parameter value of the pixel in the image data can be the elevation value of the corresponding target drawing point; the target image can also be other images, and the target parameter value can be the parameter value corresponding to the target rendering effect. For example, some product images need to show a dynamic rotation effect, and the parameter value corresponding to the dynamic rotation effect can be stored in the image data as the target parameter value. The target parameter value can be set as needed during specific implementation, and this embodiment does not specifically limit this.
[0055] The image processor can obtain image data from the central processing unit, and after obtaining the image data, further processing can be performed, such as sampling interpolation processing, to obtain new image data. The image processor can be a graphics processing unit (GPU) or other image processors with high parallel computing capabilities. The embodiment of the present invention takes the GPU as an example for exemplary description.
[0056] S120 , drawing corresponding target drawing points according to the target parameter values of the pixel points in the image data to obtain a target image.
[0057] Specifically, the pixel points in the image data correspond to the target drawing points to be drawn. After obtaining the image data, the image processor can draw the corresponding target drawing points according to the target parameter values of the pixel points in the image data to obtain the target image.
[0058] Taking the target image as a three-dimensional terrain map as an example, the image processor can perform terrain stretching and rendering processing on the corresponding target drawing points according to the elevation values of the pixel points to obtain the target image. In this way, the terrain can be stretched according to the elevation values to obtain a three-dimensional terrain effect, and the corresponding color values can be determined according to the elevation values for terrain rendering to obtain the final three-dimensional terrain map without first establishing a geometric model and then rendering the terrain; and the high parallel computing power of the image processor can be used to draw multiple target drawing points in parallel, thereby effectively improving the drawing efficiency.
[0059] Among them, the target drawing point can be determined according to the three-dimensional terrain data. Specifically, the three-dimensional terrain data is a collection of a series of sampling points, wherein each sampling point is represented by a three-dimensional coordinate. In a specific implementation, the three-dimensional terrain data can be the commonly used DEM data, or it can be other data containing three-dimensional coordinates of the terrain. In the embodiment of the present invention, DEM data is used as an example. The DEM data includes a series of sampling points, and the image processor can specifically determine the target drawing point to be drawn according to the sampling points in the DEM data. For example, each sampling point in the DEM data can be directly used as the target drawing point to be drawn.
[0060] The pixel points in the image data correspond to the target drawing points to be drawn. Taking the target drawing points as sampling points in the DEM data as an example, the number of pixel points in the image data is consistent with the number of target drawing points (i.e., the number of sampling points). For example, a grid including 10*20 grid units (i.e., sampling points) can form image data with a pixel resolution of 10*20.
[0061] When drawing a three-dimensional terrain map, a rectangular geometric body can be simply drawn initially according to the target drawing point to be drawn. For a certain target drawing point, the elevation value stored in the pixel point corresponding to the target drawing point can be extracted from the image data, and the terrain can be stretched at the position corresponding to the target drawing point on the rectangular geometric body according to the elevation value; at the same time, the corresponding color value is determined according to the elevation value to render the terrain. Among them, when rendering the target drawing point, the corresponding color value can be preset for the target drawing point with a specific elevation value or a specific elevation value range according to the needs, and the corresponding preset color value is used to render these target drawing points with a specific elevation value or a specific elevation value range during rendering; for other target drawing points, the color value of the pixel point corresponding to the target drawing point in the image data can be used to render the target drawing point.
[0062] In the image drawing method provided in this embodiment, the image processor first obtains the image data corresponding to the target image to be drawn, wherein the image data includes pixel data of multiple pixels, the pixel data of the pixel includes image channel parameter values and target parameter values, the target parameter values are obtained by replacing at least a part of the image channel parameter values, and the target parameter values are stored in at least one image channel of the pixel; then the corresponding target drawing points are drawn according to the target parameter values of the pixel points to obtain the target image. In this way, the image processor can quickly obtain the required target drawing parameters through the image data for drawing, and can make full use of its own high parallel computing capabilities to process multiple image data in parallel, thereby effectively improving the drawing efficiency.
[0063] Figure 2 This is a flow chart of another image drawing method provided by an embodiment of the present invention. This embodiment is a specific implementation method of drawing an image when the target image is a three-dimensional topographic map. Figure 1 Based on the embodiment shown, Figure 1 As shown, the method provided in this embodiment may include the following steps:
[0064] S210: Obtain image data corresponding to the three-dimensional topographic map to be drawn.
[0065] Specifically, the GPU may obtain image data generated based on three-dimensional terrain data from a central processing unit (CPU) or a memory, wherein the target parameter value of a pixel point in the image data may specifically be an elevation value of a corresponding target drawing point. Figure 3 A schematic diagram of a three-dimensional terrain map rendering scene provided by an embodiment of the present invention, such as Figure 3 As shown, the target parameter value can be specifically stored in the A channel of the pixel point, that is, the A channel parameter value (transparency value) of the pixel point can be replaced by the elevation value of the corresponding target drawing point; the image channel parameter value of the pixel point in the image data can be specifically a color value, for example Figure 3 ; in this embodiment, the pixel data of some or all of the pixels in the image data may also include only the elevation value as needed, without including the image channel parameter value, so as to save storage space. For example, when the color value corresponding to each elevation value is preset, the pixel data of each pixel in the image data may not include the color value (i.e., the image channel parameter value), but only include the elevation value; when the color value corresponding to a specific elevation value is preset, the pixel point whose elevation value stored in the image data is the specific elevation value may not include the image channel parameter value, but only include the elevation value. Figure 3 The example in which the pixel data includes both the image channel parameter value and the elevation value (ie, the target parameter value) is used for exemplary description.
[0066] In specific implementation, in this embodiment, the elevation value of a specific target drawing point can also be set to a preset value as needed. For example, if a certain terrain area has non-terrain objects such as covers or buildings that can block the ground, the drawn terrain geometry will block these covers or buildings. Therefore, in order to avoid this problem, the areas in the terrain geometry that should not block non-terrain objects can be determined, and the elevation values of the target drawing points corresponding to these areas can be set to preset values, such as 0, and they are treated as plane terrain when drawing.
[0067] In this embodiment, in order to improve the flexibility of image drawing, at least a part of the image channel parameter values of the pixel points in the target area in the image data can be replaced with the elevation value according to the demand, and the image channel parameter values of the pixel points in other areas of the image data except the target area are not replaced. For example: the original image data of some important areas in the image data needs to be retained, or the image areas corresponding to some non-terrain objects irrelevant to the height do not need elevation value information, then the A channel of the pixel points in these areas retains the transparency value, and the transparency value of the A channel of the pixel points in other areas is replaced with the elevation value of the corresponding target drawing point.
[0068] After acquiring the image data, the GPU can directly perform equal-precision drawing based on the image data with respect to the precision of the DEM data; considering that in conventional topographic map drawing methods, the precision of the drawn topographic map is limited by the precision of the original three-dimensional topographic data because the CPU cannot perform flexible interpolation calculations, while the GPU can perform flexible interpolation calculations in the image space, therefore, in this embodiment, the GPU can perform sampling interpolation calculations on the image data when the precision of the three-dimensional topographic data does not meet the preset precision requirements, so that the precision corresponding to the new image data meets the precision requirements, and perform non-equal-precision drawing relative to the precision of the DEM data, so that the drawn topographic map is not limited by the precision of the original three-dimensional topographic data, so as to improve the drawing effect of the topographic map and better meet user needs.
[0069] In specific implementation, the GPU can first determine whether the accuracy of the three-dimensional terrain data meets the preset accuracy requirements. If not, it can first perform sampling and interpolation calculations on the image data to make the accuracy corresponding to the image data meet the accuracy requirements; if the accuracy of the three-dimensional terrain data meets the preset accuracy requirements, there is no need to perform sampling and interpolation calculations on the image data.
[0070] S220: Determine a target drawing point to be drawn according to the three-dimensional terrain data.
[0071] As described above, when the accuracy of the three-dimensional terrain data meets the preset accuracy requirements, the GPU can perform equal-precision drawing relative to the accuracy of the DEM data. At this time, each sampling point in the three-dimensional terrain data can be directly used as the target drawing point to be drawn.
[0072] The GPU can also perform non-equal precision drawing relative to the DEM data when the accuracy of the 3D terrain data does not meet the preset accuracy requirements. At this time, the target drawing points to be drawn can be determined according to the geographical range of the 3D terrain data and the accuracy requirements. In specific implementation, the 3D terrain data can be re-gridified according to the accuracy requirements, the target drawing points to be drawn can be determined, and a new correspondence between the image data and the 3D terrain data can be established.
[0073] It should be noted that there is no strict timing execution relationship between steps S210 and S220, and this embodiment does not specifically limit the execution order between the two.
[0074] S230 , performing terrain stretching and rendering processing on the corresponding target drawing points according to the elevation values of the pixel points in the image data to obtain a three-dimensional terrain map.
[0075] Specifically, for a certain target drawing point, the elevation value of the target drawing point can be obtained from the image data, that is, the elevation value stored in the A channel of the pixel point corresponding to the target drawing point; after obtaining the elevation value of the target drawing point, the GPU can stretch the terrain according to the elevation value to obtain a three-dimensional terrain effect, and at the same time determine the corresponding color value according to the elevation value to perform terrain rendering, to obtain the final three-dimensional terrain map.
[0076] In the current topographic map drawing process, when drawing contour lines, the CPU calculates the vertex data of the contour lines, and then uploads it to the GPU, which renders the contour lines. At the same time, the GPU draws the terrain according to the terrain data, and finally displays the contour lines superimposed on the drawn terrain for output. Considering that this contour line drawing method has low calculation efficiency of the contour lines, resulting in low overall drawing efficiency, in this embodiment, it can be determined whether the target drawing point belongs to the point on the contour line to be drawn according to the elevation value of the target drawing point. If so, it can be rendered using a pre-set rendering effect to highlight these target drawing points and form contour lines. In this way, there is no need to perform complex contour line calculations by the CPU, and the image processor itself has a high parallel computing capability, which can process multiple parts of the contour line at the same time to achieve rapid determination of the contour line, thereby effectively improving the contour line drawing efficiency.
[0077] In a specific implementation, a preset color value corresponding to the elevation value of the contour line to be drawn (here referred to as the target elevation value) can be pre-set. For each target drawing point, after obtaining the elevation value of the target drawing point, the target drawing point can be subjected to terrain stretching processing according to the elevation value of the target drawing point in the image data; when rendering, it can be first determined whether the elevation value of the target drawing point is the target elevation value. When the elevation value of the target drawing point is the target elevation value, the target drawing point is rendered using the preset color value corresponding to the target elevation value to highlight the target drawing point, wherein the target elevation value is the elevation value of any contour line to be drawn; when the elevation value of the target drawing point is not the target elevation value, the target drawing point can be rendered using the color value of the pixel point corresponding to the target drawing point in the image data. In this way, the target drawing points belonging to the same contour line are rendered with the same color value. After the drawing is completed, contour lines can be formed, that is, the contour lines are drawn while the terrain area is drawn, without the need to calculate the points on each contour line through the CPU. Moreover, the GPU itself has a very high parallel computing capability and can obtain, judge and render the elevation values of multiple target drawing points at the same time, thereby effectively improving the contour line drawing efficiency.
[0078] Among them, different contour lines correspond to different target elevation values, and the preset color values corresponding to each target elevation value can be the same, that is, all contour lines are rendered with the same rendering effect, for example: the target drawing points belonging to the contour line are all rendered in red; the preset color values corresponding to each target elevation value can also be the same, that is, different contour lines can be rendered with different rendering effects, for example: the target drawing points on the contour line with an elevation value of 100m are rendered in red, and the target drawing points on the contour line with an elevation value of 200m are rendered in blue. In specific implementation, it can be selected as needed, and this embodiment does not make any special restrictions on this. In addition, other rendering effects can also be added during specific rendering, and this embodiment does not make any special restrictions on this.
[0079] When the image processor is drawing, it draws the image position corresponding to the geographic coordinates of the target drawing point. For the geographic coordinates of the target drawing point, when drawing with equal precision, the geographic coordinates of the target drawing point can be directly extracted from the DEM data; when drawing with non-equal precision, the geographic coordinates of each target drawing point can be calculated according to the geographic range of the three-dimensional terrain data and the above-mentioned accuracy requirements.
[0080] In this embodiment, the elevation value of the contour line to be drawn can be a system preset elevation value, or it can be an elevation value determined by the CPU or GPU according to the contour line drawing conditions input by the user, so as to better meet user needs and improve user experience; for example, the contour line drawing conditions input by the user are: draw a contour line every 100 meters, then the elevation values of the contour lines to be drawn include: 100 meters, 200 meters, 300 meters..., and the maximum elevation value of the contour line can be set as needed. Similarly, the preset color value corresponding to the target elevation value can be a system preset, or it can be determined according to the contour line rendering conditions input by the user, for example: the contour line rendering conditions input by the user are: all contour lines will be drawn in red, that is, the preset color value corresponding to any target elevation value is red.
[0081] In this embodiment, for other terrain areas that do not belong to the contour lines, the target drawing points can be rendered using the color values of the pixels corresponding to the target drawing points in the image data. Of course, corresponding color values can also be set for the target terrain that belongs to the target elevation value range. When drawing, the target drawing points whose elevation values are within the target elevation value range are rendered using the corresponding color values. Similar to the color value setting method for contour lines, the color value corresponding to the target terrain can be preset by the system or set by the user.
[0082] like Figure 3 As shown, after the GPU draws the target drawing points and obtains the target image, the target image can be transmitted to the display so that the display can display a complete terrain map, such as Figure 3 As shown, Figure 3 A topographic map is shown on the display. The display may be a conventional computer display or a large-screen display ( Figure 3 In the example, a large-screen display is used as an example for illustrative explanation); in addition, the display can be a separate structure from the terrain rendering device, or can be integrated with the terrain rendering device on the same device; when the two are separate structures, the display can transmit data to the terrain rendering device through wired or wireless means, Figure 3 The wired method is used as an example for illustration.
[0083] In the image drawing method provided by the present embodiment, in the obtained image data, the pixel data of the pixel point includes the elevation value of the corresponding target drawing point. When drawing a three-dimensional terrain map, the target drawing point can be stretched according to the elevation value in the image data to obtain a three-dimensional terrain effect. At the same time, the target drawing point can be rendered according to the elevation value to obtain the final three-dimensional terrain map, without having to first establish a geometric model and then perform terrain rendering; and the high parallel computing power of the image processor can be used to draw multiple target drawing points in parallel, thereby effectively improving the drawing efficiency.
[0084] Figure 4 A flowchart of another image drawing method provided by an embodiment of the present invention is provided. This embodiment is a specific implementation method when considering non-equal precision drawing. Figure 2 Based on the embodiment shown, Figure 4 As shown, the method provided in this embodiment may include the following steps:
[0085] S310: Acquire image data generated based on three-dimensional terrain data.
[0086] Specifically, the initial image data can be generated by the CPU based on the three-dimensional terrain data. When generating the data, taking DEM data as an example, the size of the grid (width*height) can be used as the pixel resolution to create a two-dimensional array corresponding to the pixel points in the image data, and then the elevation values are extracted row by row from the two-dimensional array of the DEM data as the values of the corresponding elements in the two-dimensional array corresponding to the image data, that is, the pixel points in the image data correspond to the sampling points in the terrain data one by one. Here, this correspondence is called the first correspondence. For example, Figure 5 A schematic diagram of the corresponding relationship between the image data and the three-dimensional terrain data provided by the embodiment of the present invention, such as Figure 4 As shown in the figure, the DEM data of the 8*10 grid generates image data with a pixel resolution of 8*10. The pixel point (i, j) corresponds to the sampling point (i, j). The pixel point (i, j) stores the elevation value of the sampling point (i, j), where i is an integer less than 8 and j is an integer less than 10.
[0087] After the CPU generates image data, it passes the image data to the GPU, which then draws the subsequent terrain.
[0088] S320: When the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirement, perform sampling interpolation calculation on the image data to obtain new image data.
[0089] After receiving the image data transmitted by the CPU, the GPU can first determine whether the accuracy of the three-dimensional terrain data meets the preset accuracy requirements; if not, it can perform sampling and interpolation calculations on the image data to make the accuracy corresponding to the image data meet the accuracy requirements; if it does, the image data can be left unprocessed.
[0090] The preset accuracy requirement may be that the accuracy of the three-dimensional terrain data is equal to the target accuracy, and the sampling interpolation calculation may specifically include up-sampling interpolation calculation and down-sampling interpolation calculation.
[0091] In the specific implementation, the GPU can determine the relationship between the accuracy of the three-dimensional terrain data and the target accuracy. When the accuracy of the three-dimensional terrain data is less than the target accuracy, the image data is upsampled and interpolated to increase the number of pixels in the image data, making the subsequently drawn terrain map smoother and clearer. When the accuracy of the three-dimensional terrain data is greater than the target accuracy, the image data is downsampled and interpolated to reduce the number of pixels in the image data, so that the drawn terrain map meets the visualization requirements while improving the drawing speed.
[0092] S330: Determine the target drawing point to be drawn according to the geographical scope and accuracy requirements of the three-dimensional terrain data.
[0093] Specifically, when the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirement, the GPU needs to determine the target drawing point to be drawn according to the geographical range and accuracy requirement of the three-dimensional terrain data.
[0094] In the specific implementation, the grid size required for the three-dimensional terrain data can be calculated based on the geographic coordinates of the four vertices of the three-dimensional terrain data (i.e., the geographic range) and the above-mentioned target accuracy. The geographic range can be re-gridified according to the grid size to determine the target drawing points to be drawn. Figure 6 A schematic diagram of the corresponding relationship between the image data after sampling and interpolation calculation and the three-dimensional terrain data provided by the embodiment of the present invention, such as Figure 6 As shown, Figure 5 After the image data in the image is upsampled and interpolated, its pixel resolution changes from 8*10 to 10*12. Correspondingly, after the three-dimensional terrain data is re-gridified, its grid size also changes from 8*10 to 10*12. At this time, the correspondence between the image data and the three-dimensional terrain data also changes accordingly. Among them, the new correspondence (herein referred to as the second correspondence) is also determined based on the above-mentioned accuracy requirements and the geographical scope of the three-dimensional terrain data. In specific implementation, the grid size required for the three-dimensional terrain data can be calculated based on the geographical scope of the three-dimensional terrain data and the above-mentioned target accuracy. The new correspondence can be determined based on the grid size, that is, the pixel point (i, j) corresponds to the sampling point (i, j), and the pixel point (i, j) stores the elevation value of the sampling point (i, j), where i is less than the grid width (such as Figure 6 The grid width in 10) is an integer, j is less than the grid height (such as Figure 6 The grid height in 12) is an integer.
[0095] It should be noted that when the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirements, the image processor executes the above three steps: sampling and interpolation calculation of the image data, determining the target drawing points to be drawn, and determining the new corresponding relationship. There is no strict execution timing relationship between these three steps. The three steps can be executed in any order or simultaneously. This embodiment does not make any special limitations on this.
[0096] S340 , for each target drawing point, performing terrain stretching processing on the target drawing point according to the elevation value of the target drawing point in the image data.
[0097] Specifically, when drawing a three-dimensional terrain map, a rectangular geometric body can be simply drawn initially according to the target drawing point to be drawn. For a certain target drawing point, the terrain can be stretched at the position corresponding to the target drawing point on the rectangular geometric body according to the elevation value of the target drawing point.
[0098] When obtaining the elevation value of the target drawing point, the elevation value of the target drawing point can be extracted from the image data according to the above new correspondence. For example, for the target drawing point (i, j), the pixel point (i, j) can be found from the image data, and the elevation value stored in the pixel point can be extracted, which is the elevation value of the target drawing point (i, j).
[0099] S350: When the elevation value of the target drawing point is the target elevation value, the target drawing point is rendered using a preset color value corresponding to the target elevation value to highlight the target drawing point.
[0100] Specifically, the rendering effect of the contour lines can be preset. For each target drawing point, after the elevation value is obtained, it can be determined whether the target drawing point belongs to the contour line or the terrain according to the elevation value. When the elevation value of the target drawing point is the target elevation value, the target drawing point is rendered using the preset color value corresponding to the target elevation value. Among them, the target elevation value is the elevation value of any contour line to be drawn, and different contour lines correspond to different target elevation values. The preset color values corresponding to each target elevation value can be the same, that is, all contour lines are rendered using the same rendering effect; the preset color values corresponding to each target elevation value can also be the same, that is, different contour lines can be rendered using different rendering effects. The specific selected rendering effect is not particularly limited in this embodiment. For example, Figure 3 As shown in , different contour lines are rendered using the same rendering effect.
[0101] S360: When the elevation value of the target drawing point is not the target elevation value, the target drawing point is rendered using the color value of the pixel point corresponding to the target drawing point in the image data.
[0102] Specifically, for other terrain areas that do not belong to the contour lines, the target drawing points can be rendered using the color values of the pixels corresponding to the target drawing points in the image data. In specific implementation, different color values can be set for terrains with different elevation value ranges when generating image data, that is, different terrains can be rendered using different rendering effects, for example Figure 3 As shown in , different terrains are rendered with different grayscale values.
[0103] In the terrain map drawing method provided in this embodiment, the image processor directly determines the contour line according to the elevation value of the target sampling point to be drawn, without the need for complex contour line calculations by the CPU, and the image processor itself has a high parallel computing capability, and can simultaneously process multiple parts of the contour line to achieve rapid determination of the contour line; in addition, the determination and rendering of the contour line are unified in the image processor, and the determination result is directly used as the input parameter of the rendering, thereby effectively improving the efficiency of contour line drawing. In addition, when the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirements, the image processor performs sampling interpolation calculations on the image data; and determines the target drawing point to be drawn according to the geographical scope and accuracy requirements of the three-dimensional terrain data, and then draws the target drawing point, so that a terrain map that meets the preset accuracy requirements can be drawn, and the drawn terrain map is not limited by the accuracy of the original three-dimensional terrain data.
[0104] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present invention provides an image drawing device, and the device embodiment corresponds to the above method embodiment. For ease of reading, the present device embodiment will no longer repeat the details of the above method embodiment one by one, but it should be clear that the device in this embodiment can correspond to and implement all the contents of the above method embodiment.
[0105] Figure 7 A schematic diagram of the structure of an image drawing device provided by an embodiment of the present invention is shown in FIG. Figure 7 As shown, the image drawing device provided by this embodiment includes: a memory 110 and an image processor 120, wherein the memory 110 is used to store a computer program; the image processor 120 is used to execute the method described in the above method embodiment when calling the computer program.
[0106] The image processor 120 may be a GPU, or other image processing devices with high parallel computing capabilities.
[0107] The image drawing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0108] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described in the above method embodiment is implemented.
[0109] An embodiment of the present invention also provides a display screen for displaying a target image, wherein the target image is drawn according to the target parameter values of the pixel points in the image data corresponding to the target image, the image data includes pixel data of multiple pixel points, the pixel data of the pixel points includes image channel parameter values and target parameter values, the target parameter values are obtained by replacing at least a part of the image channel parameter values, and the target parameter values are stored in at least one image channel of the pixel points.
[0110] In this embodiment, the display screen can be a large digital screen or other small display screens. The display screen can display the target image drawn by the image drawing device in the above embodiment. When the display screen is a small display screen, it can also be integrated into the image drawing device.
[0111] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media that include computer-usable program code.
[0112] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0113] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0114] Computer readable media include permanent and non-permanent, removable and non-removable storage media. Storage media can be implemented by any method or technology to store information, and the information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0115] 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 replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image drawing method, characterized in that: include: Obtaining image data corresponding to a target image to be drawn, the image data comprising pixel data of a plurality of pixels, the pixel data of the pixels comprising image channel parameter values and target parameter values, the target parameter values being obtained by replacing at least a portion of the image channel parameter values, the target parameter values being stored in at least one image channel of the pixels, the target image being a three-dimensional topographic map, and the target parameter values of the pixels in the image data being elevation values of corresponding target drawing points; Performing terrain stretching and rendering processing on the corresponding target drawing points according to the elevation values of the pixel points to obtain the target image; The terrain stretching and rendering processing is performed on the corresponding target drawing point according to the elevation value of the pixel point, including: For each target drawing point, performing terrain stretching processing on the target drawing point according to the elevation value of the target drawing point in the image data; When the elevation value of the target drawing point is a target elevation value, the target drawing point is rendered using a preset color value corresponding to the target elevation value to highlight the target drawing point, and the target elevation value is the elevation value of any contour line to be drawn; When the elevation value of the target drawing point is not the target elevation value, the target drawing point is rendered using the color value of the pixel point corresponding to the target drawing point in the image data.
2. The method according to claim 1, characterized in that Before drawing the corresponding target drawing point according to the target parameter value of the pixel point, the method further includes: Determine the target drawing point to be drawn according to the three-dimensional terrain data.
3. The method according to claim 2, characterized in that The step of obtaining image data corresponding to the target image to be drawn includes: Acquire image data generated based on three-dimensional terrain data; When the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirement, performing sampling interpolation calculation on the image data to obtain new image data; The step of determining the target drawing point to be drawn according to the three-dimensional terrain data includes: According to the geographical range of the three-dimensional terrain data and the accuracy requirement, a target drawing point to be drawn is determined.
4. The method according to claim 3, characterized in that The preset accuracy requirement is that the accuracy of the three-dimensional terrain data is equal to the target accuracy, and the sampling interpolation calculation is an up-sampling interpolation calculation or a down-sampling interpolation calculation; when the accuracy of the three-dimensional terrain data does not meet the preset accuracy requirement, performing sampling interpolation calculation on the image data includes: When the accuracy of the three-dimensional terrain data is less than the target accuracy, performing upsampling interpolation calculation on the image data; When the accuracy of the three-dimensional terrain data is greater than the target accuracy, downsampling interpolation calculation is performed on the image data.
5. The method according to claim 1, characterized in that When the elevation value of the target drawing point is the target elevation value, before rendering the target drawing point using the preset color value corresponding to the target elevation value, the method further includes: The target elevation value is determined according to the contour drawing conditions input by the user.
6. The method according to claim 5, characterized in that The method further comprises: According to the contour rendering condition input by the user, a preset color value corresponding to the target elevation value is determined.
7. The method according to any one of claims 2 to 6, characterized in that: The elevation value of the target drawing point corresponding to the preset terrain area in the image data is set to a preset value.
8. The method according to any one of claims 2 to 6, characterized in that: At least a portion of the image channel parameter values of the pixels in the target area in the image data is replaced with elevation values, and the image channel parameter values of the pixels in other areas of the image data except the target area are not replaced.
9. The method according to claim 1, characterized in that: The target parameter value is a parameter value corresponding to the target rendering effect.
10. An image drawing device, characterized in that: include: A memory and an image processor, wherein the memory is used to store a computer program; and the image processor is used to execute the method according to any one of claims 1 to 9 when calling the computer program.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
12. A display screen, characterized in that: Used to display a target image, wherein the target image is drawn by performing terrain stretching and rendering processing on corresponding target drawing points according to the elevation values of the pixel points, the image data includes pixel data of multiple pixel points, the pixel data of the pixel points includes image channel parameter values and target parameter values, the target parameter values are obtained by replacing at least a part of the image channel parameter values, the target parameter values are stored in at least one image channel of the pixel points, the target image is a three-dimensional terrain map, and the target parameter values of the pixel points in the image data are the elevation values of the corresponding target drawing points; The terrain stretching and rendering processing is performed on the corresponding target drawing point according to the elevation value of the pixel point, including: For each target drawing point, performing terrain stretching processing on the target drawing point according to the elevation value of the target drawing point in the image data; When the elevation value of the target drawing point is a target elevation value, the target drawing point is rendered using a preset color value corresponding to the target elevation value to highlight the target drawing point, and the target elevation value is the elevation value of any contour line to be drawn; When the elevation value of the target drawing point is not the target elevation value, the target drawing point is rendered using the color value of the pixel point corresponding to the target drawing point in the image data.
Citation Information
Patent Citations
Selenographic globe and manufacturing method thereof
CN101976531A
SGOG tile-based large region true three-dimensional geographic scene adaptive construction method
CN106898045A
Method and device for drawing three-dimensional electronic map
CN107689189A
Three-dimensional simulation system for typhoon disaster monitoring and assessment
CN108170714A
WPF-based three-dimensional terrain high-efficiency gradient coloring method
CN108305315A
