Method and device for generating three-dimensional thermal map, storage medium and electronic device
By generating regular mesh and target grayscale images and using interpolation method for three-dimensional rendering, the problem of low accuracy in three-dimensional heat map generation is solved, and a higher quality display effect is achieved.
Patent Information
- Application Number
- CN202411372942.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-09-29
AI Technical Summary
In the prior art, the accuracy of generation of three-dimensional heat maps in three-dimensional scenes is low, and there is a grid hollowing phenomenon, resulting in poor display effect.
By obtaining discrete point data associated with the heat map to be generated, a regular grid is generated, and the target grayscale image is generated based on this, the pixel value is determined using the interpolation method, and three-dimensional rendering is performed to improve the quality and accuracy of the heat map.
It improves the accuracy of generation of three-dimensional heat maps, solves the problem of grid hollowing, and enhances the display effect.
Smart Images

Figure CN118864683B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to a method and device for generating a three-dimensional thermal map, a storage medium, and an electronic device. Background Art
[0002] In three-dimensional scene rendering, a three-dimensional heat map is usually used to display the distribution of data. Specifically, the three-dimensional heat map is superimposed on the three-dimensional scene or other simulation models in the form of color coding. In the prior art, since the heat map is represented by linear elements in three-dimensional space, when the terrain, physical model and heat map in the three-dimensional scene are superimposed and displayed, there will be a grid hollowing phenomenon, which in turn leads to a technical problem of low generation accuracy of the three-dimensional heat map.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a method and device for generating a three-dimensional heat map, a storage medium, and an electronic device to at least solve the technical problem of low accuracy in generating a three-dimensional heat map.
[0005] According to one aspect of an embodiment of the present application, a method for generating a three-dimensional heat map is provided, comprising: in response to a heat map generation request message, obtaining discrete point data associated with a heat map to be generated, and generating a regular grid based on the discrete point data, wherein the discrete point data includes discrete coordinate points and feature values of the discrete coordinate points, and any of the discrete coordinate points belongs to a grid point in the regular grid; generating a target grayscale image based on the regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, and the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by the feature value of the discrete coordinate point associated with the corresponding grid point, the pixel value of the second pixel point is determined by interpolation of the feature value of the interpolation coordinate point associated with the corresponding grid point, and the interpolation coordinate point represents the discrete coordinate point of the grid point corresponding to the second pixel point that meets a preset range condition; performing three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel in the target grayscale image.
[0006] According to another aspect of an embodiment of the present application, a three-dimensional heat map generation device is also provided, including: an acquisition module, which is used to respond to a heat map generation request message, obtain discrete point data associated with the heat map to be generated, and generate a regular grid based on the discrete point data, wherein the discrete point data includes discrete coordinate points and feature values of the discrete coordinate points, and any of the discrete coordinate points belongs to a grid point in the regular grid; a generation module, which is used to generate a target grayscale image based on the regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, and the target grayscale image includes a first pixel point and a second pixel point, and the pixel value of the first pixel point is determined by the feature value of the discrete coordinate point associated with the corresponding grid point, and the pixel value of the second pixel point is determined by interpolation by the feature value of the interpolation coordinate point associated with the corresponding grid point, and the interpolation coordinate point represents the discrete coordinate point of the grid point corresponding to the second pixel point that meets the preset range condition; a rendering module, which is used to perform three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel in the target grayscale image.
[0007] Optionally, the device is used to respond to a heat map generation request message in the following manner, obtain discrete point data associated with the heat map to be generated, and generate a regular grid based on the discrete point data: in response to a heat map generation request message, obtain heat map range information, wherein the heat map range information is used to specify the heat map range of the target three-dimensional heat map; determine the discrete point data based on the heat map range information, wherein the discrete point data represents the discrete coordinate points located in the heat map range in a predetermined discrete point data set and the characteristic values associated with the discrete coordinate points; generate a regular grid based on the discrete point data.
[0008] Optionally, the device is used to generate a regular grid based on the discrete point data in the following manner: determine the horizontal coordinate extreme values and the vertical coordinate extreme values based on the discrete point data, wherein the horizontal coordinate extreme values include the horizontal coordinate maximum value and the horizontal coordinate minimum value of each discrete coordinate point in the discrete point data, and the vertical coordinate extreme values include the vertical coordinate maximum value and the vertical coordinate minimum value of each discrete coordinate point in the discrete point data; determine the number of grid points of the regular grid according to a predetermined grid granularity, the horizontal coordinate extreme values and the vertical coordinate extreme values, and generate the regular grid according to the number of grid points.
[0009] Optionally, the device is used to generate a target grayscale image based on the regular grid in the following manner: determine the first grid point and the second grid point based on the coordinate value of each discrete coordinate point in the discrete point data and the grid point position of each grid point in the regular grid, wherein any discrete coordinate point belongs to one of the first grid points, and any discrete coordinate point does not belong to any of the second grid points; assign a value to the first grid point based on the characteristic value of each discrete coordinate point, and determine the first grid point feature data corresponding to the first grid point; determine the interpolation coordinate point based on the grid point position of the second grid point, and perform bilinear interpolation on the second grid point based on the characteristic value of the interpolation coordinate point, and determine the second grid point feature data corresponding to the second grid point; determine the pixel values of the first pixel point and the second pixel point according to the first grid point feature data and the second grid point feature data, and generate the target grayscale image.
[0010] Optionally, the device is used to determine the interpolation coordinate point based on the grid point position of the second grid point in the following manner, and perform bilinear interpolation for the second grid point based on the characteristic value of the interpolation coordinate point to determine the second grid point characteristic data corresponding to the second grid point: determine a first horizontal coordinate interpolation coordinate point, a second horizontal coordinate interpolation coordinate point, a first vertical coordinate interpolation coordinate point and a second vertical coordinate interpolation coordinate point based on the grid point position of the second grid point, wherein the first horizontal coordinate interpolation coordinate point and the second horizontal coordinate interpolation coordinate point represent the two coordinate points closest to the second grid point in different directions along the horizontal coordinate axis, and the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point represent the two coordinate points closest to the second grid point in different directions along the vertical coordinate axis; perform bilinear interpolation based on the characteristic values corresponding to the first horizontal coordinate interpolation coordinate point, the second horizontal coordinate interpolation coordinate point, the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point, respectively, to determine the second grid point characteristic data corresponding to the second grid point.
[0011] Optionally, the device is used to perform three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map in the following manner: generate a grayscale texture according to the target grayscale image, determine a vertex buffer object according to the grayscale texture, wherein a vertex in the vertex buffer object corresponds to a pixel point in the target grayscale image; and perform three-dimensional rendering based on the vertex buffer object through a preset shader to obtain the target three-dimensional heat map.
[0012] Optionally, the device is used to perform three-dimensional rendering based on the vertex buffer object through a preset shader in the following manner to obtain the target three-dimensional heat map: sampling the height of each vertex from the grayscale texture through a vertex shader to determine the height information of each vertex in the target three-dimensional heat map, wherein the height information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; sampling the color of each vertex from the grayscale texture through a fragment shader to determine the color information of each vertex in the target three-dimensional heat map, wherein the color information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; performing three-dimensional rendering based on the height information and the color information to obtain the target three-dimensional heat map.
[0013] Optionally, the device is also used to: respond to the heat map generation request message sent by the front-end device, obtain discrete point data associated with the heat map to be generated, and generate the regular grid based on the discrete point data; generate the target grayscale image based on the regular grid, and convert the target grayscale image into a target character string and send it to the front-end device, so that the front-end device performs three-dimensional rendering based on the target character string through graphics processing to obtain the target three-dimensional heat map.
[0014] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned method for generating a three-dimensional thermal map when running.
[0015] According to another aspect of the embodiment of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above three-dimensional heat map generation method.
[0016] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned method for generating a three-dimensional thermal map through the computer program.
[0017] In an embodiment of the present application, in response to a heat map generation request message, discrete point data associated with the heat map to be generated is obtained, and a regular grid is generated based on the discrete point data, wherein the discrete point data includes discrete coordinate points and eigenvalues of the discrete coordinate points, and any discrete coordinate point belongs to a grid point in the regular grid; a target grayscale image is generated based on the regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by the eigenvalue of the discrete coordinate point associated with the corresponding grid point, and the pixel value of the second pixel point is determined by the eigenvalue of the interpolation coordinate point associated with the corresponding grid point. The eigenvalue is determined by interpolation, and the interpolation coordinate point represents a discrete coordinate point of a grid point corresponding to a second pixel point that satisfies a preset range condition; three-dimensional rendering is performed based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel point in the target grayscale image, by accurately mapping discrete point data to a regular grid and using an interpolation method to determine the pixel value, thereby ensuring the quality and accuracy of the three-dimensional heat map, achieving the purpose of improving the quality and accuracy of the three-dimensional heat map, thereby achieving the technical effect of improving the generation accuracy of the three-dimensional heat map, and then solving the technical problem of low generation accuracy of the three-dimensional heat map. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 is a schematic diagram of an application environment of an optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0020] Figure 2 It is a schematic diagram of a flow chart of an optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0021] Figure 3 is a schematic diagram of an optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0023] Figure 5 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0024] Figure 6 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0025] Figure 7 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0026] Figure 8 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0027] Fig. 9 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application;
[0028] Fig.10 is a schematic structural diagram of an optional three-dimensional heat map generating device according to an embodiment of the present application;
[0029] Fig.11 It is a structural schematic diagram of an optional three-dimensional heat map generation product according to an embodiment of the present application;
[0030] Fig.12 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] The present application is described below in conjunction with embodiments:
[0034] According to one aspect of an embodiment of the present application, a method for generating a three-dimensional heat map is provided. Optionally, in this embodiment, the method for generating a three-dimensional heat map can be applied to Figure 1 In the hardware environment composed of the server 101 and the terminal device 103 shown in FIG. Figure 1 As shown, the server 101 is connected to the terminal 103 via a network, and can be used to provide services for the terminal device or an application 107 installed on the terminal device. The application can be a video application, an instant messaging application, a browser application, an educational application, a game application, etc. A database 105 may be set up on the server or independently of the server to provide data storage services for the server 101, for example, a game data storage server. The above-mentioned network may include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network and a wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The terminal device 103 may be a terminal configured with an application, and may include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, a MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, a virtual reality (Virtual Reality, VR for short) terminal, an augmented reality (Augmented Reality, AR for short) terminal, a mixed reality (Mixed Reality, MR for short) terminal and other computer devices. The above-mentioned server may be a single server, or a server cluster consisting of multiple servers, or a cloud server.
[0035] Combination Figure 1 As shown, the above-mentioned method for generating the three-dimensional heat map can be executed by an electronic device, which can be a terminal device or a server. The above-mentioned method for generating the three-dimensional heat map can be implemented by the terminal device or the server respectively, or by the terminal device and the server together.
[0036] The above is only an example and is not specifically limited in this embodiment.
[0037] Optionally, as an optional implementation, as Figure 2 As shown, the method for generating the above three-dimensional heat map includes:
[0038] S202, in response to the heat map generation request message, obtaining discrete point data associated with the heat map to be generated, and generating a regular grid based on the discrete point data, wherein the discrete point data includes discrete coordinate points and feature values of the discrete coordinate points, and any discrete coordinate point belongs to a grid point in the regular grid;
[0039] It should be noted that heat map is a data visualization technology that is used to display the distribution of data in a certain area. The density or intensity of data is indicated by changes in color. Generally speaking, the darker the color, the denser the data points in the area or the higher the value.
[0040] Optionally, in an embodiment of the present application, the above-mentioned heat map generation request message may include but is not limited to the user's number or session information, the identifier of the data set or data source for which the heat map needs to be generated, specific parameters or settings, such as color scheme, resolution, data range, etc.
[0041] Exemplarily, a heat map generation request message may be issued by a user or a business system, and its purpose is to generate a heat map. The above-mentioned discrete point data refers to the original data points that constitute the heat map. Each discrete point has a discrete point coordinate (usually x and y coordinates in two-dimensional space) and a characteristic value (which can be any type of data, such as temperature, population density, sales, etc.). The above-mentioned regular grid is a grid system used to display data in a heat map. Each grid cell in the regular grid represents the data density or intensity in an area. The regular grid can be any shape, such as a square or rectangle. The size of each grid cell in the regular grid can be the same or different. In different business scenarios, the above-mentioned discrete point data is also different.
[0042] In an exemplary embodiment, taking parking as an example, the discrete coordinate point is the parking location, and the discrete point data is the coordinate information (for example, expressed in longitude and latitude) of the discrete coordinate point in the data provided by the parking service and the above-mentioned characteristic values. In the parking service scenario, the characteristic value may be one or more of the intensity of parking demand, parking time, parking fee, etc.
[0043] In another exemplary embodiment, taking the shopping mall business as an example, the discrete coordinate point is the location of the shopping mall, and the characteristic value may be the flow density of people in each shopping mall or the turnover of each shopping mall, etc.
[0044] Exemplarily, the step of determining the discrete point data associated with the above-mentioned heat map to be generated from a plurality of discrete point data may be as follows:
[0045] S1, parsing the heat map generation request message to obtain the data range required for the heat map to be generated;
[0046] S2, obtaining each discrete point data within the data range as the discrete point data associated with the above-mentioned thermal map to be generated.
[0047] In another exemplary embodiment, taking the shopping mall business as an example, the discrete coordinate points are the shopping mall locations, and the characteristic values are the pedestrian flow density of each shopping mall. It is assumed that the user circles the longitude and latitude range on a map on the terminal display screen through interactive operations such as touch screen, mouse, and keyboard, that is, selects a specific geographical area. The geographical area can be defined by inputting longitude and latitude coordinates as the data range in S1 above. Then, the discrete point data associated with the heat map to be generated is the location of each shopping mall within the longitude and latitude range, as well as the pedestrian flow density of each shopping mall.
[0048] In an exemplary embodiment, taking the discrete point coordinates representing the geographic longitude and latitude as an example, a regular grid can be generated by the following steps:
[0049] S1, define a two-dimensional discrete point class, which contains latitude and longitude and characteristic value fields, create an array based on this class, traverse the discrete points to obtain the extreme values Xmin, Ymin, Xmax, Ymax in both directions of longitude and latitude of each discrete point coordinate in the discrete point data;
[0050] S2, calculate the number of grids NumX and NumY in the two directions according to the XY direction size and the grid size, intNumX = std::ceil((Xmax - Xmin) / dx), intNumY = std::ceil((Ymax - Ymin) / dy); (dx is the width of each grid, dy is the length of each grid, (Xmax - Xmin) / dx calculates how many grids are theoretically needed to cover the range from Xmin to Xmax, (Ymax - Ymin) / dY calculates how many grids are theoretically needed to cover the range from Ymin to Ymax. Since the number of grids must be an integer, the std::ceil function is used to ensure that even if the calculation result is a decimal, it will be rounded up to the next integer, which ensures that the entire range is covered);
[0051] S3, traverse the grid points, and determine the inclusion relationship with the discrete points to assign the eigenvalues of the discrete points to the grid points.
[0052] It should be noted that in addition to determining the regular grid by the number of discrete point coordinates mentioned above, the regular grid can also be determined by the following methods, including but not limited to: based on the distribution of discrete point data: analyze the distribution of discrete point data, such as cluster analysis, to determine the distribution of the grid, increase the grid density in data-intensive areas, and reduce the grid density in data-sparse areas; based on terrain or landform characteristics: consider natural features such as terrain undulations, rivers, mountains, etc., and adjust the size and shape of the grid to better adapt to the terrain; based on functional requirements: design the grid to meet specific functional requirements according to the specific needs of the application scenario, such as urban planning, environmental monitoring, etc.; based on statistical methods: use statistical methods (such as variance analysis) to determine the optimal size and distribution of the grid to minimize errors or maximize information acquisition; based on user input: allow users to customize the size and distribution of the grid according to specific needs, providing flexibility; dynamic adjustment: dynamically adjust the size and distribution of the grid according to real-time data or changing environmental conditions.
[0053] In yet another exemplary embodiment, a regular grid is determined based on the distribution of discrete point data, and the regular grid may be generated by the following steps:
[0054] S1, collects a set of discrete point data, which can be geographic location, physical measurement points, user distribution, etc.;
[0055] S2, preprocessing of discrete point data, including but not limited to cleaning (removing outliers and erroneous data) and standardization (ensuring that the data are on the same scale);
[0056] S3, analyzing the distribution characteristics of discrete point data, such as density, clustered areas, etc., which may include but are not limited to using statistical methods or machine learning algorithms to identify the distribution pattern of data;
[0057] S4. Determine the size of the regular grid according to the data distribution and application requirements. For example, calculate the statistical indicators of the discrete point data, such as the mean, median, standard deviation, etc., to determine the approximate size of the grid; or use a clustering algorithm (such as K-means, DBSCAN, etc.) to identify natural clustering areas in the data and set the grid size according to the size of these areas; or, if the discrete point data is unevenly distributed in space, use a spatial interpolation method (such as Kriging interpolation, inverse distance weighted interpolation, etc.) to set the grid size;
[0058] S5, determining the maximum and minimum boundaries of the data distribution as the boundaries of the regular grid, and evenly dividing the boundaries according to the determined grid size in the grid dimension to form regular grid units;
[0059] S6, assigning each discrete coordinate point to a corresponding grid cell, and also aggregating the data within the grid cell, such as calculating the number, average value or other statistics of points within each grid cell;
[0060] It should be noted that in an embodiment of the present application, a grid within a regular grid may be associated with only one discrete coordinate point, that is, a grid may have only one discrete coordinate point, or may be associated with multiple discrete coordinate points, in which case multiple discrete points may fall within a grid.
[0061] S204, generating a target grayscale image based on a regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by a feature value of a discrete coordinate point associated with the corresponding grid point, the pixel value of the second pixel point is determined by interpolation of a feature value of an interpolation coordinate point associated with the corresponding grid point, and the interpolation coordinate point represents a discrete coordinate point of the grid point corresponding to the second pixel point that satisfies a preset range condition;
[0062] Exemplarily, the above-mentioned target grayscale image refers to a two-dimensional image, in which each pixel has a grayscale value between 0 (black) and 255 (white), and the target grayscale image does not contain color information but only brightness information; the above-mentioned first pixel can be understood as a pixel in the target grayscale image that can directly correspond to a discrete coordinate point in a regular grid, and the grayscale value of the first pixel is directly determined by the eigenvalue of the grid point to which they correspond; the above-mentioned second pixel can be understood as a pixel that cannot directly correspond to a discrete coordinate point in a regular grid, and the grayscale value of the second pixel is calculated from the eigenvalue of the discrete coordinate point that meets the preset range condition by an interpolation method, and the above-mentioned interpolation coordinate point refers to the grid point corresponding to the second pixel, and their eigenvalue is used to calculate the grayscale value of the second pixel by an interpolation method.
[0063] In an exemplary embodiment, assuming that the grid point at position (1, 3) in the regular grid falls into the discrete point, then the pixel point at (1, 3) of the target grayscale image corresponding to the grid point (1, 3) is the above-mentioned first pixel point; and the grid point at position (1, 2) in the regular grid does not fall into the discrete point, then the pixel point at (1, 2) of the target grayscale image corresponding to the grid point (1, 2) is the above-mentioned second pixel point.
[0064] It can be understood that the grids in the above regular grid correspond one-to-one to the pixel points of the target grayscale image, and the grids in the above regular grid may fall into the above discrete coordinate points or not, that is, the above grid points are associated with the discrete coordinate points.
[0065] It should be noted that interpolation is a mathematical method used to estimate the value of unknown data points between known data points, which may include but is not limited to linear interpolation, bilinear interpolation, cubic spline interpolation, etc.
[0066] Exemplarily, assuming that xValues is the x-coordinate set of each discrete coordinate point in the above discrete point data, yValues is the y-coordinate set of each discrete coordinate point in the above discrete point data, x is the x-coordinate of the grid point corresponding to the second pixel point, and y is the y-coordinate of the grid point corresponding to the second pixel point. Specifically, taking one pixel point in the second pixel point as an example:
[0067] Find the two discrete coordinate points xLower (find the discrete coordinate point closest to but less than or equal to x in xValues) and xUpper (find the discrete coordinate point closest to but greater than x in xValues) that are closest to x in xValues; find the two discrete coordinate points yLower (find the discrete coordinate point closest to but less than or equal to y in yValues) and yUpper (find the discrete coordinate point closest to but greater than y in yValues) that are closest to y in yValues, and obtain four discrete coordinate points, namely: xLower, xUpper, yLower, yUpper. These four discrete coordinate points are the discrete coordinate points of the grid points corresponding to the second pixel point that meet the preset range conditions.
[0068] In an exemplary embodiment, Figure 3 is a schematic diagram of an optional method for generating a three-dimensional heat map according to an embodiment of the present application, where xLower is Figure 3 The discrete coordinate point A shown; xUpper is Figure 3 The discrete coordinate point B shown; yLower is Figure 3 The discrete coordinate point B shown; yUpper is Figure 3 The discrete coordinate point D is shown.
[0069] Next, after obtaining xLower, xUpper, yLower, and yUpper (the above interpolation coordinate points), the eigenvalues corresponding to the four discrete coordinate points are obtained from the above discrete point data; bilinear (X direction, Y direction) interpolation is performed according to the eigenvalues and weights of the four discrete coordinate points, which can be expressed as:
[0070] double weightX = (xUpper - x) / (xUpper - xLower);
[0071] double weightY = (yUpper - y) / (yUpper - yLower);
[0072] double interpolatedValue = (1 - weightX) ((1 - weightY) xLowerValue + weightY yLowerValue) +weightX ((1 - weightY) xUpperValue + weightY yUpperValue).
[0073] Wherein, interpolatedValue is used to represent the pixel value of the second pixel point.
[0074] In another exemplary embodiment, assuming that a 5x5 regular grid is generated in step S202, the feature value of each grid point represents the height of the point, in order to generate a corresponding 5x5 target grayscale image, the specific implementation steps are as follows:
[0075] S1, the pixel value of the first pixel point (assuming it is the point in the upper left corner) is directly determined by the characteristic value of the discrete point data in the corresponding grid point. For example, the point in the upper left corner of the target grayscale image corresponds to the grid point in the upper left corner of the regular grid. A discrete point falls into the grid point, and its discrete point characteristic value is 10. Then the pixel value of the first pixel point is 10.
[0076] S2, the pixel value of the second pixel point (assuming it is the middle point) needs to be determined by interpolation. First, select the four nearest grid points (up, down, left, and right) around it. These points meet the above-mentioned preset range conditions (that is, the four grid points closest to the grid point corresponding to the second pixel point in the four directions of up, down, left, and right), respectively determine the eigenvalues of the discrete points falling within the four nearest grid points, use the bilinear interpolation method, calculate the eigenvalue of the center point based on the eigenvalues of these four points, and convert the calculated eigenvalue into a grayscale value, which is the pixel value of the second pixel point.
[0077] Exemplarily, since the pixel values of the target grayscale image are grayscale levels from 0 (black) to 255 (white), considering that the eigenvalues of the above-mentioned grid coordinate points may exceed the range of [0, 255], the embodiment of the present application provides numerical scaling and range mapping, that is, numerical scaling and range mapping operations are performed based on the eigenvalues of the discrete points in the grid so as to map the grid data to the grayscale range in the grayscale image, and record the mapping ratio of the eigenvalues and the pixel values.
[0078] In an exemplary embodiment, numerical scaling includes but is not limited to determining the maximum and minimum values of the eigenvalues of the grid coordinate points (or the eigenvalues obtained after the interpolation operation mentioned above), and then using these values to scale the data to fit within the range of 0 to 255, for example, dividing the data by the maximum value and then multiplying it by 255.
[0079] In yet another exemplary embodiment, range mapping includes but is not limited to being implemented by rounding off or using rounding after numerical scaling.
[0080] In another exemplary embodiment, in order to be able to perform an inverse operation when it may be necessary to restore the original data from the image data in the future, the scaling and mapping ratios may be recorded.
[0081] In yet another exemplary embodiment, if the feature value still exceeds the range of 0 to 255 after scaling, the feature value that exceeds the range may be directly set to a boundary value (0 or 255).
[0082] S206, performing three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel point in the target grayscale image.
[0083] Optionally, in an embodiment of the present application, in three-dimensional rendering, a two-dimensional grayscale image is converted into a three-dimensional heat map for visualizing the depth information of the image data. The above-mentioned target three-dimensional heat map may include but is not limited to the following elements: vertex height, color mapping, transparency, lighting effects, texture, etc.
[0084] Exemplarily, in the process of determining the height and color of each vertex in the above-mentioned target three-dimensional heat map according to the pixel value of each pixel point in the target grayscale image, the characteristic values can be respectively mapped to the height and color of each vertex in the target three-dimensional heat map through a preset mapping relationship. It can be understood that the mapping relationship can be flexibly set.
[0085] In an exemplary embodiment, in three-dimensional rendering, the grayscale value of each pixel can be used to determine the height of the corresponding vertex, which can be achieved by a mapping function that maps the grayscale value (usually between 0 and 255) to a height value in three-dimensional space. For example, a linear mapping can be set, where a grayscale value of 0 corresponds to the lowest height and a grayscale value of 255 corresponds to the highest height.
[0086] In another exemplary embodiment, in the three-dimensional heat map, a color gradient may be used to represent different grayscale values. For example, a gradient from blue (low grayscale value) to red (high grayscale value) or any other color mapping scheme may be used.
[0087] In yet another exemplary embodiment, Figure 4 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application, such as Figure 4 This may include, but is not limited to:
[0088] S401, start;
[0089] S402, the front-end page requests the server according to the business, and the server obtains the discrete points (the above-mentioned discrete point data) and generates a regular grid and a grayscale image for the discrete points;
[0090] Next, generate a regular grid on the server:
[0091] S403, the front end sends a request for the desired heat map latitude and longitude range and grid granularity (coverage range of each grid dx, dy) to the server, and the server queries for matching discrete points based on the latitude and longitude range. The points must include latitude and longitude and feature values, and define a two-dimensional discrete point class, which includes latitude and longitude and feature value fields. An array is created based on the class, and the discrete points are traversed to obtain the extreme values Xmin (minimum value in the X-axis direction), Ymin (minimum value in the Y-axis direction), Xmax (maximum value in the X-axis direction), and Ymax (maximum value in the Y-axis direction) in both directions of longitude and latitude.
[0092] S404, the front end defines the single grid size dx, dy (grid size), and requests the grid granularity (coverage range dx, dy of each grid) to the server;
[0093] S405, calculate the number of grids according to the X-axis, Y-axis direction and grid size, recorded as "NumX, NumY": calculate the number of grids NumX, NumY in the two directions according to the XY direction size and the grid size, intNumX = std::ceil((Xmax -Xmin) / dx), intNumY = std::ceil((Ymax - Ymin) / dy); (dx is the width of each grid, dy is the length of each grid, (Xmax - Xmin) / dx calculates how many grids are theoretically needed to cover the range from Xmin to Xmax, (Ymax - Ymin) / dY calculates how many grids are theoretically needed to cover the range from Ymin to Ymax, because the number of grids must be an integer, so the std::ceil function is used to ensure that even if the calculation result is a decimal, it will be rounded up to the next integer, so as to ensure that the entire range is covered);
[0094] S406, traversing the grid points and determining the inclusion relationship with the discrete points, and assigning the eigenvalues of the discrete points to the grid points;
[0095] Next, the target grayscale image is generated on the server using regular grid and discrete point data:
[0096] S407, generating a two-dimensional matrix according to the discrete point data corresponding to the regular grid;
[0097] S408, creating an empty grayscale image object with the same size as the grid data, for storing the target grayscale image;
[0098] S409, according to the format of the grid data, it is necessary to use a double loop to traverse the grid data, and assign the value in each grid cell to the corresponding pixel value (here, the pixel value of the first pixel point), and the pixel value of the target grayscale image is a grayscale of 0 (black) to 255 (white);
[0099] S410, assigning values to each pixel of the target grayscale image, specifically, performing numerical scaling and range mapping operations, so as to map the grid data to the grayscale range in the grayscale image, and recording the mapping ratio of the feature value and the pixel value;
[0100] S411, generating a target grayscale image;
[0101] Since the above second pixel point exists in the target grayscale image, that is, it corresponds to the grid point that does not fall into the discrete coordinate point in the regular grid, the grayscale image interpolation can be continued to be performed on the target grayscale image to obtain the pixel value of the corresponding pixel point:
[0102] S412, traversing the grayscale image pixel by pixel;
[0103] S413, find the two discrete coordinate points xLower and xUpper closest to x in xValues;
[0104] S414, find the two discrete coordinate points yLower and yUpper closest to y in yValues; obtain the coordinates and eigenvalues of the four discrete points;
[0105] S416, perform bilinear (X direction, Y direction) interpolation according to the coordinates, eigenvalues and weights of the four discrete points:
[0106] double weightX = (xUpper - x) / (xUpper - xLower);
[0107] double weightY = (yUpper - y) / (yUpper - yLower);
[0108] double interpolatedValue=(1-weightX) ((1-weightY) xLowerValue+weightY yLowerValue)+weightX ((1-weightY) xUpperValue+weightY yUpperValue), where xLowerValue is the eigenvalue of xLower, yLowerValue is the eigenvalue of yLower, yLowerValue is the eigenvalue of yLower, yUpperValue is the eigenvalue of yUpper, weightX and weightY are weights, which can be set flexibly.
[0109] S417, assigning a value to a second pixel point in the target grayscale image according to the interpolation result of each pixel, to generate a new target grayscale image;
[0110] Next, transfer the target grayscale image and load the texture of the 3D heat map:
[0111] S418, the front-end and back-end establish ws communication (WebSocket network socket communication), and the front-end obtains the pushed (grayscale image) base64 string through websocket (network socket, full-duplex communication protocol, data can be sent from the client to the server at any time, and from the server to the client without the client initiating a request first);
[0112] S419, the network socket gets the pushed base64 (a coding method) string, and the front end uses the base64 data to create the image URL;
[0113] S420, creating a WebGL texture and loading image data: using the texImage2D function of WebGL to create a texture object, and loading the image data into the texture;
[0114] Furthermore, use texImage2D to load the grayscale image data into the texture for 3D rendering:
[0115] S421, set up the WebGL environment: set up the WebGL context, vertex buffer, shader program and texture, etc. For example, the height map boundary longitude and latitude conversion web Mercator, in the case where XY represents the near longitude and latitude, the longitude and latitude can be converted to Mercator coordinates: Use the following formula to convert longitude and latitude (latitude and longitude) to Mercator coordinates (x and y): x=R longitude π / 180; y=R ln(tan((90+latitude) π / 360)), R is the radius of the earth, usually 6378137 meters;
[0116] S422, creating a vertex buffer object;
[0117] S423, prepare grayscale image texture and load grayscale image data:
[0118] S424, create a vertex buffer object (VBO) mesh model. The vertex buffer object mesh model consists of a series of vertices. These vertices are initially flat and will be deformed according to the grayscale image. Create a VBO to store these vertex data; create a texture coordinate buffer object. In addition to the vertex position, you also need to provide texture coordinates for each vertex so that the vertex shader can sample the correct height value from the grayscale image (the grayscale value of each pixel determines the height of each corresponding vertex). Create a texture coordinate VBO and fill it with the UV coordinates corresponding to the vertex;
[0119] It should be noted that in 3D graphics, UV coordinates are a coordinate system used for texture mapping, which maps 2D textures to the surface of 3D models. UV coordinates are usually between 0 and 1, where U represents the horizontal direction and V represents the vertical direction. Each vertex has a corresponding UV coordinate, and these coordinates define how the texture is mapped on the 3D model.
[0120] S425, upload textures and set uniform variables (a special variable in graphics shaders (such as vertex shaders and fragment shaders) used to share data between different executions of shader programs). In WebGL programs, you need to upload grayscale textures to a texture unit and set uniform variables u_Texture_unit (specify the texture unit) and u_Maximum_height (specify a maximum height value). (Use u_Texture_unit to get texture data, or use u_Maximum_height to adjust the height of the terrain) for the shader to find the texture and its value. Use the vertexAttribPointer function (vertex pointer attribute function, a function used to bind vertex data (such as vertex position, texture coordinates, etc.) to attribute variables in GPU shaders.) to bind the vertex position and texture coordinate data to the corresponding attribute variables a_Vertex (vertex position attribute, storing vertex position data) and a_Texture_coordinate (texture coordinate attribute, storing texture coordinate data for texture mapping);
[0121] S426, bind vertices and texture coordinates;
[0122] S427, write the vertex shader: Vertex Shader: The vertex shader samples the height of each vertex from the grayscale image and uses these height values to modify the y coordinate of the vertex to create height changes in the terrain;
[0123] S428, using the corresponding texture coordinates to obtain the color of the height map at the vertex position;
[0124] S429, calculate the height of this vertex using the color value (between 0.0 and 0.1) as a percentage of the scaled large height;
[0125] S430, using the height as the Y component corresponding to the Y axis of the vertex;
[0126] S431, the height of the vertex is passed to the fragment shader for vertex color height mapping. Fragment Shader: The fragment shader is usually used to determine the final color of each pixel. The grayscale value in the vertex shader is passed to determine the color of each vertex according to the defined height and color mapping method.
[0127] S432, heat map drawing: call the drawElements function to render the terrain mesh. WebGL will generate the final three-dimensional heat map surface according to the instructions of the vertex shader and the fragment shader, combined with the grayscale image texture. The generated three-dimensional heat map is an image surface. Each pixel on the surface has a grayscale value, which can be mapped to the height through the grayscale value.
[0128] S433, end.
[0129] For example, Figure 5 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application. The three-dimensional heat map generated by the embodiment of the present application can be as follows Figure 5 shown.
[0130] Through the embodiments of the present application, in response to a heat map generation request message, discrete point data associated with the heat map to be generated is obtained, and a regular grid is generated based on the discrete point data, wherein the discrete point data includes discrete coordinate points and characteristic values of the discrete coordinate points, and any discrete coordinate point belongs to a grid point in the regular grid; a target grayscale image is generated based on the regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by the characteristic value of the discrete coordinate point associated with the corresponding grid point, and the pixel value of the second pixel point is determined by the characteristic value of the interpolation coordinate point associated with the corresponding grid point. The eigenvalue is determined by interpolation, and the interpolation coordinate point represents a discrete coordinate point of a grid point corresponding to a second pixel point that satisfies a preset range condition; three-dimensional rendering is performed based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel point in the target grayscale image, by accurately mapping discrete point data to a regular grid and using an interpolation method to determine the pixel value, thereby ensuring the quality and accuracy of the three-dimensional heat map, achieving the purpose of improving the quality and accuracy of the three-dimensional heat map, thereby achieving the technical effect of improving the generation accuracy of the three-dimensional heat map, and then solving the technical problem of low generation accuracy of the three-dimensional heat map.
[0131] As an optional solution, the above-mentioned response to the heat map generation request message, obtaining discrete point data associated with the heat map to be generated, and generating a regular grid based on the above-mentioned discrete point data, includes: responding to the heat map generation request message, obtaining heat map range information, wherein the above-mentioned heat map range information is used to specify the heat map range of the above-mentioned target three-dimensional heat map; determining the above-mentioned discrete point data according to the above-mentioned heat map range information, wherein the above-mentioned discrete point data represents the above-mentioned discrete coordinate points located in the above-mentioned heat map range in a predetermined discrete point data set and the characteristic values associated with the above-mentioned discrete coordinate points; generating a regular grid based on the above-mentioned discrete point data.
[0132] Optionally, in an embodiment of the present application, the above-mentioned heat map range refers to the area used to determine the target three-dimensional heat map, including the geographic or spatial coordinates covered by the three-dimensional heat map, such as longitude, latitude, altitude, etc., as well as possible time or other related parameters. The above-mentioned heat map range information is used to filter out discrete coordinate points and their associated characteristic values within the range from a predetermined discrete point data set.
[0133] In an exemplary embodiment, assume that a heat map of temperature data of a city is generated to display the temperature distribution of different areas of the city; a specific area of the city (the above-mentioned heat map range) needs to be focused on, and the boundaries of this area are defined, such as 120 degrees east longitude to 121 degrees east longitude and 30 degrees north latitude to 31 degrees north latitude; data is collected from the city's temperature monitoring stations, which are distributed in various corners of the city, and only the data of those monitoring stations within the heat map range we defined are selected; a regular grid is created within this range, such as one grid unit for every 0.1 degrees of longitude and latitude.
[0134] It should be noted that the specific range of the heat map depends on the actual business application scenario. The heat map range can be specified by the user or automatically determined by the algorithm.
[0135] Through the embodiments of the present application, the actual needs of various business scenarios are met, and the technical effect of effectively visualizing the data in a specific area is achieved.
[0136] As an optional scheme, the above-mentioned generating a regular grid based on the above-mentioned discrete point data includes: determining the horizontal coordinate extreme value and the vertical coordinate extreme value based on the above-mentioned discrete point data, wherein the above-mentioned horizontal coordinate extreme value includes the horizontal coordinate maximum value and the horizontal coordinate minimum value of each discrete coordinate point in the above-mentioned discrete point data, and the above-mentioned vertical coordinate extreme value includes the vertical coordinate maximum value and the vertical coordinate minimum value of each discrete coordinate point in the above-mentioned discrete point data; determining the number of grid points of the above-mentioned regular grid according to a predetermined grid granularity, the above-mentioned horizontal coordinate extreme value and the above-mentioned vertical coordinate extreme value, and generating the above-mentioned regular grid according to the above-mentioned number of grid points.
[0137] Optionally, the above grid granularity can be understood as the side length of each grid unit in a regular grid.
[0138] For example, Figure 6 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application, such as Figure 6 As shown:
[0139] S602, start;
[0140] S604, obtaining discrete point data to be drawn;
[0141] S606, traverse the discrete points to obtain the minimum and maximum values in the X-axis direction; and the minimum and maximum values in the Y-axis direction;
[0142] S608, defining the grid unit size dx, dy (grid granularity);
[0143] S610, calculating the number of grids according to the X-axis and Y-axis directions and the grid size, recorded as "NumX, NumY";
[0144] S612, traversing the grid points and determining the inclusion relationship with the discrete points, and assigning the eigenvalues of the discrete points to the grid points;
[0145] S614, end.
[0146] In an exemplary embodiment, first, it is necessary to find the maximum and minimum values of the horizontal coordinate (x) and the maximum and minimum values of the vertical coordinate (y) of all discrete points;
[0147] Assume that the discrete point data are as follows: Point A: (x1, y1) = (2, 3); Point B: (x2, y2) = (5, 7); Point C: (x3, y3) = (3, 8); Point D: (x4, y4) = (6, 2). Therefore, the maximum value of the extreme value of the horizontal coordinate is max(x1,x2, x3, x4) = 6; the minimum value is min(x1, x2, x3, x4) = 2; the maximum value of the extreme value of the vertical coordinate is max(y1,y2, y3, y4) = 8; the minimum value is min(y1, y2, y3, y4) = 2;
[0148] Furthermore, assuming that the grid granularity is 1, based on the grid granularity and coordinate extreme values, we can calculate how many grid points are needed to cover the entire heat map range. Specifically:
[0149] The number of grid points in the horizontal axis direction = (maximum horizontal axis value - minimum horizontal axis value) / grid granularity + 1 = (6 - 2) / 1 + 1 = 5; the number of grid points in the vertical axis direction = (maximum vertical axis value - minimum vertical axis value) / grid granularity + 1 = (8 - 2) / 1 + 1 = 7.
[0150] Finally, a 5x7 regular grid is generated, and the side length of each grid cell is 1.
[0151] Through the embodiments of the present application, a regular grid can be flexibly created, and the regular grid can cover all given discrete point data, so as to better understand and display the spatial distribution of the discrete point data.
[0152] As an optional scheme, the above-mentioned generating a target grayscale image based on the above-mentioned regular grid includes: determining the first grid point and the second grid point based on the coordinate value of each of the above-mentioned discrete coordinate points in the above-mentioned discrete point data and the grid point position of each grid point in the above-mentioned regular grid, wherein any of the above-mentioned discrete coordinate points belongs to one of the above-mentioned first grid points, and any of the above-mentioned discrete coordinate points does not belong to any of the above-mentioned second grid points; assigning a value to the above-mentioned first grid point based on the characteristic value of each of the above-mentioned discrete coordinate points, and determining the first grid point characteristic data corresponding to the above-mentioned first grid point; determining the above-mentioned interpolation coordinate point based on the grid point position of the above-mentioned second grid point, and performing bilinear interpolation on the above-mentioned second grid point based on the characteristic value of the above-mentioned interpolation coordinate point, and determining the second grid point characteristic data corresponding to the above-mentioned second grid point; determining the pixel values of the above-mentioned first pixel point and the above-mentioned second pixel point according to the above-mentioned first grid point characteristic data and the above-mentioned second grid point characteristic data, and generating the above-mentioned target grayscale image.
[0153] Optionally, in an embodiment of the present application, the first grid point feature data corresponds to the value of a first pixel in the target grayscale image corresponding to the first grid point; the second grid point feature data corresponds to the value of a second pixel in the target grayscale image corresponding to the second grid point.
[0154] For example, Figure 7 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application, such as Figure 7 As shown:
[0155] S702, start;
[0156] S704, generating a two-dimensional matrix according to the regular grid data (the above-mentioned discrete point data);
[0157] S706, creating an image for storing the target grayscale image;
[0158] S708, traversing the grid data, and mapping the eigenvalues corresponding to the grid to the pixel range of the grayscale image;
[0159] S710, assigning values to each pixel of the grayscale image;
[0160] S712, end.
[0161] As an optional scheme, the above-mentioned interpolation coordinate point is determined based on the grid point position of the above-mentioned second grid point, and bilinear interpolation is performed for the above-mentioned second grid point based on the characteristic value of the above-mentioned interpolation coordinate point to determine the second grid point characteristic data corresponding to the above-mentioned second grid point, including: determining the first horizontal coordinate interpolation coordinate point, the second horizontal coordinate interpolation coordinate point, the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point based on the grid point position of the above-mentioned second grid point, wherein the above-mentioned first horizontal coordinate interpolation coordinate point and the above-mentioned second horizontal coordinate interpolation coordinate point represent the two coordinate points closest to the above-mentioned second grid point in different directions along the horizontal coordinate axis, and the above-mentioned first vertical coordinate interpolation coordinate point and the above-mentioned second vertical coordinate interpolation coordinate point represent the two coordinate points closest to the above-mentioned second grid point in different directions along the vertical coordinate axis; bilinear interpolation is performed based on the characteristic values corresponding to the above-mentioned first horizontal coordinate interpolation coordinate point, the above-mentioned second horizontal coordinate interpolation coordinate point, the above-mentioned first vertical coordinate interpolation coordinate point and the above-mentioned second vertical coordinate interpolation coordinate point, respectively, to determine the second grid point characteristic data corresponding to the above-mentioned second grid point.
[0162] Optionally, in an embodiment of the present application, the above-mentioned first horizontal coordinate interpolation coordinate point is the left point on the horizontal coordinate axis, closest to the second grid point; the second horizontal coordinate interpolation coordinate point is the right point on the horizontal coordinate axis, closest to the second grid point; the first vertical coordinate interpolation coordinate point is the upper point on the vertical coordinate axis, closest to the second grid point; the second vertical coordinate interpolation coordinate point is the lower point on the vertical coordinate axis, closest to the second grid point.
[0163] Exemplarily, the first horizontal interpolation coordinate point is recorded as X1; the second horizontal interpolation coordinate point is recorded as X2; the first vertical interpolation coordinate point is recorded as Y1; the second vertical interpolation coordinate point is recorded as Y2, and the eigenvalues corresponding to the above four interpolation coordinate points are obtained, which are recorded as f(X1, Y1), f(X2, Y1), f(X1, Y2), and f(X2, Y2), respectively.
[0164] Furthermore, bilinear interpolation is performed on the horizontal coordinate and the vertical coordinate to obtain the characteristic value of the final second grid point characteristic data.
[0165] For example, Figure 8 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application, such as Figure 8 As shown:
[0166] S802, start;
[0167] S804, traversing the target grayscale image pixel by pixel;
[0168] S806-1, find two discrete points closest to the X value among the discrete point values corresponding to the X axis;
[0169] S806-2, find two discrete points closest to the Y value among the discrete point values corresponding to the Y axis;
[0170] S808, performing bilinear interpolation according to the values and weights of the four discrete points;
[0171] S810, generating a new target grayscale image according to the interpolation results of each pixel;
[0172] S812, end.
[0173] Through the embodiments of the present application, high-precision image interpolation is achieved, and the technical result of improving the accuracy of the target grayscale image is achieved, ensuring the display effect of subsequent three-dimensional rendering according to the target grayscale image.
[0174] As an optional scheme, the above-mentioned three-dimensional rendering is performed based on the above-mentioned target grayscale image to obtain the target three-dimensional heat map, including: generating a grayscale texture according to the above-mentioned target grayscale image, determining a vertex buffer object according to the above-mentioned grayscale texture, wherein a vertex in the above-mentioned vertex buffer object corresponds to a pixel point in the above-mentioned target grayscale image; and performing three-dimensional rendering based on the above-mentioned vertex buffer object through a preset shader to obtain the above-mentioned target three-dimensional heat map.
[0175] As an optional solution, the above-mentioned three-dimensional rendering is performed based on the above-mentioned vertex buffer object through a preset shader to obtain the above-mentioned target three-dimensional heat map, including: sampling the height of each vertex from the above-mentioned grayscale texture through a vertex shader to determine the height information of each vertex in the above-mentioned target three-dimensional heat map, wherein the height information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; sampling the color of each vertex from the above-mentioned grayscale texture through a fragment shader to determine the color information of each vertex in the above-mentioned target three-dimensional heat map, wherein the color information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; performing three-dimensional rendering based on the above-mentioned height information and the above-mentioned color information to obtain the above-mentioned target three-dimensional heat map.
[0176] It should be noted that in 3D rendering, the above-mentioned grayscale texture is a special texture that contains grayscale information, that is, each pixel in the image has only one grayscale value, which represents the brightness; in the rendering process, the grayscale texture can be used to simulate lighting effects, material properties, etc. The above-mentioned vertex buffer object (also known as VBO, Vertex Buffer Object) is a method for storing vertex data, which includes vertex position, color, texture coordinates, etc. In graphics APIs (interfaces) such as OpenGL, VBO allows vertex data to be uploaded to the GPU (graphics display unit) memory for efficient access during the rendering process.
[0177] For example, Fig. 9 is a schematic diagram of another optional method for generating a three-dimensional heat map according to an embodiment of the present application, such as Fig. 9 As shown:
[0178] S902, start;
[0179] S904, the front end obtains the base64 (a coding method) string of the target grayscale image pushed by the server through the network socket;
[0180] S906, the front-end web page receives the base64 string and converts it into a height map texture (the grayscale texture mentioned above);
[0181] S908, converting longitude and latitude, for example, converting longitude and latitude into Mercator coordinates;
[0182] S910, creating a vertex buffer object;
[0183] S912, creating a texture coordinate buffer object;
[0184] S914, create and initialize texture;
[0185] S916, set uniform (a variable type) variable;
[0186] S918, bind vertices and texture coordinates;
[0187] S920, write vertex shaders;
[0188] S922, using the corresponding texture coordinates to obtain the color of the height map at the vertex position;
[0189] S924, calculate the height of this vertex using the color value (between 0.0 and 0.1) as a percentage of the scaled large height;
[0190] S926, using the height as the Y component corresponding to the Y axis of the vertex;
[0191] S928, the height of the vertex is passed to the fragment shader for vertex color height mapping;
[0192] S930, drawing the height of each vertex in the three-dimensional heat map;
[0193] S932, end.
[0194] In an exemplary embodiment, vertex data (including position and texture coordinates) are sent to a vertex shader, which processes each vertex, extracts height information from a grayscale texture based on the texture coordinates, and adjusts the vertex position. Next, the adjusted vertex data is sent to a fragment shader, which processes each fragment, extracts color information from a grayscale texture based on the texture coordinates, and outputs a final color value. Finally, these color values are used to render a three-dimensional model to form the three-dimensional heat map mentioned above.
[0195] Through the embodiments of the present application, the vertex shader processes the vertex position and texture coordinates, while the fragment shader extracts height and color information from the two textures and performs color mapping, thereby achieving the purpose of efficiently rendering a three-dimensional heat map and achieving the technical effect of balancing rendering efficiency and visual effects.
[0196] As an optional solution, the method further includes: in response to the heat map generation request message sent by the front-end device, obtaining discrete point data associated with the heat map to be generated, and generating the regular grid based on the discrete point data; generating the target grayscale image based on the regular grid, and converting the target grayscale image into a target character string and sending it to the front-end device, so that the front-end device performs three-dimensional rendering based on the target character string through graphics processing to obtain the target three-dimensional heat map.
[0197] Optionally, in an embodiment of the present application, the above-mentioned front-end device may include but is not limited to various intelligent terminal devices, etc.
[0198] In an exemplary embodiment, the method for generating a three-dimensional heat map proposed in this application can be applied to the field of three-dimensional geographic scene rendering. Specifically,
[0199] It should be noted that heat maps are widely used in many fields, such as geographic information systems (GIS), data analysis, market research, etc. They can provide an intuitive and easy-to-understand way to reflect the distribution pattern and correlation of data, helping users make more accurate decisions and analysis. A three-dimensional heat map is a chart that visualizes the density or intensity distribution of data in three-dimensional space. Combining heat maps with three-dimensional models, it can more intuitively display the distribution of data in space. In related technologies, three-dimensional heat maps are usually drawn by grid rendering and plane rendering. For this, discrete points in grid line rendering require data preprocessing, and heat maps cannot be dynamically generated. In addition, when rendering with real line entities, when the terrain, entity model and heat map are superimposed in the three-dimensional scene, there will be a grid hollowing problem and the display effect is not good. In the process of using plane rendering, it is necessary to create a geometric body to render the heat map. The heat map is still two-dimensional in visual effect, and no mask is generated. The rendering area is rectangular with a strong sense of boundary.
[0200] Furthermore, through the embodiments of the present application, a grayscale image after spatial interpolation can be dynamically generated on the server side, and the vertex height and vertex color processing of the heat map can be performed in the shader based on the GPU (graphics processing unit) to draw a three-dimensional heat map, avoiding the problems of mesh hollowing out and strong sense of aggregate boundaries.
[0201] In an exemplary embodiment, the above-mentioned GPU-based three-dimensional heat map drawing method and process may include the following steps:
[0202] S1, the front-end page requests the server according to the business, the server obtains the discrete points, and generates regular grids and grayscale images for the discrete points:
[0203] S1-1, server-side regular grid generation: the front end sends the expected heat map latitude and longitude range and grid granularity (the coverage range of each grid dx, dy) to the server, and the server queries the matching discrete points according to the latitude and longitude range. The points must contain longitude and latitude and characteristic values; define a two-dimensional discrete point class, which contains longitude and latitude and characteristic value fields, create an array based on this class, traverse the discrete points to obtain the extreme values Xmin, Ymin, Xmax, and Ymax in both directions of longitude and latitude; calculate the number of grids NumX (intNumX= std::ceil((Xmax - Xmin) / dx)) and NumY (intNumY = std::ceil((Ymax - Ymin) / dy)) in both directions according to the size of the XY direction and the grid size, traverse the grid points and determine the inclusion relationship with the discrete points to assign the characteristic values of the discrete points to the grid points;
[0204] S1-2, Grayscale image generation: Create an empty grayscale image object with the same size as the grid data; assign the numerical value or intensity in the grid data to the pixel value of the grayscale image; according to the format of the grid data, a double loop is needed to traverse the grid data and assign the numerical value in each grid cell to the corresponding pixel value. The pixel value of the grayscale image is a grayscale of 0 (black) to 255 (white); perform numerical scaling and range mapping operations to map the grid data to the grayscale range in the grayscale image, and record the mapping ratio of the feature value and pixel value.
[0205] S1.3, grayscale image interpolation, first, you need to load the grayscale image, get the matrix containing the grid data, and traverse the grayscale image pixel by pixel; find the two discrete points xLower and xUpper closest to x in xValues; find the two discrete points yLower and yUpper closest to y in yValues; get the coordinates and eigenvalues of the four discrete points; perform bilinear interpolation based on the values and weights of the four discrete points: double weightX = (xUpper - x) / (xUpper -xLower); double weightY = (yUpper - y) / (yUpper - yLower); doubleinterpolatedValue = (1 - weightX) ((1 - weightY) xLowerValue + weightY yLowerValue) +weightX ((1 - weightY) xUpperValue + weightY yUpperValue); and generate a new grayscale image based on the interpolation results of each pixel;
[0206] S2, grayscale image transfer, texture loading:
[0207] S2-1, the front-end and back-end establish ws communication, and the front-end obtains the pushed base64 string through websocket;
[0208] S2-2, after the front end obtains the Uint8Array type data, it converts it into a base64 string and uses the base64 data to create an image URL;
[0209] S2-3, create a WebGL texture and load image data: use the WebGL texImage2D function to create a texture object and load the image data into the texture;
[0210] S3, grayscale image rendering:
[0211] S3-1, Set up the WebGL environment: Set up the WebGL context, vertex buffer, shader program, texture, etc.;
[0212] S3-2, prepare grayscale image texture, load grayscale image data: use texImage2D to load grayscale image data into texture;
[0213] S3-3, create a vertex buffer object (VBO) mesh model, which consists of a series of vertices. These vertices can be flat initially, and they will be deformed according to the grayscale image. Create a VBO to store these vertex data;
[0214] S3-4, create a texture coordinate buffer object. In addition to the vertex position, you also need to provide texture coordinates for each vertex so that the vertex shader can sample the correct height value from the grayscale image. Create a texture coordinate VBO and fill it with the UV coordinates corresponding to the vertex.
[0215] S3-5, upload texture and set uniform variables. In WebGL program, you need to upload grayscale texture to a texture unit and set uniform variables u_Texture_unit and u_Maximum_height for the shader to find the texture and its value. Use the vertexAttribPointer function to bind the vertex position and texture coordinate data to the corresponding attribute variables a_Vertex and a_Texture_coordinate.
[0216] S3-6, write shaders: Vertex Shader: The vertex shader samples the height of each vertex from the grayscale image and uses these height values to modify the y coordinate of the vertex to create height changes in the terrain; Fragment Shader: The fragment shader is usually used to determine the final color of each pixel. The grayscale value in the vertex shader is passed to determine the color of each vertex according to the defined height and color mapping method.
[0217] S3-7, heat map drawing: Call the drawElements function to render the terrain mesh. WebGL will generate the final three-dimensional heat map surface based on the instructions of the vertex shader and fragment shader, combined with the grayscale image texture.
[0218] It should be noted that the above-mentioned three-dimensional heat map can be dynamically generated by the server into a two-dimensional grayscale image, and bilinear interpolation processing is performed. This generation method is different from the processing on the Web side. A large amount of dynamic data can be acquired and processed on the server side, reducing the computing pressure on the web side, and the grayscale image is used in the form of a base64 string through websocket for communication between the server and the front end. The three-dimensional heat map is transmitted to the GPU through the grayscale image, and then mapped to the eigenvalue in the vertex shader through texture sampling and colored according to the eigenvalue range. The color, height and range of the three-dimensional heat map are controllable.
[0219] Through the embodiments of the present application, a GPU-based three-dimensional heat map drawing method is implemented, which can be applied to heat map rendering in three-dimensional geographic scenes to achieve the fusion of heat maps and scene models. Grid generation and grayscale image conversion are performed on the server side to solve the computing pressure on the browser caused by large-scale data transmission and rendering. The fluency of the heat map is enhanced, and the heat map effect is added to the three-dimensional scene through grayscale color mapping, thereby achieving visual unification. The scene fusion effect can be observed from multiple angles and in all directions, and the fusion effect is better.
[0220] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0221] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0222] According to another aspect of the embodiment of the present application, a three-dimensional heat map generation device for implementing the above-mentioned three-dimensional heat map generation method is also provided. Fig.10 As shown, the device comprises:
[0223] The acquisition module 1002 is used to respond to the heat map generation request message, obtain discrete point data associated with the heat map to be generated, and generate a regular grid based on the discrete point data, wherein the discrete point data includes discrete coordinate points and feature values of the discrete coordinate points, and any discrete coordinate point belongs to a grid point in the regular grid;
[0224] A generating module 1004 is used to generate a target grayscale image based on a regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by a feature value of a discrete coordinate point associated with the corresponding grid point, the pixel value of the second pixel point is determined by interpolation of a feature value of an interpolation coordinate point associated with the corresponding grid point, and the interpolation coordinate point represents a discrete coordinate point of the grid point corresponding to the second pixel point that satisfies a preset range condition;
[0225] The rendering module 1006 is used to perform three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel point in the target grayscale image.
[0226] As an optional solution, the above-mentioned device is used to respond to a heat map generation request message in the following manner, obtain discrete point data associated with the heat map to be generated, and generate a regular grid based on the discrete point data: in response to the heat map generation request message, obtain heat map range information, wherein the heat map range information is used to specify the heat map range of the target three-dimensional heat map; determine discrete point data according to the heat map range information, wherein the discrete point data represents discrete coordinate points located in the heat map range in a predetermined discrete point data set and characteristic values associated with the discrete coordinate points; generate a regular grid based on the discrete point data.
[0227] As an optional solution, the above-mentioned device is used to generate a regular grid based on discrete point data in the following manner: determine the horizontal coordinate extreme values and the vertical coordinate extreme values based on the discrete point data, wherein the horizontal coordinate extreme values include the horizontal coordinate maximum value and the horizontal coordinate minimum value of each discrete coordinate point in the discrete point data, and the vertical coordinate extreme values include the vertical coordinate maximum value and the vertical coordinate minimum value of each discrete coordinate point in the discrete point data; determine the number of grid points of the regular grid according to the predetermined grid granularity, the horizontal coordinate extreme value and the vertical coordinate extreme value, and generate the regular grid according to the number of grid points.
[0228] As an optional solution, the above-mentioned device is used to generate a target grayscale image based on a regular grid in the following manner: determine the first grid point and the second grid point based on the coordinate value of each discrete coordinate point in the discrete point data and the grid point position of each grid point in the regular grid, wherein any discrete coordinate point belongs to a first grid point, and any discrete coordinate point does not belong to any second grid point; assign a value to the first grid point based on the characteristic value of each discrete coordinate point, and determine the first grid point feature data corresponding to the first grid point; determine the interpolation coordinate point based on the grid point position of the second grid point, and perform bilinear interpolation on the second grid point based on the characteristic value of the interpolation coordinate point, and determine the second grid point feature data corresponding to the second grid point; determine the pixel values of the first pixel point and the second pixel point according to the first grid point feature data and the second grid point feature data to generate a target grayscale image.
[0229] As an optional scheme, the above-mentioned device is used to determine the interpolation coordinate point based on the grid point position of the second grid point in the following manner, and perform bilinear interpolation for the second grid point based on the characteristic value of the interpolation coordinate point to determine the second grid point characteristic data corresponding to the second grid point: determine the first horizontal coordinate interpolation coordinate point, the second horizontal coordinate interpolation coordinate point, the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point based on the grid point position of the second grid point, wherein the first horizontal coordinate interpolation coordinate point and the second horizontal coordinate interpolation coordinate point represent the two coordinate points closest to the second grid point in different directions along the horizontal coordinate axis, and the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point represent the two coordinate points closest to the second grid point in different directions along the vertical coordinate axis; perform bilinear interpolation based on the characteristic values corresponding to the first horizontal coordinate interpolation coordinate point, the second horizontal coordinate interpolation coordinate point, the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point, respectively, to determine the second grid point characteristic data corresponding to the second grid point.
[0230] As an optional solution, the above-mentioned device is used to perform three-dimensional rendering based on the target grayscale image in the following manner to obtain a target three-dimensional heat map: generate a grayscale texture according to the target grayscale image, determine a vertex buffer object according to the grayscale texture, wherein a vertex in the vertex buffer object corresponds to a pixel point in the target grayscale image; perform three-dimensional rendering based on the vertex buffer object through a preset shader to obtain a target three-dimensional heat map.
[0231] As an optional solution, the above-mentioned device is used to perform three-dimensional rendering based on the vertex buffer object through a preset shader in the following manner to obtain a target three-dimensional heat map: the height of each vertex is sampled from the grayscale texture through the vertex shader to determine the height information of each vertex in the target three-dimensional heat map, wherein the height information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; the color of each vertex is sampled from the grayscale texture through the fragment shader to determine the color information of each vertex in the target three-dimensional heat map, wherein the color information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; three-dimensional rendering is performed based on the height information and color information to obtain the target three-dimensional heat map.
[0232] As an optional solution, the above-mentioned device is also used to: respond to a heat map generation request message sent by the front-end device, obtain discrete point data associated with the heat map to be generated, and generate a regular grid based on the discrete point data; generate a target grayscale image based on the regular grid, and convert the target grayscale image into a target character string and send it to the front-end device, so that the front-end device performs three-dimensional rendering based on the target character string through graphics processing to obtain a target three-dimensional heat map.
[0233] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0234] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0235] According to one aspect of the present application, a computer program product is provided. The computer program product includes a computer program.
[0236] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0237] Fig.11 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.
[0238] It should be noted that Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0239] like Fig.11 As shown, the computer system 1100 includes a central processing unit 1101 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 1102 (ROM) or the program loaded from the storage part 1108 to the random access memory 1103 (RAM). Various programs and data required for system operation are also stored in the random access memory 1103. The central processing unit 1101, the read-only memory 1102 and the random access memory 1103 are connected to each other through a bus 1104. The input / output interface 1105 (Input / Output interface, i.e., I / O interface) is also connected to the bus 1104.
[0240] The following components are connected to the input / output interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the input / output interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom is installed into the storage section 1108 as needed.
[0241] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the central processor 1101, various functions defined in the system of the present application are executed.
[0242] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the central processor 1101, various functions provided by the embodiments of the present application are performed.
[0243] According to another aspect of the embodiment of the present application, an electronic device for implementing the above-mentioned method for generating a three-dimensional thermal map is also provided. The electronic device may be Figure 1 The terminal device or server shown in the figure. This embodiment is described by taking the electronic device as a terminal device as an example. Fig.12 As shown, the electronic device includes a memory 1202 and a processor 1204. The memory 1202 stores a computer program, and the processor 1204 is configured to execute the steps in any of the above method embodiments through the computer program.
[0244] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0245] Optionally, in this embodiment, the above-mentioned processor can be configured to execute the methods in each embodiment of the present application through a computer program.
[0246] Alternatively, a person skilled in the art may understand that: Fig.12 The structure shown is for illustration only. Fig.12 The structure of the electronic device is not limited. Fig.12 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.12 Different configurations are shown.
[0247] Among them, the memory 1202 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for generating a three-dimensional heat map in the embodiment of the present application. The processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, that is, realizing the above-mentioned method for generating a three-dimensional heat map. The memory 1202 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1202 may further include a memory remotely located relative to the processor 1204, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1202 can be specifically, but not limited to, used to store information such as discrete point data. As an example, such as Fig.12 As shown, the memory 1202 may include, but is not limited to, the acquisition module 1002, the generation module 1004, and the rendering module 1006 in the three-dimensional heat map generation device. In addition, it may also include, but is not limited to, other module units in the three-dimensional heat map generation device, which will not be repeated in this example.
[0248] Optionally, the transmission device 1206 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 1206 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 1206 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0249] In addition, the electronic device further includes: a display 1208 for displaying the three-dimensional thermal map; and a connection bus 1210 for connecting various module components in the electronic device.
[0250] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. The nodes may form a peer-to-peer network, and any form of computing device, such as a server, terminal or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0251] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method for generating a three-dimensional heat map provided in various optional implementations of the above-mentioned three-dimensional heat map generation method.
[0252] Optionally, in this embodiment, the above-mentioned computer-readable storage medium can be configured to store data for executing the methods in various embodiments of the present application.
[0253] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0254] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0255] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for one or more electronic devices to execute all or part of the steps of the methods described in each embodiment of the present application.
[0256] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0257] In the several embodiments provided in the present application, it should be understood that the disclosed application can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0258] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0259] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0260] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for generating a three-dimensional heat map, characterized in that: include: In response to a heat map generation request message, obtaining discrete point data associated with the heat map to be generated, and generating a regular grid based on the discrete point data, wherein the discrete point data includes discrete coordinate points and feature values of the discrete coordinate points, and any of the discrete coordinate points belongs to a grid point in the regular grid; Generate a target grayscale image based on the regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by a feature value of the discrete coordinate point associated with the corresponding grid point, the pixel value of the second pixel point is determined by interpolation of a feature value of an interpolation coordinate point associated with the corresponding grid point, and the interpolation coordinate point represents the discrete coordinate point of the grid point corresponding to the second pixel point that satisfies a preset range condition; Performing three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel point in the target grayscale image; The generating of the target grayscale image based on the regular grid includes: determining the first grid point and the second grid point based on the coordinate value of each discrete coordinate point in the discrete point data and the grid point position of each grid point in the regular grid, wherein any discrete coordinate point belongs to one of the first grid points, and any discrete coordinate point does not belong to any of the second grid points; assigning a value to the first grid point based on the characteristic value of each discrete coordinate point, and determining the first grid point characteristic data corresponding to the first grid point; determining the interpolation coordinate point based on the grid point position of the second grid point, and performing bilinear interpolation on the second grid point based on the characteristic value of the interpolation coordinate point, and determining the second grid point characteristic data corresponding to the second grid point; determining the pixel values of the first pixel point and the second pixel point according to the first grid point characteristic data and the second grid point characteristic data, and generating the target grayscale image; The method also includes: in response to the heat map generation request message sent by the front-end device, obtaining discrete point data associated with the heat map to be generated, and generating the regular grid based on the discrete point data; generating the target grayscale image based on the regular grid, and converting the target grayscale image into a target character string and sending it to the front-end device, so that the front-end device performs three-dimensional rendering based on the target character string through graphics processing to obtain the target three-dimensional heat map.
2. The method according to claim 1, characterized in that The step of obtaining, in response to a heat map generation request message, discrete point data associated with a heat map to be generated, and generating a regular grid based on the discrete point data comprises: In response to the heat map generation request message, obtaining heat map range information, wherein the heat map range information is used to specify the heat map range of the target three-dimensional heat map; Determine the discrete point data according to the heat map range information, wherein the discrete point data represents the discrete coordinate points located in the heat map range in a predetermined discrete point data set and feature values associated with the discrete coordinate points; A regular grid is generated based on the discrete point data.
3. The method according to claim 2, characterized in that The generating a regular grid based on the discrete point data comprises: Determine an extreme value of abscissa and an extreme value of ordinate based on the discrete point data, wherein the extreme value of abscissa includes the maximum value of abscissa and the minimum value of abscissa of each discrete coordinate point in the discrete point data, and the extreme value of ordinate includes the maximum value of ordinate and the minimum value of ordinate of each discrete coordinate point in the discrete point data; The number of grid points of the regular grid is determined according to a predetermined grid granularity, the extreme value of the horizontal coordinate and the extreme value of the vertical coordinate, and the regular grid is generated according to the number of grid points.
4. The method according to claim 1, characterized in that The step of determining the interpolation coordinate point based on the grid point position of the second grid point, and performing bilinear interpolation for the second grid point based on the feature value of the interpolation coordinate point to determine the second grid point feature data corresponding to the second grid point includes: Determine a first horizontal coordinate interpolation coordinate point, a second horizontal coordinate interpolation coordinate point, a first vertical coordinate interpolation coordinate point, and a second vertical coordinate interpolation coordinate point based on the grid point position of the second grid point, wherein the first horizontal coordinate interpolation coordinate point and the second horizontal coordinate interpolation coordinate point represent the two coordinate points closest to the second grid point in different directions along the horizontal coordinate axis, and the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point represent the two coordinate points closest to the second grid point in different directions along the vertical coordinate axis; Bilinear interpolation is performed based on the characteristic values corresponding to the first horizontal coordinate interpolation coordinate point, the second horizontal coordinate interpolation coordinate point, the first vertical coordinate interpolation coordinate point and the second vertical coordinate interpolation coordinate point to determine the second grid point characteristic data corresponding to the second grid point.
5. The method according to claim 1, characterized in that The three-dimensional rendering is performed based on the target grayscale image to obtain a target three-dimensional thermal map, including: Generate a grayscale texture according to the target grayscale image, and determine a vertex buffer object according to the grayscale texture, wherein a vertex in the vertex buffer object corresponds to a pixel in the target grayscale image; The target three-dimensional heat map is obtained by performing three-dimensional rendering based on the vertex buffer object through a preset shader.
6. The method according to claim 5, characterized in that The method of performing three-dimensional rendering based on the vertex buffer object by using a preset shader to obtain the target three-dimensional heat map includes: Sampling the height of each vertex from the grayscale texture through a vertex shader to determine the height information of each vertex in the target three-dimensional thermal map, wherein the height information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; Sampling the color of each vertex from the grayscale texture through a fragment shader to determine the color information of each vertex in the target three-dimensional heat map, wherein the color information of each vertex has a mapping relationship with the pixel value of the corresponding pixel point; Three-dimensional rendering is performed based on the height information and the color information to obtain the target three-dimensional thermal map.
7. A device for generating a three-dimensional thermal map, characterized in that: include: An acquisition module, configured to, in response to a heat map generation request message, acquire discrete point data associated with the heat map to be generated, and generate a regular grid based on the discrete point data, wherein the discrete point data includes discrete coordinate points and feature values of the discrete coordinate points, and any of the discrete coordinate points belongs to a grid point in the regular grid; A generating module, configured to generate a target grayscale image based on the regular grid, wherein a pixel point in the target grayscale image corresponds to a grid point in the regular grid, the target grayscale image includes a first pixel point and a second pixel point, the pixel value of the first pixel point is determined by a feature value of the discrete coordinate point associated with the corresponding grid point, the pixel value of the second pixel point is determined by interpolation of a feature value of an interpolation coordinate point associated with the corresponding grid point, and the interpolation coordinate point represents the discrete coordinate point of the grid point corresponding to the second pixel point that satisfies a preset range condition; A rendering module, used for performing three-dimensional rendering based on the target grayscale image to obtain a target three-dimensional heat map, wherein the height and color of each vertex in the target three-dimensional heat map are determined by the pixel value of each pixel point in the target grayscale image; The device is used to generate a target grayscale image based on the regular grid in the following manner: determining a first grid point and a second grid point based on the coordinate value of each discrete coordinate point in the discrete point data and the grid point position of each grid point in the regular grid, wherein any of the discrete coordinate points belongs to one of the first grid points, and any of the discrete coordinate points does not belong to any of the second grid points; assigning a value to the first grid point based on the characteristic value of each of the discrete coordinate points, and determining first grid point characteristic data corresponding to the first grid point; determining the interpolation coordinate point based on the grid point position of the second grid point, and performing bilinear interpolation on the second grid point based on the characteristic value of the interpolation coordinate point, and determining second grid point characteristic data corresponding to the second grid point; determining pixel values of the first pixel point and the second pixel point according to the first grid point characteristic data and the second grid point characteristic data, and generating the target grayscale image; The device is also used to: respond to the heat map generation request message sent by the front-end device, obtain discrete point data associated with the heat map to be generated, and generate the regular grid based on the discrete point data; generate the target grayscale image based on the regular grid, and convert the target grayscale image into a target character string and send it to the front-end device, so that the front-end device performs three-dimensional rendering based on the target character string through graphics processing to obtain the target three-dimensional heat map.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein the computer program can be executed by an electronic device to perform the method described in any one of claims 1 to 6.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.
