A visualization method for three-dimensional ocean temperature and salinity flow data

Through automated reading and pre -processing marine data, using adaptive interpolation and user -defined color mapping rules, combined with the value line of the Bessel curve drawing, solve the problem of pre -processing and color mapping accuracy in marine data visualization. Achieve high -quality marine data visualization.

CN118708644BActive Publication Date: 2025-01-28OCEAN UNIV OF CHINA +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411186455.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2025-01-28
Estimated Expiration
2044-08-28

AI Technical Summary

Technical Problem

Existing ocean data visualization methods face data preprocessing challenges when dealing with large-scale, high-dimensional ocean datasets, especially how to extract useful information from raw data containing noise and outliers, and how to ensure it during color mapping. accuracy.

Method used

The method of automated reading and pre -processing marine observation data includes the use of the abnormal values ​​and invalid data of the mask marking data to repair the missing data through the adaptive interpolation method, and to standardize and color mapping through the user -defined color mapping rules. At the same time, use the Bessel curve to draw an equivalent line, dynamically adjust the value line trail, and provide a value text label to enhance readability.

Benefits of technology

Effectively handle the noise and abnormal values ​​in marine data, generate high -quality visual images, improve the scientific accuracy and visual effects of data, enhance user interaction capabilities, support high -quality image rendering and zooming.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708644B_ABST
    Figure CN118708644B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of data visualization technology, and discloses a method for visualizing ocean three-dimensional temperature-salinity flow data, including step 1, automatically reading data files and preprocessing; step 2, color mapping; step 3, drawing contour patterns; step 4, visualizing vector data or three-dimensional data. The present invention can be used to parse data files containing characteristic values ​​such as ocean temperature and salinity and generate visualization images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of data visualization, relates to the field of ocean data visualization, and particularly relates to a visualization method for three-dimensional ocean temperature-salinity flow data. Background Art

[0002] Data visualization plays an important role in scientific research and decision support. This technology converts complex data sets into graphics and images, making abstract numerical information intuitive and easy to understand, thereby effectively assisting researchers in data observation and analysis. In marine scientific research, the visualization of three-dimensional temperature and salinity flow data is a key link, which involves extracting useful information from marine observations and remote sensing data and presenting it to researchers in an easy-to-understand way. Due to the complexity and variability of marine data, traditional two-dimensional charts are difficult to fully display the spatial distribution and dynamic changes of marine data. In recent years, with the development of computer graphics and visualization technology, more advanced visualization technologies have gradually been able to meet the needs of displaying the multidimensional characteristics of marine data, such as color mapping and vector field visualization. However, existing visualization methods still face a series of challenges when dealing with large-scale, high-dimensional marine data sets, especially in the data preprocessing stage. How to extract truly useful information from the original data set containing noise and outliers is a technical difficulty. In addition, although color mapping technology visually enhances the performance of data, how to ensure the accuracy of the color mapping process and select appropriate mapping methods according to data characteristics also need to be studied.

[0003] The multi-dimensional nature of ocean data requires us to use efficient data processing algorithms in the visualization process to achieve rapid data integration. For example, parameters such as temperature, salinity, and density are related in spatial and temporal distribution, and the processing of these data needs to maintain consistency and accuracy. Secondly, due to the high difficulty of ocean data collection, there may be missing or erroneous values ​​in the acquired ocean data. How to accurately process these abnormal data and generate smooth and continuous visualization results is a technical challenge. Although existing 3D visualization tools have met these needs to a certain extent, there is still room for improvement in the scientific accuracy of the data, visual effects, and user interaction. Summary of the invention

[0004] In view of the shortcomings of the prior art, the present invention provides a method for visualizing three-dimensional ocean temperature-salinity flow data, which is used to parse data files containing characteristic values ​​such as ocean temperature and salinity and generate visualization images.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0006] A method for visualizing three-dimensional ocean temperature-salinity flow data, comprising the following steps:

[0007] Step 1: Automatically read and preprocess data files:

[0008] Automatically read ocean observation data and configuration files, and preprocess the data, including using masks to mark data outliers or invalid data, and repairing missing data through adaptive interpolation methods;

[0009] Step 2: Data normalization and color mapping:

[0010] The numerical information preprocessed in step 1 is converted into color information according to the user-defined color mapping rules and output in JPG format to achieve a two-dimensional visualization effect of ocean data;

[0011] Step 3: Draw contour lines:

[0012] First, the data information preprocessed in step 1 is normalized to obtain data texture, and then the data texture is converted into a binary image through threshold processing, and the data texture is smoothed using an image restoration algorithm, and the index array of the contour line is traversed, and the contour line is constructed by calculating the actual position of the key points of the contour line, and then the Bezier curve is drawn to obtain the final contour line pattern;

[0013] Step 4: Visualize vector data or 3D data:

[0014] If the ocean data contains vector environmental data or needs to be displayed in three dimensions, a JSON format file is constructed to simulate ocean current movement or the data is filled into a vtkImageData object and written to a VTI file to achieve vector simulation and three-dimensional visualization of the ocean data.

[0015] Furthermore, in step 1, the ocean data preprocessing is specifically performed by the following steps:

[0016] 1) The information obtained from the configuration file includes water area data water_mask_datas. If the data value is not null and not an outlier, the corresponding water_mask mask position is set to 255, indicating the water surface area; Next, traverse the input raw data. Once an outlier or invalid data is detected, use the mask variable to mark these data points and mark them as data missing areas;

[0017] 2) For missing data, an adaptive method is used to dynamically select interpolation algorithms based on the surrounding valid pixels to fill in the missing values ​​according to the spatial distribution characteristics of ocean data. Specifically, the neighborhood range is defined before processing missing data, the gradient of the data is calculated in the local neighborhood, and the rate of change of the data is measured according to the gradient size. In areas with small gradients, linear interpolation is selected for pixel repair; in areas with large gradients, spline interpolation is selected for pixel repair; all missing pixels are repaired through multiple iterations. If there are still pixels that cannot be filled after processing, the pixel value corresponding to the water surface area mask is set to 0 until all missing pixels are processed.

[0018] Furthermore, in step 2, the following steps are specifically performed:

[0019] Step 201, data normalization: according to the given configuration information, decide whether it is necessary to calculate the normalized value of each data point. This step is to map the data value into a standardized color index range;

[0020] Step 202, determine the color interval: determine the position of the data value in the color index array according to the data value, find the color interval containing the data value, and record the left and right endpoint indexes of the interval;

[0021] Step 203, take the color value at the left end of the interval or take the interpolation result: determine whether to perform color interpolation according to the information in the configuration file. If it is set to 0, directly return the color value of the left end point of the interval; otherwise, perform color interpolation to obtain a smoother color transition;

[0022] Step 204, apply to each pixel: apply the calculated color value to each pixel to generate a final color mapping image.

[0023] Furthermore, in step 203, the specific process of color interpolation is: for the selected color interval, a linear interpolation method is used to obtain the final RGB color value of the pixel by calculating the weighted average of the colors of the two interval endpoints:

[0024] ;

[0025] ; ;

[0026] ;

[0027] Among them, C relativevalue It is the original data value or the value normalized to the range of 0 to 1 according to the configuration file. i is the data value corresponding to the starting index of the current color interval, C nextis the data value corresponding to the end index of the current color interval. The interpolation coefficient α of the relative data value in the current interval is calculated by the formula, r left 、r right , g left , g right 、b left 、b right are the RGB values ​​of the start and end indexes of the current color interval, and r, g, and b are the RGB values ​​corresponding to each pixel.

[0028] Furthermore, in step 3, the specific steps of drawing contour lines are:

[0029] Step 301, binarization and repair: first, normalize the data information preprocessed in step 1 into a uniform range, and use a constructor to store it as a data texture; then convert the data texture into a binary image, in which black and white are assigned according to whether the corresponding data of each pixel point is higher than a threshold; then perform dilation and image repair operations on the binary image to fill in the discontinuous parts of the data;

[0030] Step 302, constructing and optimizing a key point array: first, traverse the binary image, determine the path of the isovalued line by analyzing the pixel value and a given threshold, construct a key point array of the line, and then traverse the key point array to achieve deduplication;

[0031] Step 303, constructing the contour and calculating the control points: constructing the contour through the key point array, and then calculating the control points of the Bezier curve to fit and draw the line to obtain the contour line; then optimizing the generated contour line to remove the points that are too close;

[0032] Step 304, numerical text annotation: adding numerical text annotation on the contour line according to the needs of the user configuration file;

[0033] Step 305, outputting contour lines: outputting contour lines in SVG format or PNG format according to user needs.

[0034] Furthermore, the specific implementation method of constructing the key point array of the contour line is: first consider the current pixel point and its surrounding pixels as the search neighborhood, check whether the data value of the point meets the water range, and continue to perform relevant calculations if the conditions are met; next, the actual position of the key point is determined according to the threshold threshold and the data values ​​corresponding to the surrounding pixels through the following formula, so that the contour line fits the actual distribution of the data more smoothly:

[0035] ;

[0036] ;

[0037] ;

[0038] ;

[0039] ;

[0040] ;

[0041] ;

[0042] ;

[0043] ;

[0044] ;

[0045] in, , , , , , , , Respectively represent the horizontal and vertical coordinates of the upper left, upper right, lower left, and lower right pixels. , , , Respectively represent the data values ​​corresponding to the upper left, upper right, lower left, and lower right pixels. Threshold is the threshold value obtained by normalizing the contour line array defined by the user in the config.json file. Scale is the scaling factor and stride is the step size. The above formula is used to obtain the intersection of the contour line at the current pixel and its neighboring pixel points for the subsequent drawing process.

[0046] Next, contour segments are dynamically generated according to the value of tempCount. Specifically: initialize the counter tempCount variable to 0, then update the value of tempCount according to the data corresponding to the four endpoints and the comparison result of the threshold. Different weights are used here to distinguish the upper left, upper right, lower left, and lower right points; determine the pixel boundaries that the contour lines may pass through according to the value of tempCount, use the previously calculated left, top, right, and bottom to determine the direction of the contour lines in the local area, add the contour segments to a lines array for storing the contour lines, use the two endpoints as key points, and continue to traverse the remaining pixel points; after the traversal is completed, sort and reduce the weight of all key points to construct the contour lines.

[0047] Furthermore, in step 3, the specific steps of constructing the contour line are: create three arrays contours, isClosedcontour and usedLines to mark the contour point set, whether the contour is closed, and whether the line segment is used to construct the contour; first find a point that can be used as the starting point of the contour, and continuously find new points from the starting point and check the connectable lines, add the connected key points to the contour array, and track the lines that have been used to avoid reuse until all points are used to construct the contour and no connectable lines can be found; next, remove the points that are too close in the constructed contour, and record the information whether the contour is closed; for each contour, draw a Bezier curve after obtaining the control points by calculation to obtain the final contour line pattern.

[0048] Furthermore, in step 3, numerical text annotation is required before outputting the contour pattern. The specific steps of numerical text annotation are: evaluating the local contour direction at each key point, calculating the sine value to determine the inclination direction of the contour; evaluating the expected width of the text annotation, and selecting the text annotation position.

[0049] Furthermore, in step 4, if the ocean data contains ocean current vector environment data, it is necessary to traverse the data file to obtain the corresponding longitude, latitude and data of the specified type to construct a data file in JSON format and use the particle system to simulate the movement of ocean currents;

[0050] If you need to display ocean data of different depths in three dimensions, you need to loop through each pixel in the three-dimensional data set, fill the variable data into the corresponding position in the image data set, and write the vtkImageData object filled with data into the VTI file to visualize the three-dimensional effect.

[0051] Compared with the prior art, the advantages of the present invention are: in the data preprocessing stage, two masks, mask and water_mask, are used to mark invalid pixels and water pixels in the data. This distinction allows the present invention to focus on repairing missing data in the water surface area, which can effectively save computing resources; at the same time, different interpolation algorithms are dynamically selected according to the spatial distribution characteristics of the data. This adaptive interpolation method can better adapt to the local characteristics of the data.

[0052] In the stage of drawing contour lines, compared with the classic Marching Squares algorithm, the present invention improves the traditional straight line segment drawing and uses Bezier curves to smooth the contour lines, making the line representation more fluent and beautiful. In addition, the present invention can dynamically draw contour lines according to different thresholds, and provides a function for evaluating the optimal text annotation position, which can adapt to different data sets more flexibly, so that the numerical information on the contour lines can be displayed intuitively without obstruction, and the readability of the drawing results is enhanced. The present invention supports the output of contour lines in SVG format, which is suitable for high-quality image rendering and scaling, and significantly improves the drawing quality and readability. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0054] Figure 1 is a flow chart of the method of the present invention;

[0055] Figure 2 A flowchart of the steps of visualizing the main texture of ocean data according to the present invention;

[0056] Figure 3 A flow chart of the steps of drawing contour patterns of ocean data for the present invention;

[0057] Figure 4 This is a diagram showing the effect of visualizing the two-dimensional scalar ocean data of the present invention;

[0058] Figure 5 Draw the effect diagram of the isoline for the present invention;

[0059] Figure 6 This is a diagram showing the effect of visualizing the two-dimensional vector ocean data of the present invention;

[0060] Figure 7 This is a rendering of the implementation effect of the three-dimensional ocean data visualization display of the present invention, wherein (a) is a visualization cube of all ocean data, and (b) is the visualization result of a cross section of the cube. DETAILED DESCRIPTION

[0061] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0062] In order to realize the visualization of ocean data, the present invention first automatically reads data files and configuration files, then pre-processes the data by patching missing data, and then performs color mapping on the ocean data to obtain the final visualization image and complete the drawing of contour lines. Figure 1 As shown, this embodiment provides a method for visualizing three-dimensional ocean temperature-salinity flow data, comprising the following steps:

[0063] Step 1: Automatically read and preprocess data files:

[0064] Automatically read ocean observation data and configuration files, and preprocess the data. The preprocessing includes using masks to mark data outliers or invalid data, and repairing missing data through adaptive interpolation methods to ensure data consistency.

[0065] The present invention parses the user-defined configuration file, allowing the user to adjust the color mapping scheme according to personal preferences or specific needs to achieve high flexibility in data visualization. At the same time, the present invention iteratively repairs the missing data through the adaptive interpolation method, so that the data preprocessing process can better adapt to the local spatial characteristics of the data.

[0066] Step 101, read the data file, extract the longitude, latitude, layer depth and other information from the data file and save them as global variables, store all ocean data and calculate the maximum and minimum values ​​in the data for subsequent operations;

[0067] In the reading stage, automatic reading can be performed according to the file type input by the user. In the present invention, the netCDF library or the C++ standard library is used to read the data file.

[0068] Step 102, read and parse the configuration file. After reading the data file, it is also necessary to read the user-defined JSON format configuration file, which stores the attributes related to the ocean data and their corresponding RGB color scales and contour line RGB color scales. The present invention needs to read all configuration information from the file and store it in the corresponding related variables.

[0069] Step 103: Data preprocessing.

[0070] The main process of data preprocessing is missing value processing and mask marking of invalid data points, including creating OpenCV Mat objects to store data, generating masks to identify data missing areas and water surface areas, and using iterative repair methods to update missing pixels to ensure data consistency.

[0071] As a preferred implementation, the data preprocessing in step 103 is specifically performed by the following steps:

[0072] 1) The variables obtained in step 102 include water area data water_mask_datas. If the data value is not null and not an outlier, the corresponding water_mask mask position is set to 255, indicating the water surface area. Next, the input raw data is traversed. Once an outlier or invalid data is detected, the mask variable is used to mark these data points and mark them as data missing areas.

[0073] The mask is a matrix of the same size as the data. In the process of reading data, invalid pixels will be assigned specific values ​​in the mask for processing in subsequent steps. Compared with the prior art, the present invention uses mask to identify points that need to be interpolated, and uses water_mask to ensure that the interpolation process is performed on the water area, which improves the accuracy and pertinence of data preprocessing, allowing developers to control the data processing process more finely and ensure that different types of data are properly processed.

[0074] 2) For missing data, an adaptive method is used to dynamically select interpolation algorithms based on the surrounding valid pixels to fill in the missing values ​​according to the spatial distribution characteristics of the ocean data. Before processing the missing data, the neighborhood range is defined (usually a 3*3 window), the gradient of the data is calculated in the local neighborhood, and the rate of change of the data is measured according to the gradient size. In areas where the data changes slowly (areas with small gradients), simple linear interpolation is selected for pixel repair; in areas where the data changes dramatically (areas with large gradients), spline interpolation is selected for pixel repair. All missing pixels are repaired through multiple iterations. If there are still pixels that cannot be filled after processing, the pixel value corresponding to the water surface area mask is set to 0 to ensure data consistency until all missing pixels are processed.

[0075] The present invention dynamically selects different interpolation algorithms according to the spatial distribution characteristics of the data. This adaptive interpolation method can better adapt to the local characteristics of the data. In addition, the missing pixels are repaired in an iterative manner to ensure the continuity and consistency of the data and improve the data quality. The present invention also considers the image boundary during the repair process and ensures that the out-of-bounds pixels will not be accessed, which ensures that no out-of-bounds errors will occur during the data repair process.

[0076] Step 2: Data normalization and color mapping:

[0077] The numerical information preprocessed in step 1 is converted into color information according to the user-defined color mapping rules and output in JPG format to achieve a two-dimensional visualization effect of ocean data.

[0078] Specifically, the ocean data must first be normalized, and according to the color mapping rules defined in the configuration file, it is decided whether to use linear interpolation to calculate the final RGB value, to implement the process of converting the data value into RGB color value, and to set the main texture color for each pixel.

[0079] As a preferred implementation, color mapping is performed for each effective pixel to generate a visual texture. Figure 2 As shown, the following steps are included:

[0080] Step 201, data normalization: that is, normalizing the ocean data to ensure that the values ​​are within the specified range. According to the given configuration information, it is determined whether the normalized value of each data point needs to be calculated. This step is to map the data value into a standardized color index range.

[0081] Furthermore, it is necessary to first determine the type of color mapping to be performed based on the mapping_type variable in the user configuration file. If the variable is set to 0, the relative mapping method is selected. Then, based on the maximum and minimum values ​​obtained in step 101, the value of each data point is converted into a normalized value between 0 and 1, and then mapped to the color index range.

[0082] During the normalization process, if the value in the data point is an invalid value or a specific boundary case, special processing is required, such as assigning a specific color or ignoring the data point. Using dynamic range normalization can adapt to the characteristics of different data sets and improve the adaptability and accuracy of color mapping.

[0083] Step 202, determine the color interval: according to the normalized data value, traverse the color index array, determine its position in the color index array, find the color interval containing the data value, and record the left and right endpoint indexes of the interval.

[0084] Step 203, take the color value at the left end of the interval or take the interpolation result: determine whether to perform color interpolation according to the information in the configuration file. If it is set to 1, the color value of the left end point of the interval is directly returned; otherwise, color interpolation is performed to obtain a smoother color transition.

[0085] In the configuration file, users can set the related variable interpolation to 1 or 0, which indicates whether linear interpolation is required. If the variable is set to 0, the color value at the left end of the interval is directly used as the mapping result; if the variable is set to 1, the color values ​​of the left and right endpoints of the interval need to be obtained, and the mapping result is obtained through linear interpolation, making the color mapping effect smoother.

[0086] Step 204, apply to each pixel: apply the calculated color value to each pixel to generate a final color mapping image.

[0087] Through this step, all pixels are traversed, the calculated RGB color value is assigned to the current pixel, the image matrix mainTex is updated, and the image output function cv::imwrite of OpenCV is used to save the color mapped image as a JPG file. The visualization effect of the two-dimensional scalar ocean data is as follows: Figure 4 shown.

[0088] As a preferred implementation, the specific process of color interpolation is: for the selected color interval, a linear interpolation method is used to obtain the final RGB color value of the pixel by calculating the weighted average of the colors of the two interval endpoints:

[0089] ;

[0090] ; ;

[0091] ;

[0092] Among them, C relativevalue It is the original data value or the value normalized to the range of 0 to 1 according to the configuration file. i is the data value corresponding to the starting index of the current color interval, C next is the data value corresponding to the end index of the current color interval. The interpolation coefficient α of the relative data value in the current interval is calculated by the formula, r left 、r right , g left , g right 、b left 、b right are the RGB values ​​of the start and end indexes of the current color interval, and r, g, and b are the RGB values ​​corresponding to each pixel.

[0093] Step 3: Draw contour lines:

[0094] First, the data information preprocessed in step 1 is normalized to obtain the data texture. Then, the data texture is converted into a binary image through threshold processing, and the data texture is smoothed using the image restoration algorithm. The index array of the contour line is traversed, and the contour line is constructed by calculating the actual position of the key points of the contour line. Then, the Bezier curve is drawn to obtain the final contour line pattern.

[0095] Compared with other techniques, the present invention dynamically determines the path of the contour line based on the pixel value, rather than relying on a predefined pattern or fixed algorithm, which makes the present invention more flexible and can adapt to different data sets to draw contour lines. By using the threshold parameter, the code can adjust the position of the line according to specific data features, increasing the flexibility of the algorithm. At the same time, through the water_mask parameter, the present invention can identify the data belonging to the water surface area in the data. This processing method allows the algorithm to focus on the area of ​​interest during the drawing process.

[0096] The specific steps of drawing contour lines are:

[0097] 1) First, normalize the data information preprocessed in step 1 to a uniform range, for example, use scale to map the data values ​​to the range of 0 to 255, and use the constructor of the cv::Mat class to store it as a data texture.

[0098] 2) Convert the data texture into a binary image, where each pixel is assigned a black or white color based on whether the corresponding data is above a threshold, and then perform dilation and repair operations to fill in the discontinuous parts of the data;

[0099] 3) Traverse the binary image, determine the path of the isovalued line by analyzing the pixel value and the given threshold, construct the key point array of the line to form the contour, and then calculate the control points of the Bezier curve to fit and draw the line;

[0100] 4) Optimize the generated contour lines, remove points that are too close to improve the clarity and drawing effect of the contour lines, and add numerical text annotations at appropriate locations so that users can more intuitively identify the specific values ​​represented by the contour lines;

[0101] 5) Export the contour lines to SVG or PNG format according to user needs.

[0102] In this step, further, in step 3, the specific implementation method of constructing the key point array of the contour line is: first consider the current pixel point and the pixel points around it as the search neighborhood, check whether the data value of the point meets the water range, and if it meets the conditions, continue to perform relevant calculations, which saves the calculation time of data in the non-water range. Next, the actual position of the key point will be determined according to the threshold threshold and the data values ​​corresponding to the surrounding pixels through the following formula, so that the contour line fits the actual distribution of the data more smoothly:

[0103] ;

[0104] ;

[0105] ;

[0106] ;

[0107] ;

[0108] ;

[0109] ;

[0110] ;

[0111] ;

[0112] ;

[0113] in, , , , , , , , Respectively represent the horizontal and vertical coordinates of the upper left, upper right, lower left, and lower right pixels. , , , They represent the data values ​​corresponding to the upper left, upper right, lower left, and lower right pixels respectively. Threshold is the threshold obtained by normalizing the contour line array defined by the user in the config.json file. Scale is the scaling factor, and stride is the step size. Through the above formula, the intersection of the contour line at the current pixel and its neighboring pixel is obtained for the subsequent drawing process.

[0114] Next, initialize the counter tempCount variable to 0, and then update the value of tempCount according to the data corresponding to the four endpoints and the comparison results of the threshold. Here, different weights (8, 4, 1, 2) are used to distinguish the upper left, upper right, lower left, and lower right points. Determine the pixel boundaries that the contour line may pass through based on the value of tempCount, and use the previously calculated left, top, right, and bottom to determine the direction of the contour line in the local area. Add the contour line segment to the lines array, and use the two endpoints as key points, and continue to traverse the remaining pixel points; after the traversal is completed, sort and reduce the weight of all key points to construct the contour line. Dynamically generate contour line segments based on the value of tempCount instead of using a predefined lookup table to make the drawing of contour lines more flexible.

[0115] In the process of calculating the actual position of the key points of the contour line, different thresholds are accepted through the threshold parameter, which means that the present invention can be used to track contour lines of different levels in different data sets. This flexibility allows users to adjust the display of contour lines according to specific needs. By using the stride and scale parameters, the present invention can adapt to images of different resolutions and different data scales, improving the versatility and applicability of the algorithm. At the same time, the calculation of the line endpoints and control points in the present invention takes into account the relative position of the contour line within the pixel. This method provides a more accurate line representation than other contour line tracking algorithms.

[0116] Furthermore, in step 3, the specific steps for constructing contours are: create three arrays contours, isClosedcontour, and usedLines to mark the contour point set, whether the contour is closed, and whether the line segment is used to construct the contour. First, find a point that can be used as the starting point of the contour (that is, skip all points that appear in pairs. If all points appear in pairs, it means that the contour is closed), start from the starting point and continuously find new points and check the connectable lines, add the connected key points to the contour array, track the lines that have been used, and avoid repeated use, until all points are used to construct the contour and no connectable lines can be found.

[0117] Next, we remove points that are too close to each other in the constructed contour and record whether the contour is closed. For each contour, we draw a Bezier curve after calculating the control points to obtain the final contour line pattern.

[0118] In the process of constructing the contour line, the present invention uses an array to record the number of repetitions of each point and removes duplicates when constructing the contour, which reduces unnecessary calculations and the use of storage space. At the same time, when the starting point and the end point of the contour are particularly close, the contour is closed, which can make the contour representation more accurate when processing actual data.

[0119] As a preferred implementation, according to the configuration file defined by the user, it can be determined whether the corresponding contour pattern needs to be output. The specific implementation method of drawing the contour pattern is as follows: Figure 3 shown.

[0120] Step 301: Binarization and restoration.

[0121] First, the data information preprocessed in step 1 needs to be normalized to a uniform range, for example, using scale to map the data value to the range of 0 to 255, and using the constructor of the cv::Mat class to store it as a data texture. Next, the data texture is converted into a binary image, where black and white are assigned according to whether the corresponding data of each pixel point is higher than the threshold. The binary image is stored in the imageMask variable of the data type CV_8UC1, which helps with the subsequent identification and processing of contour lines. At the same time, in order to fill the holes or breaks in the image, the binary image needs to be expanded and repaired before drawing the contour lines. In the specific implementation process, the cv::dilate function and cv::inpaint function of OpenCV need to be used to process the binary image, so that the subsequent generation of contour lines is smoother and more continuous.

[0122] Step 302: construct an array of contour key points and optimize it.

[0123] First, traverse the binary image, determine the path of the contour line by analyzing the pixel value and the given threshold, and construct the key point array of the line. First, you need to define relevant variables such as pixel coordinates (lt, rt, lb, rb, representing the coordinates of the upper left, upper right, lower left, and lower right pixel points, respectively), and the corresponding data values ​​(lt_value, rt_value, lb_value, rb_value, representing the data values ​​corresponding to the upper left, upper right, lower left, and lower right pixel points, respectively). According to the comparison results of the data values ​​of the current pixel and its neighboring pixel points with the contour line threshold, the actual position of the contour line key point is calculated using the relevant formula. The formula is mentioned in the previous part and will not be repeated here. Update the value of the counter tempCount according to the data corresponding to the four endpoints and the comparison results of the threshold, determine the direction of the contour line around the current pixel, create contour line segments with relevant points and add them to the key point array.

[0124] After calculating the key point array, all key points need to be sorted, and then the key point array is traversed to compare whether the current key point is the same as the next point. If they are the same, the first point is added to the new array, and subsequent identical points are skipped to achieve the purpose of deduplication and improve the clarity and drawing effect of the contour lines.

[0125] Step 303: construct contour lines and calculate Bezier curve control points.

[0126] The contour is constructed through the key point array, and then the control points of the Bezier curve are calculated to fit and draw the line to obtain the contour line; then the generated contour line is optimized to remove points that are too close.

[0127] First, initialize the marker array and find the starting point of the isoline segment (skip all points that appear in pairs), start from the starting point and keep looking for new points and check for connectable lines, add the connected key points to the contour array, keep track of the lines that have been used to avoid reuse, until all points are used to build the contour and no connectable lines can be found. Next, simplify the contour. If the distance between two points is less than 5 times the stride, the two points are considered too close and the point with index next is deleted.

[0128] Furthermore, after constructing the contour, the control points Ctrl1 and Ctrl2 of the Bezier curve need to be calculated through the key points using the following formula:

[0129] ;

[0130] ;

[0131] ;

[0132] ;

[0133] ;

[0134] ;

[0135] Among them, p0 x ,p0y,p1 x 、p1 y 、p2 x 、p2 y is the horizontal and vertical coordinates of the three adjacent elements in the key point list, d 01 and d 12 Respectively represent the distance between point p0 and point p1, point p1 and point p2, t is used to control the position of the control point, Ctrl1 x , Ctrl1 y , Ctrl2 x , Ctrl2 y They represent the horizontal and vertical coordinates of the two control points respectively. The calculated control points are added to the Ctrl1 and Ctrl2 arrays respectively, and the drawing operation is performed when outputting the contour line pattern.

[0136] Compared with the traditional control point calculation method, the present invention uses a parameter t to dynamically calculate the position of the control point, thereby affecting the shape of the curve and creating a more natural and smooth visual effect.

[0137] Step 304, numerical text annotation. According to the needs of the user profile, numerical text annotations are added at appropriate locations on the contour lines, so that the user can intuitively identify the specific values ​​represented by the contour lines. Specifically, the present invention evaluates the local contour direction at each key point and calculates the sine value to determine the tilt direction of the contour, so as to ensure that the text annotation can clearly point upward; in addition, the expected width of the text annotation is evaluated, so as to avoid visual overlap and select the best text annotation position.

[0138] The present invention adopts a dynamic scoring system to evaluate and select the best text position, uses current_score to record the suitability of the text annotation placement position starting from a certain position, and compares the current position with the best position found before to decide whether to update, which helps to find the best text placement point on the entire contour.

[0139] Step 305: Output the contour line pattern. According to user needs, the contour line pattern can be output in SVG format or in PNG format using OpenCV's cv::line function and cv::imwrite function. The effect of drawing the contour line pattern is as follows: Figure 5 shown.

[0140] The specific steps for converting curve data into SVG format text elements are as follows: first, initialize the SVG format string contents, determine the size of the SVG canvas according to the width and height of the output curve data, and then create SVG rectangular and circular masks for masking text and contour line paths. Next, set the color, width and other attributes of the path and apply the mask to control the visible area of ​​the path. Then use the "C" command to add contour points to the SVG path to draw the contour pattern. If the contour is closed, use the "Z" command to close the path. Finally, set the text style, and convert the value represented by the contour line into a string according to the best placement point of the text annotation and add it to the text element. Write the constructed SVG content contents to a user-defined file with the extension ".svg".

[0141] Step 4: Visualize vector data or 3D data:

[0142] If the ocean data contains vector environmental data or requires three-dimensional display, JSON format files are constructed according to user needs to enable the particle system to simulate ocean current movement; or the data is filled into a VTI file to achieve three-dimensional visualization of the ocean data.

[0143] (1) If the ocean data contains ocean current vector environment data, it is necessary to traverse the data file to obtain the corresponding longitude, latitude and data of the specified type to construct a data file in JSON format and use the particle system to simulate the movement of ocean currents.

[0144] (2) If you need to display ocean data at different depths in three dimensions, you need to loop through each pixel in the three-dimensional data set, fill the variable data into the corresponding position in the image data set, and write the vtkImageData object filled with data into the VTI file to visualize the three-dimensional effect.

[0145] Visualize vector data or 3D data. Output vector data to JSON file format according to user needs to achieve visualization effect in particle system. The actual visualization effect after importing JSON file into interactive platform is as follows Figure 6 As shown; or output the 3D data to VTI file format to achieve 3D visualization effect. The actual visualization effect after importing the VTI file into the interactive platform is as follows Figure 7 As shown, Figure 7 (a) is a visualization cube of all ocean data, which is used to show the spatial distribution of ocean data at different depths. Figure 7 (b) is the visualization result of a cross section of the cube, which is used to show the spatial distribution of the corresponding layer depth.

[0146] In addition, the present invention also provides a flexible configuration mechanism, allowing users to customize data attributes such as RGB color scale, contour line RGB color scale, etc. through configuration files, thereby meeting the needs of different users.

[0147] It should be noted that in the configuration file, users can change the mapping_type variable to 0 or 1 to control the color mapping method. A variable value of 0 indicates relative mapping. The color mapping process is based on the minimum and maximum values ​​of the data, so that the color distribution is related to the relative distribution. Even if the absolute range of the data changes, the color mapping remains consistent; a variable value of 1 indicates absolute mapping, which will cause each value in the data to be associated with a specific color value, and data out of range will not be correctly mapped to the color space.

[0148] The interpolation variable in the configuration file represents the interpolation method, which will affect the mapping result of each pixel in the color mapping stage. When the variable is 0, the RGB value at the left endpoint of the color interval is used as the mapping result. When the variable is 1, the RGB value calculated by linear interpolation is used as the mapping result, which can make the color transition smoother.

[0149] In the configuration file, you also need to set the default outlier type to detect missing data or outliers in the data. You also need to define the mapped numeric array index and the corresponding Red, Green, and Blue color value arrays. The array length of each variable must be consistent.

[0150] In addition, the definitions of attributes such as the contour RGB color scale are the same as those of the texture RGB color scale, and are not repeated here.

[0151] Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Any changes, modifications, additions or substitutions made by ordinary technicians in this technical field within the essential scope of the present invention should fall within the protection scope of the present invention.

Claims

1. A method for visualizing three-dimensional ocean temperature-salinity flow data, characterized in that: The following steps are involved: Step 1: Automatically read and preprocess data files: Automatically read ocean observation data and configuration files, and preprocess the data, including using masks to mark data outliers or invalid data, and repairing missing data through adaptive interpolation methods; Step 2: Data normalization and color mapping: The data information preprocessed in step 1 is converted into color information according to the user-defined color mapping rules and output in JPG format to achieve a two-dimensional visualization effect of ocean data; Step 3: Draw contour lines: First, the data information preprocessed in step 1 is normalized to obtain data texture, and then the data texture is converted into a binary image through threshold processing, and the data texture is smoothed using an image restoration algorithm, and the index array of the contour line is traversed, and the contour line is constructed by calculating the actual position of the key points of the contour line, and then the Bezier curve is drawn to obtain the final contour line pattern; The specific steps of drawing contour lines are: Step 301, binarization and repair: first, normalize the data information preprocessed in step 1 into a uniform range, and use a constructor to store it as a data texture; then convert the data texture into a binary image, in which black and white are assigned according to whether the corresponding data of each pixel point is higher than a threshold; then perform dilation and image repair operations on the binary image to fill in the discontinuous parts of the data; Step 302, constructing and optimizing a key point array: first, traverse the binary image, determine the path of the contour line by analyzing the pixel value and the given threshold, construct the key point array of the line, and then traverse the key point array to achieve deduplication; the given threshold refers to the threshold value, which is the threshold value obtained by normalizing the contour line array defined by the user in the config.json file; Step 303, constructing contours and calculating control points: constructing contours through key point arrays, and then calculating the control points of the Bezier curve to fit and draw the lines to obtain contour lines; then optimizing the generated contour lines to remove points that are too close; Step 304, numerical text annotation: adding numerical text annotations to the contour lines according to the needs of the user configuration file; Step 305, outputting contour lines: outputting contour lines in SVG format or PNG format according to user needs; Step 4: Visualize vector data or 3D data: If the ocean data contains vector environmental data or needs to be displayed in three dimensions, a JSON format file is constructed to simulate ocean current movement or the data is filled into a vtkImageData object and written to a VTI file to achieve vector simulation and three-dimensional visualization of the ocean data.

2. The method for visualizing ocean three-dimensional temperature-salinity flow data according to claim 1, characterized in that: In step 1, the ocean data preprocessing is specifically carried out using the following steps: 1) The information obtained from the configuration file includes water area data water_mask_datas. If the data value is not null and not an outlier, the corresponding water_mask mask position is set to 255, indicating the water surface area; Next, traverse the input raw data. Once an outlier or invalid data is detected, use the mask variable to mark these data points and mark them as data missing areas; 2) For missing data, an adaptive method is used to dynamically select interpolation algorithms based on the surrounding valid pixels to fill in the missing values ​​according to the spatial distribution characteristics of ocean data. Specifically, the neighborhood range is defined before processing missing data, the gradient of the data is calculated in the local neighborhood, and the rate of change of the data is measured according to the gradient size. In areas with small gradients, linear interpolation is selected for pixel repair; in areas with large gradients, spline interpolation is selected for pixel repair; all missing pixels are repaired through multiple iterations. If there are still pixels that cannot be filled after processing, the pixel value corresponding to the water surface area mask is set to 0 until all missing pixels are processed.

3. The method for visualizing ocean three-dimensional temperature-salinity flow data according to claim 1, characterized in that: In step 2, the following steps are specifically performed: Step 201, data normalization: according to the given configuration information, decide whether it is necessary to calculate the normalized value of each data point. This step is to map the data value into a standardized color index range; Step 202, determine the color interval: determine the position of the data value in the color index array according to the data value, find the color interval containing the data value, and record the left and right endpoint indexes of the interval; Step 203, take the color value at the left end of the interval or take the interpolation result: determine whether to perform color interpolation according to the information in the configuration file. If it is set to 0, directly return the color value of the left end point of the interval; otherwise, perform color interpolation to obtain a smoother color transition; Step 204, apply to each pixel: apply the calculated color value to each pixel to generate a final color mapping image.

4. The method for visualizing three-dimensional ocean temperature-salinity flow data according to claim 3, characterized in that: In step 203, the specific process of color interpolation is: for the selected color interval, a linear interpolation method is used to calculate the weighted average of the colors of the two interval endpoints to obtain the final RGB color value of the pixel: r=r left +α×(r right -r left );g=g left +α×(g right -g left ); b=b left +α×(b right -b left ); Among them, C relativevalue It is the original data value or the value normalized to the range of 0 to 1 according to the configuration file. i is the data value corresponding to the starting index of the current color interval, C next is the data value corresponding to the end index of the current color interval. The interpolation coefficient α of the relative data value in the current interval is calculated by the formula, r left 、r right , g left , g right , b left , b right are the RGB values ​​of the start and end indexes of the current color interval, and r, g, and b are the RGB values ​​corresponding to each pixel.

5. The method for visualizing ocean three-dimensional temperature-salinity flow data according to claim 1, characterized in that: In step 3, the specific implementation method of constructing the key point array of the contour line is: first consider the current pixel and its surrounding pixels as the search neighborhood, check whether the data values ​​of the current pixel and its surrounding pixels meet the water range, and continue to perform relevant calculations if the conditions are met; next, the actual position of the key point is determined according to the threshold threshold and the data values ​​corresponding to the surrounding pixels through the following formula, so that the contour line fits the actual distribution of the data more smoothly: left x =scale×lb x ; top y =scale×lt y ; bottom y =scale×rb y ; right x =scale×rt x ; Among them, lt x ,lt y , rt x , rt y lb x lb y ,rb x ,rb y Respectively represent the horizontal and vertical coordinates of the upper left, upper right, lower left, and lower right pixels, lt value , rt value lb value ,rb value Respectively represent the data values ​​corresponding to the upper left, upper right, lower left, and lower right pixels. Threshold is the threshold value obtained by normalizing the contour line array defined by the user in the config.json file. Scale is the scaling factor and stride is the step size. The above formula is used to obtain the intersection of the contour line at the current pixel and its neighboring pixel points for the subsequent drawing process. Next, contour lines are dynamically generated based on the value of tempCount. Specifically, the counter tempCount variable is initialized to 0, and then the value of tempCount is updated based on the data corresponding to the four endpoints of the upper left, upper right, lower left, and lower right pixel points and the comparison result of the threshold. Different weights are used here to distinguish the upper left, upper right, lower left, and lower right points. The pixel boundaries that the contour lines may pass through are determined based on the value of tempCount. The direction of the contour lines in the local area is determined using the previously calculated left, top, right, and bottom. The contour line segments are added to a lines array for storing the contour lines, and the two endpoints are used as key points. The remaining pixel points are traversed continuously. After the traversal is completed, all key points are sorted and reduced in weight to construct the contour lines.

6. The method for visualizing three-dimensional ocean temperature-salinity flow data according to claim 5, characterized in that: In step 3, the specific steps of constructing the contour line are: create three arrays contours, isClosedcontour and usedLines to mark the contour point set, whether the contour is closed, and whether the line segment is used to construct the contour; first find a point that can be used as the starting point of the contour, and continuously find new points from the starting point and check the connectable lines, add the connected key points to the contour array, and track the lines that have been used to avoid reuse until all points are used to construct the contour and no connectable lines can be found; next, remove the points that are too close in the constructed contour, and record the information whether the contour is closed; for each contour, draw the Bezier curve after calculating the control points to obtain the final contour line pattern.

7. The method for visualizing three-dimensional ocean temperature-salinity flow data according to claim 5, characterized in that: In step 3, numerical text annotation is required before outputting the contour pattern. The specific steps of numerical text annotation are: evaluate the local contour direction at each key point, calculate the sine value to determine the tilt direction of the contour; evaluate the expected width of the text annotation, and select the text annotation position.

8. The method for visualizing three-dimensional ocean temperature-salinity flow data according to claim 6, characterized in that: In step 4, (1) If the ocean data contains ocean current vector environment data, it is necessary to traverse the data file to obtain the corresponding longitude, latitude and data of the specified type to construct a data file in JSON format and use the particle system to simulate the movement of ocean currents; (2) If you need to display ocean data of different depths in three dimensions, you need to loop through each pixel in the three-dimensional data set, fill the variable data into the corresponding position in the image data set, and write the vtkImageData object filled with data into the VTI file to visualize the three-dimensional effect.

Citation Information

Patent Citations

  • Grid contour line drawing method based on ocean IOT (Internet of Things)

    CN108776999A

  • Method of extracting trough ridge feature points and trough ridge feature lines from contour data and synoptic chart analysis method

    CN109102538A