Unified storage and calculation method and system for hexagonal and rectangular grid data
Through the matrix, hexagonal and rectangular grid data are uniformly stored, and the format is dynamically converted according to the task type, the problem of poor compatibility of rectangular and hexagonal grid data processing algorithms is solved, and efficient data storage and processing is realized, suitable for fields such as geographic information systems, astronomy, remote sensing and materials science.
Patent Information
- Application Number
- CN202510471156.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, the data processing algorithms of rectangular and hexagonal grids have poor compatibility and scalability, making it difficult to achieve the unity of data storage and algorithm design, resulting in the slow development of hexagonal grids and the inability to effectively integrate processing and analysis.
The hexagonal and rectangular grid data are stored in a matrix form. By specifying the first row of cell indentation identifiers, the hexagonal grid data is stored in indentation format, and converted to double-optimized coordinate format according to the task type in the workflow to realize dynamic conversion of the data format.
It realizes unified storage and processing of hexagonal and rectangular grid data, breaks down the barriers of data storage and algorithm design, improves compatibility and scalability, and is suitable for data analysis and processing in multiple scientific fields.
Smart Images

Figure CN120451290A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geographic information systems (GIS), and in particular to a unified storage and calculation method and system for hexagonal and rectangular grid data. Background Art
[0002] The fundamental problem in digital image processing is spatial discretization, or the tessellation scheme. This depends on the arrangement of the sensor array. Sensor arrays come in two shapes: rectangular and hexagonal. Rectangular arrays are more mature, while hexagonal arrays are more common in specific scientific research fields. Consequently, digital image processing technology has developed along two parallel lines: rectangular grids and hexagonal grids. While the standardization and richness of rectangular grid algorithms far surpass those of hexagonal grid algorithms, the accuracy and visual quality of rectangular grid data analysis are slightly lower than those of hexagonal grids. With the advancement of science and technology, more and more fields, such as astronomy, geographic information science, discrete quantum field theory, and materials science, are demanding the fusion and analysis of data from these two grids. However, barriers exist between the two grids, both in data storage and algorithm design. Their current state of technology can be likened to two parallel lines that never intersect.
[0003] Although data processing algorithms for rectangular and hexagonal grids are generally developing along parallel lines, existing technologies face at least the following challenges due to hardware, geometric properties, and storage barriers: First, compared to the mature rectangular grid algorithm framework, hexagonal grid algorithms have poor scalability and compatibility and are not yet systematic, resulting in slow and difficult progress. Second, given the rigid processing requirements of hexagonal grid sensor data and the hybrid processing requirements of rectangular and hexagonal grid data, it is urgent to propose a unified grid mathematical model and implement an algorithm framework design, breaking down the barriers between data storage and algorithm design to achieve parallel processing, free conversion, and fusion analysis of rectangular and hexagonal grid data. Summary of the Invention
[0004] In order to solve the above problems, in a first aspect of the present invention, a method for unified storage and calculation of hexagonal and rectangular grid data is provided, the method comprising the following steps:
[0005] Hexagonal grid and rectangular grid data are uniformly stored in matrix form. If the matrix stores hexagonal grid data, the first row of pixel indentation identifiers of the matrix is specified, and the format of the hexagonal grid data matrix storage is recorded as the indentation format.
[0006] Read image data stored in matrix form. If the image data is hexagonal grid data, for each step in the workflow, if it is a geometry processing task and the output of the previous step is in indented format, convert the indented format to double-optimized coordinate format. If it is a statistics task and the output of the previous step is in double-optimized coordinate format, convert the double-optimized coordinate format to indented format.
[0007] Preferably, the converting of the indentation format into the double optimized coordinate format is specifically as follows:
[0008] Separate the matrix in indentation format into odd and even rows, and obtain the indentation mark of the first row of pixels in the matrix.
[0009] If the first row pixel indentation is identified as the first row indentation, zero pixels are inserted at the beginning of the odd rows and zero pixels are appended at the end of the even rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format.
[0010] If the first row pixel indentation flag is that the first row is not indented, zero pixels are inserted at the beginning of the even rows and zero pixels are appended at the end of the odd rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format.
[0011] Preferably, the converting of the double optimized coordinate format into the indented format is specifically as follows:
[0012] Determines whether to indent the first line based on the first and second lines in the double-optimized coordinate format.
[0013] If so, the first row pixel indentation mark is the first row indentation, the zero pixels at the beginning of the odd row are deleted, the zero pixels at the end of the even row are deleted, and the odd and even rows are reconnected to obtain the indentation format.
[0014] Otherwise, the first row pixel indentation mark is that the first row is not indented, the zero pixels at the beginning of the even row are deleted, the zero pixels at the end of the odd row are deleted, and the odd and even rows are reconnected to obtain the indentation format.
[0015] Preferably, after reading the image data stored in the matrix form, the method further includes:
[0016] If the image data is rectangular grid data, the workflow processing remains unchanged.
[0017] Preferably, the statistical tasks include grayscale stretching, histogram equalization and / or normalization; the geometric processing tasks include convolution, rotation, scaling and / or affine transformation.
[0018] In a second aspect of the present invention, a unified storage and computing system for hexagonal and rectangular grid data is provided, the system comprising the following modules:
[0019] A unified storage module is used to uniformly store hexagonal grid and rectangular grid data in matrix form. If the matrix stores hexagonal grid data, the first row of pixel indentation identifiers of the matrix is specified, and the format of the hexagonal grid data matrix storage is recorded as the indentation format.
[0020] A unified computing module is used to read image data stored in matrix form. If the image data is hexagonal grid data, for each step in the workflow, if it is a geometric processing task and the output of the previous step is in indented format, the indented format is converted to a double-optimized coordinate format. If it is a statistical task and the output of the previous step is in double-optimized coordinate format, the double-optimized coordinate format is converted to an indented format.
[0021] Preferably, the converting of the indentation format into the double optimized coordinate format is specifically as follows:
[0022] Separate the matrix in indentation format into odd and even rows, and obtain the indentation mark of the first row of pixels in the matrix.
[0023] If the first row pixel indentation is identified as the first row indentation, zero pixels are inserted at the beginning of the odd rows and zero pixels are appended at the end of the even rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format.
[0024] If the first row pixel indentation flag is "no indentation for the first row", zero pixels are inserted at the beginning of the even rows and zero pixels are appended at the end of the odd rows, and the even and odd rows are reconnected to obtain a double optimized coordinate format.
[0025] Preferably, the converting of the double optimized coordinate format into the indented format is specifically as follows:
[0026] Determines whether to indent the first line based on the first and second lines in the double-optimized coordinate format.
[0027] If so, the first row pixel indentation mark is the first row indentation, the zero pixels at the beginning of the odd row are deleted, the zero pixels at the end of the even row are deleted, and the odd and even rows are reconnected to obtain the indentation format.
[0028] Otherwise, the first row pixel indentation mark is that the first row is not indented, the zero pixels at the beginning of the even row are deleted, the zero pixels at the end of the odd row are deleted, and the odd and even rows are reconnected to obtain the indentation format.
[0029] Preferably, after reading the image data stored in the matrix form, the method further includes:
[0030] If the image data is rectangular grid data, the workflow processing remains unchanged.
[0031] Preferably, the statistical tasks include grayscale stretching, histogram equalization and / or normalization; the geometric processing tasks include convolution, rotation, scaling and / or affine transformation.
[0032] In a third aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program stored on the computer-readable storage medium implements the method according to the first aspect when executed by a processor.
[0033] This paper proposes a unified grid mathematical model. Based on this model, it utilizes a rectangular image storage solution and, taking into account the characteristics of data workflows, proposes a hexagonal image storage and format conversion solution compatible with rectangular images. This solution is the most space-efficient hexagonal data storage and processing solution, combining compatibility with rectangular grids with strong scalability. This paper can uniformly process rectangular and hexagonal grid data, breaking down the data storage and algorithm design barriers in the prior art. In addition to digital image processing-related fields, this paper is also applicable to a variety of fields, including astronomy, remote sensing, quantum theory, and materials science, meeting the needs of diverse application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 This is a flow chart of Example 1;
[0035] Figure 2 This is a schematic diagram of the hexagonal grid data storage format and conversion algorithm;
[0036] Figure 3 Schematic diagram of the workflow for unifying data for rectangular and hexagonal grids;
[0037] Figure 4 This is a schematic diagram of hexagonal grid resampling;
[0038] Figure 5 It is a rectangular grid image class and a hexagonal grid image class. DETAILED DESCRIPTION
[0039] In the embodiments of the present invention, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner to facilitate understanding.
[0040] It will be understood that the “embodiment” mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the various embodiments throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It will be understood that in the various embodiments of the present application, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0041] In the present invention, unless otherwise specified, the same or similar parts between the various embodiments can refer to each other. In the various embodiments of the present invention, and the various implementation methods / implementation methods / implementation methods in each embodiment, if there is no special explanation and logical conflict, the terms and / or descriptions between different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment are consistent and can be referenced to each other. The technical features in different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment can be combined to form new embodiments, implementation methods, implementation methods, or implementation methods according to their inherent logical relationships. The implementation methods of the present application described below do not constitute a limitation on the scope of protection of the present application.
[0042] A grid is a discrete representation of a continuous space, with grid cells being closed regions enclosed by partitioning boundaries. This is a common example in nature, such as the array of cone cells in the human eye and the hexagonal structure of a honeycomb. It also occurs in artificial devices, such as sensor arrays, which divide the sensor plane into discrete cells. Through the imaging process, continuous spectral information is quantified and recorded by each cell. Therefore, all digital images are stored in discrete grids.
[0043] Inspired by lattice theory and cryptography, the following mathematical model is developed to illustrate key points about grids. Definition 1 provides a general definition of the grid category, while Definitions 2 and 3 define rectangular and hexagonal grids, respectively. For ease of understanding, Definition 4 introduces unimodular matrices. To avoid ambiguity in grid representation, Theorem 1 expresses the necessary and sufficient conditions for grid congruence, and from this, we derive corollaries regarding grid subset relations.
[0044] A grid is represented by a set of its cell centers: First, a grid cell is a linear space The elements in . Second, the combination of grid cells is closed with respect to the operator '+'. Third, the position of each grid cell is expressed by its center. The general definition of a grid is as follows:
[0045] Definition 1: A grid is defined as a triplet: (L, B, +), where:
[0046] (i) L is the set of grid points, n is the linear space Dimensions of:
[0047]
[0048] (ii) B is The base,
[0049] (iii) '+' is a binary operator defined on L×L, and for any p, q, r∈L, it satisfies the following conditions:
[0050] Commutative law: p+q=q+p
[0051] Associative law: (p+q)+r=p+(q+r)
[0052] Unit element:
[0053] Negative yuan:
[0054] (iv) The elements in L form a closed operation with respect to '+'. For any p, q∈L, p+q=r∈L.
[0055] In the above definition, additive closure guarantees a uniform distribution of cells. Rectangular and hexagonal grids satisfy this definition, but triangular grids do not. Because of this, triangular grid cell arrays have holes, so they are not discussed here. The following definitions are given for planar rectangular and hexagonal grids, where one of the basis vectors for the planar grid is horizontal:
[0056] Definition 2: The grid of rectangular pattern is defined as G r =(L r , B r , +), where the operator '+' represents vector addition, B r is the basis of the rectangular grid. Let w1 be the distance between the centers of adjacent horizontal cells and h1 be the distance between the centers of adjacent vertical cells:
[0057]
[0058] Definition 3: The hexagonal grid is defined as G h =(L h , B h , +), where the operator '+' represents vector addition, B h It is the basis of the hexagonal grid. The meaning of w2 relative to w1 remains unchanged. h2 represents the projection of the distance between the centers of two diagonally adjacent hexagonal units in the vertical direction.
[0059]
[0060] Since the grid is generated by basis vectors, it is obvious that the grid point set of the same grid may be obtained by multiple groups using different bases. For example, {[h, 0] T , [0, w] T} and {[h,w] T , [h, 2w] T} will generate the same grid. In fact, these two bases can be converted to each other through unimodular matrices. To facilitate understanding, we give its definition and list its properties without proof.
[0061] Definition 4: Let U be a matrix with integer elements. U is called a unimodular matrix if and only if the determinant of U is equal to 1 or -1.
[0062] A unimodular matrix is always invertible, and its inverse is also a unimodular matrix. More generally, an integer inverse exists if and only if an integer matrix is unimodular. The following theorem gives the necessary and sufficient conditions for identifying congruent grids and equivalent bases:
[0063] Theorem 1: Grids L1 and L2 are congruent if and only if there exists a unimodular matrix U such that B1 = B2U, where B1 and B2 are bases of L1 and L2. In this case, B1 and B2 are called equivalent bases.
[0064] prove:
[0065] Given two different bases B1 and B2 for the grid L, and let {b1,b2,…,b n} are n column vectors in B2. Since b i is a basis vector of L, so there exists So that:
[0066] B2=(b1,b2,…,b n )=B1(x1,x2,…,x n )=B1U
[0067] Notice Similarly, existence Make
[0068] B1=B2V
[0069] Right now
[0070] B1=B2V=B1UV
[0071] Therefore
[0072] B1 T B1=(UV) T B1 T B1(UV)
[0073] Taking the determinant on both sides, we get
[0074] det(B1 T B1)=det(V T U T )·det(B1 T B1) det(UV)
[0075] Right now
[0076] [det(UV)] 2 =[det(U)·det(V)] 2 =1
[0077] Observed So det(U), ,so
[0078] det(U)=±1,det(V)=±1
[0079] Therefore, if B1 and B2 are bases of congruent grids, then the transformation matrices U and V are unimodular matrices.
[0080] For the basis B1 of the grid L1 and the basis B2 of the grid L2, there exists a unimodular matrix U such that B2 = B1U. Let {b1, b2, ..., b n} is the column vector of B2. Observe that b i is an integer linear combination of the column vectors in B1, so
[0081]
[0082] Similarly, since the unimodular matrix U is invertible, B1=B2U -1 ,so
[0083]
[0084] So if there exists a unimodular transformation matrix U from B2 to B1, then the grids generated by the two sets of bases are congruent, and the theorem is proved.
[0085] According to the above process, the following inference is given without proof:
[0086] Corollary: For any (L2,BU,+) is a subset of (L1,B,+). L1=L2 if and only if U is a unimodular matrix.
[0087] After defining both hexagonal and rectangular grids using the above method, we hope to find the relationship between hexagonal grids and rectangular grids through inference.
[0088] Naturally, the conversion from hexagonal grid to rectangular grid can be done with B r =Bh U hr Indicates that, so there is
[0089]
[0090] This means that when extracting rectangular subgrids from a hexagonal grid, w1 must be divisible by w2, and h1 must be divisible by 2h2.
[0091] Similarly, from rectangular grid to hexagonal grid, there are
[0092]
[0093] This means that when extracting a hexagonal subgrid from a rectangular grid, w2 must be divisible by 2w1, and h2 must be divisible by h1. Therefore, a hexagonal grid can be considered a subgrid of a rectangular grid, and vice versa. This is the theoretical basis for the present invention's hexagonal data storage solution, which is compatible with rectangular grids.
[0094] Figure 1 FIG. 1 shows a flow chart of a specific embodiment of the present invention. Figure 1 The unified storage calculation method for hexagonal and rectangular grid data includes the following steps:
[0095] S1, uniformly store the hexagonal grid and rectangular grid data in matrix form. If the matrix stores hexagonal grid data, specify the indentation identifier of the first row of pixels in the matrix, and record the format of the hexagonal grid data matrix storage as the indentation format.
[0096] S2 reads image data stored in matrix form. If the image data is hexagonal grid data, for each step in the workflow, if it is a geometric processing task and the output of the previous step is in indented format, the indented format is converted to a double-optimized coordinate format. If it is a statistical task and the output of the previous step is in double-optimized coordinate format, the double-optimized coordinate format is converted to an indented format.
[0097] Algorithms for rectangular grids are categorized into two types: statistical and geometric. The latter can be further divided into topological and metric.
[0098] like Figure 2As shown in the left figure, the indentation format (Offset, OFS) is to store the hexagonal image directly in the form of an array or matrix. Since this scheme only retains the attribute values of the image and discards the geometric information, it is necessary to specify the indentation properties of the first row of pixels in order to losslessly restore the original hexagonal grid image from the array, so it is called the indentation format. This format is suitable for statistical algorithms. Under this format, the hexagonal grid corresponds one-to-one to the elements in a matrix. Therefore, it is the most memory-efficient among all uncompressed algorithms. Since it does not change the number of pixels and does not introduce additional invalid information, the OFS format maintains the statistical properties of the original hexagonal image. Therefore, photometric transformation algorithms, such as grayscale stretching, histogram equalization, and normalization algorithms can be directly executed in the OFS format.
[0099] For geometric algorithms, according to Definitions 2 and 3, the rectangular grid is characterized by aligned elements, while the hexagonal grid is characterized by misaligned elements. Considering the compatibility with the subgrid defined by Equation (4), the rectangular grid is used as a full set to perform data storage and calculations on its hexagonal or rectangular subgrids. There are two existing schemes that meet the equations of the subgrid: Double Width (DW) and Optimized Double Width (ODW). Figure 1 As shown in the right figure, the DW format only retains the data of the square where the purple point is located, and the remaining squares are zero-filled. In the ODW format, a logical pixel is composed of two squares, so it presents a structure similar to a brick wall. Taking into account the spatial coverage and unit neighborhood relationship, the present invention adopts the latter. A rectangular unit composed of two congruent units is logically equivalent to a hexagonal unit, which efficiently expresses the inter-row misalignment property of the hexagonal grid described in equation (3). However, it is noted that there are logically half hexagonal units in the first and last columns, which are zero-filled, which results in the statistical algorithms mentioned in the previous paragraph not being able to be directly executed in the ODW format.
[0100] Topology-related algorithms primarily include spatial encoding algorithms, such as convolution. Metric-related algorithms, on the other hand, include at least those related to resampling. Common grid transformation algorithms are implemented through resampling, and their multi-threaded or GPU-parallel acceleration is achieved through slicing methods provided by PyTorch or NumPy. In addition, other metric-related algorithms, such as rotation, scaling, and affine transformations, can also be implemented through resampling.
[0101] like Figure 2As shown in Figure 1, the conversion from OFS to ODW follows these steps: First, each pixel is replicated once in the row direction. Then, given the indented nature of the first row, odd and even rows are separated, with zero pixels inserted at the beginning or appended at the end, respectively. Finally, the odd and even rows are reconnected. Due to this doubling of pixels, the reverse process is quite simple: starting with the second pixel in each row, slicing is performed with a step size of 1 in the column direction and a step size of 2 in the row direction to convert from ODW to OFS.
[0102] Unified data workflows such as Figure 3 As shown in the figure, the rectangular grid workflow remains unchanged, and the hexagonal grid uses a format compatible with the rectangular grid. The data flow uses the OFS format, and the ODW format is used only when the hexagonal grid involves geometric topological transformations. Figure 2 Format conversion shown.
[0103] Taking nearest neighbor sampling and centroid resampling as examples, this paper illustrates the key issues in the design of a parallel resampling algorithm for hexagonal grids. The algorithm mainly includes two steps: searching for neighborhood data points and parallel interpolation of sampling points.
[0104] First, find the three points closest to the sampling point in the affine coordinate system. Figure 4 As shown, the hexagonal grid points are arranged in a staggered pattern. The positioning points of the original hexagonal grid cells are called "data points," as distinguished from "sampling points." In an affine coordinate system, the data points form an aligned diamond structure, similar to a rectangular grid in an orthogonal coordinate system. First, the diamond where the sampling point is located is found using affine coordinates. The relationship between the horizontal and vertical coordinates of the affine coordinates is then determined to determine whether the sampling point is in the lower left or upper right part of the diamond. This determines the coordinates of the three neighboring points of the sampling point. Nearest neighbor interpolation or centroid interpolation is then performed using the coordinates of the three neighboring points.
[0105] The whole process is as follows: Assume that the geometric coordinates of the sampling point in the orthogonal system are (x p ,y p ), the basis of the hexagonal grid is B h , remember B h =T, then its affine coordinates (i p ,j p )for:
[0106]
[0107] In the affine coordinate system, the coordinates of the grid cell in the upper left corner of the diamond structure where the sampling point is located are:
[0108]
[0109] Determine the upper and lower triangle areas of the rhombus where the sampling point is located, thereby completing the search of the 3-point neighborhood of the sampling point, and giving the geometric coordinates of the 3-point neighborhood {(x i ,y i ) T |i=1, 2, 3}:
[0110]
[0111] Then interpolate. Use n to replace the index of the three points, n = 1, 2, 3. If it is the nearest interpolation, you need to calculate (x, y) to (x n ,y n ) distance:
[0112]
[0113] The grid cell index for the minimum distance:
[0114] v=value(argmin(d i )) (10)
[0115] If it is barycentric interpolation, you need to calculate the area of the triangle formed by the sampling point and the three data points in the neighborhood:
[0116]
[0117] Then perform barycentric interpolation and set the values of the three neighboring points to v1, v2, and v3:
[0118]
[0119] The above steps are the same for each grid cell, so it is a parallel algorithm. Parallel acceleration can be achieved by using the slicing method provided by pytorch or numpy. The above theories and methods have been integrated into Figure 5 The code framework is shown below. To facilitate algorithm expansion, the rectangular image class (Image.py, Class IMAGE) uses the GDAL library to facilitate reading, writing, and visualizing geographic raster data. The hexagonal image class (HexImage.py, Class HEXIMAGE) is a derivative of the rectangular image class. In addition to reading and writing, it also implements format conversion and hexagonal image visualization methods. The core algorithm of the geometry algorithm file (Geometry.py) is the resampling algorithm.
[0120] In a second specific embodiment, a unified storage and computing system for hexagonal and rectangular grid data is provided, the system comprising the following modules:
[0121] A unified storage module is used to uniformly store hexagonal grid and rectangular grid data in matrix form. If the matrix stores hexagonal grid data, the first row of pixel indentation identifiers of the matrix is specified, and the format of the hexagonal grid data matrix storage is recorded as the indentation format.
[0122] Whether it's traditional rectangular grid data or the more complex hexagonal grid data, both can be stored uniformly using a two-dimensional matrix similar to a table. For rectangular grid data, each row and column of the matrix corresponds to a row and column of pixels in the grid. A hexagonal grid is characterized by its hexagonal pixels, with adjacent rows arranged in a staggered pattern similar to a honeycomb. Simply forcing hexagonal grid data into a rectangular matrix can lead to difficulties in data organization, such as complex representation of neighbor relationships. Hexagonal grid data is also stored in a two-dimensional matrix. To indicate that the matrix stores hexagonal grid data and to correctly understand the hexagonal grid arrangement, it is necessary to specify whether the first row of pixels in the matrix needs to be indented. Indentation means that when mapping the hexagonal grid to the rectangular matrix, the pixels in the first row may need to be offset horizontally relative to the rectangular grid arrangement. This is because the rows of the hexagonal grid are staggered. This method, that is, using a matrix to store hexagonal grid data and specifying the first row of pixel indentation identifier, the stored hexagonal grid data format is called the indentation format.
[0123] In another specific embodiment, the hexagonal grid and rectangular grid data are uniformly stored in a matrix form, and an identifier is set. For example, if the identifier is 0, it is a rectangular grid data; if the identifier is 1, it is a hexagonal grid with the first row indented; if the identifier is 2, it is a hexagonal grid with the first row not indented.
[0124] A unified computing module is used to read image data stored in matrix form. If the image data is hexagonal grid data, for each step in the workflow, if it is a geometric processing task and the output of the previous step is in indented format, the indented format is converted to a double-optimized coordinate format. If it is a statistical task and the output of the previous step is in double-optimized coordinate format, the double-optimized coordinate format is converted to an indented format.
[0125] The workflow reads image data stored in matrix format and determines whether the data represents a hexagonal grid, for example, by identifying it by the indentation of the first row of pixels. If the task is geometric processing, the current step converts the data from the indentation format to a double-optimized coordinate format. The double-optimized coordinate format is more suitable for geometric calculations and stores the coordinate information of the hexagonal grid pixels more accurately, facilitating calculations of distances and relationships between adjacent pixels.
[0126] If the current task involves statistical processing, such as calculating the mean, variance, or histogram, and the output data from the previous step is in double-optimized coordinate format, the current step converts the data from double-optimized coordinate format back to indented format. Geometric tasks require more precise coordinate information and therefore convert to double-optimized coordinate format; statistical tasks may focus more on pixel values themselves and therefore convert back to indented format. Data format conversion occurs at every step in the workflow and depends on the current task type and the output format of the previous step.
[0127] Split the image data matrix stored in indented format into two subsets: a matrix containing all odd rows and a matrix containing all even rows. Also, retrieve the first row pixel indent flag stored in the indented format. This flag indicates whether the first row of the original hexagonal grid is indented.
[0128] The first row pixel indent is marked as the first row indent, and a zero pixel is inserted at the beginning of each odd row and a zero pixel is appended at the end of each even row. The modified odd and even rows are reconnected in the order they were in the original matrix to form a matrix in double optimized coordinate format.
[0129] The first row pixel indentation is marked as no indentation of the first row, a zero pixel is inserted at the beginning of each even row, and a zero pixel is appended at the end of each odd row. Similarly, the modified even and odd rows are reconnected in the original order to obtain a matrix in the double optimized coordinate format.
[0130] In one embodiment, a zero pixel is a pixel with a pixel value of 0. In another embodiment, a zero pixel is a placeholder filler value. The rows of the hexagonal grid are staggered, and this can be simulated by adding extra pixels at the beginning or end of odd or even rows so that pixels that are adjacent in the rectangular matrix are more likely to be true neighbors in the hexagonal grid.
[0131] The process of converting hexagonal grid data from double-optimized coordinate format back to indented format is to determine whether the first row is indented or not indented based on the structure of the first and second rows of the double-optimized coordinate matrix. If the first row contains a zero pixel at the beginning and the second row contains a zero pixel at the end, the first row is indented. If the second row contains a zero pixel at the beginning and the first row contains a zero pixel at the end, the first row is not indented.
[0132] When the first row is indented, the first row pixel indent flag is set to the first row indent, the zero pixels at the beginning of all odd rows and the zero pixels at the end of all even rows are deleted, and the odd and even rows after deleting the zero pixels are reconnected in the order they were in the original matrix to obtain a matrix in the indented format.
[0133] When the first row is not indented, the first row pixel indent flag is set to the first row not indented, the zero pixels at the beginning of all even rows and the zero pixels at the end of all odd rows are deleted, and the odd and even rows after deleting the zero pixels are reconnected in the original order to obtain a matrix in the indented format.
[0134] For rectangular grid data, every step in the workflow uses the data in its native matrix format. No conversion from indented to double-optimized coordinate format or vice versa occurs. Geometric and statistical tasks in the workflow continue to function as intended, without requiring any format conversion steps specific to hexagonal grid data. Processing continues in standard matrix format, without any additional format conversion.
[0135] For hexagonal grid data, dynamic conversion between indented and double-optimized coordinate formats is performed based on the task type (geometric or statistical) and the output format of the previous step. Statistical tasks include, but are not limited to, grayscale stretching, histogram equalization, and / or normalization; geometric processing tasks include, but are not limited to, convolution, rotation, scaling, and / or affine transformations.
[0136] Specific embodiment three provides a computer-readable storage medium, and the computer program stored in the computer-readable storage medium implements the method described in specific embodiment one when executed by a processor.
[0137] The above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0138] The steps of the methods or algorithms described in the embodiments of the present application can be directly embedded in hardware, software units executed by a processor, or a combination of the two. The software units can be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or other storage media in any form known in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and write information to the storage medium. Alternatively, the storage medium can also be integrated into the processor. The processor and storage medium can be arranged in an ASIC.
[0139] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0140] Although the present application has been described with reference to specific features and embodiments thereof, it is apparent that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely illustrative of the present application as defined by the appended claims and are deemed to cover any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the scope of the present application. Thus, the present application is intended to include such modifications and variations if they fall within the scope of the claims of the present application and their equivalents.
Claims
1. A unified storage and calculation method for hexagonal and rectangular grid data, characterized in that: The method comprises the following steps: Hexagonal grid and rectangular grid data are uniformly stored in matrix form. If the matrix stores hexagonal grid data, the first row of pixels in the matrix is indented, and the format of the hexagonal grid data matrix storage is recorded as indented format. Read image data stored in matrix form. If the image data is hexagonal grid data, for each step in the workflow, if it is a geometry processing task and the output of the previous step is in indented format, convert the indented format to double-optimized coordinate format. If it is a statistics task and the output of the previous step is in double-optimized coordinate format, convert the double-optimized coordinate format to indented format.
2. The method according to claim 1, wherein The indentation format is converted to the double optimized coordinate format, specifically: Separate the matrix in the indentation format into odd and even rows, and obtain the indentation mark of the first row of pixels in the matrix; If the first row pixel indentation is marked as the first row indentation, zero pixels are inserted at the beginning of the odd rows and zero pixels are appended at the end of the even rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format; If the first row pixel indentation flag is that the first row is not indented, zero pixels are inserted at the beginning of the even rows and zero pixels are appended at the end of the odd rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format.
3. The method according to claim 1, wherein The double optimized coordinate format is converted to the indented format as follows: Determine whether to indent the first line based on the first and second lines in the double-optimized coordinate format; If so, the first row pixel indentation mark is the first row indentation, the zero pixels at the beginning of the odd row are deleted, the zero pixels at the end of the even row are deleted, and the odd and even rows are reconnected to obtain the indentation format; Otherwise, the first row pixel indentation mark is that the first row is not indented, the zero pixels at the beginning of the even row are deleted, the zero pixels at the end of the odd row are deleted, and the odd and even rows are reconnected to obtain the indentation format.
4. The method according to claim 1, wherein After reading the image data stored in the matrix form, the method further includes: If the image data is rectangular grid data, the workflow processing remains unchanged.
5. The method according to claim 1, wherein The statistical tasks include grayscale stretching, histogram equalization and / or normalization; the geometric processing tasks include convolution, rotation, scaling and / or affine transformation.
6. A unified storage and computing system for hexagonal and rectangular grid data, characterized in that: The system includes the following modules: A unified storage module is used to uniformly store hexagonal grid and rectangular grid data in a matrix format. If the matrix stores hexagonal grid data, the first row of pixel indentation identifiers of the matrix is specified, and the format of the hexagonal grid data matrix storage is recorded as the indentation format. A unified computing module is used to read image data stored in matrix form. If the image data is hexagonal grid data, for each step in the workflow, if it is a geometric processing task and the output of the previous step is in indented format, the indented format is converted to a double-optimized coordinate format. If it is a statistical task and the output of the previous step is in double-optimized coordinate format, the double-optimized coordinate format is converted to an indented format.
7. The system according to claim 6, wherein: The indentation format is converted to the double optimized coordinate format, specifically: Separate the matrix in the indentation format into odd and even rows, and obtain the indentation mark of the first row of pixels in the matrix; If the first row pixel indentation is marked as the first row indentation, zero pixels are inserted at the beginning of the odd rows and zero pixels are appended at the end of the even rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format; If the first row pixel indentation flag is that the first row is not indented, zero pixels are inserted at the beginning of the even rows and zero pixels are appended at the end of the odd rows, and the odd and even rows are reconnected to obtain a double optimized coordinate format.
8. The system according to claim 6, wherein: The double optimized coordinate format is converted to the indented format as follows: Determine whether to indent the first line based on the first and second lines in the double-optimized coordinate format; If so, the first row pixel indentation mark is the first row indentation, the zero pixels at the beginning of the odd row are deleted, the zero pixels at the end of the even row are deleted, and the odd and even rows are reconnected to obtain the indentation format; Otherwise, the first row pixel indentation mark is that the first row is not indented, the zero pixels at the beginning of the even row are deleted, the zero pixels at the end of the odd row are deleted, and the odd and even rows are reconnected to obtain the indentation format.
9. The system according to claim 6, wherein: After reading the image data stored in the matrix form, the method further includes: If the image data is rectangular grid data, the workflow processing remains unchanged.
10. The system according to claim 6, wherein: The statistical tasks include grayscale stretching, histogram equalization and / or normalization; the geometric processing tasks include convolution, rotation, scaling and / or affine transformation.