CN108648136B - Method and device for compressing two-dimensional lookup table - Google Patents

Method and device for compressing two-dimensional lookup table Download PDF

Info

Publication number
CN108648136B
CN108648136B CN201810175611.8A CN201810175611A CN108648136B CN 108648136 B CN108648136 B CN 108648136B CN 201810175611 A CN201810175611 A CN 201810175611A CN 108648136 B CN108648136 B CN 108648136B
Authority
CN
China
Prior art keywords
lookup table
dimensional lookup
grid
value
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810175611.8A
Other languages
Chinese (zh)
Other versions
CN108648136A (en
Inventor
艾韬
张基隆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Visionertech Co ltd
Original Assignee
Visionertech Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Visionertech Co ltd filed Critical Visionertech Co ltd
Priority to CN201810175611.8A priority Critical patent/CN108648136B/en
Publication of CN108648136A publication Critical patent/CN108648136A/en
Application granted granted Critical
Publication of CN108648136B publication Critical patent/CN108648136B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/28Indexing scheme for image data processing or generation, in general involving image processing hardware

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention discloses a method and a device for compressing a two-dimensional lookup table, wherein the method comprises the following steps: acquiring a two-dimensional lookup table to be compressed, wherein the two-dimensional lookup table comprises N rows multiplied by N columns of nodes; dividing the two-dimensional lookup table into a plurality of grid areas according to the preset grid size, wherein the number of nodes contained in each grid area is equal; aiming at each grid region, calculating a central value corresponding to the grid region according to a preset central value calculation formula; calculating a difference value between the node value and the central value of each node, judging whether the difference value is smaller than a preset difference value threshold value, if so, combining the nodes contained in the grid area to obtain a combined first node, and calling the central value as the node value of the first node; and replacing the nodes contained in the grid area with the first nodes in the two-dimensional lookup table so as to compress the two-dimensional lookup table. The invention can improve the compression rate of the two-dimensional lookup table and improve the compression precision of the two-dimensional lookup table.

Description

Method and device for compressing two-dimensional lookup table
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for compressing a two-dimensional lookup table.
Background
In computer science, a lookup table is a data structure such as an array or an associative array calculated in the runtime is replaced by a simple query operation, so that complicated calculation is avoided, and the corresponding speed is improved. However, when storing the corresponding lookup table, a corresponding storage space is required for storage. For example, in digital image processing using an HDR (High-Dynamic Range) optical response characteristic curve, when a two-dimensional lookup table is to be created for one 1080 × 1080 graph, 1080 × 1080 × 32 ═ 4.7MB of storage space resources must be used.
However, the FPGA (Field-Programmable Gate Array) has been widely used in aspects of communication, image processing, industrial control, etc. due to its fast and efficient processing capability, but, similarly, the FPGA resource is very limited, and not all processing can be realized by the FPGA. The two-dimensional lookup table can avoid complicated calculation, but has a large requirement on a storage space. In order to realize the lookup of the two-dimensional table on the FPGA, the two-dimensional lookup table needs to be compressed. In the prior art, in order to implement mapping of a huge two-dimensional lookup table in limited FPGA resources, part of calculation accuracy is sacrificed, that is, the accuracy of the two-dimensional lookup table is reduced to reduce the requirement of the two-dimensional lookup table on a storage space, so that the mapping can be implemented on an FPGA.
Therefore, the prior art has the problem of low precision in the compression of the two-dimensional lookup table.
Disclosure of Invention
Therefore, in order to solve the technical problem of insufficient precision in the scheme of compressing the two-dimensional lookup table in the traditional technology, a method for compressing the two-dimensional lookup table is particularly provided.
A method of compressing a two-dimensional lookup table, comprising:
acquiring a two-dimensional lookup table to be compressed, wherein the two-dimensional lookup table comprises N rows multiplied by M columns of nodes;
dividing nodes contained in the two-dimensional lookup table according to the size of a preset grid, and dividing the two-dimensional lookup table into a plurality of grid areas, wherein the number of the nodes contained in each grid area is equal;
aiming at each grid area obtained by division, calculating a central value corresponding to the grid area according to a preset central value calculation formula by using node values of all nodes contained in the grid area; calculating a difference value between the node value of each node and the central value, judging whether the difference value is smaller than a preset difference value threshold value, if so, combining the nodes contained in the grid area to obtain a combined first node, and calling the central value as the node value of the first node; and replacing the nodes contained in the grid area with the first nodes in the two-dimensional lookup table so as to compress the two-dimensional lookup table.
Optionally, in one embodiment, the calculating, according to a preset central value calculation formula, a central value corresponding to the grid area according to the node values of all nodes included in the grid area further includes:
interpolating all nodes contained in the grid area according to a preset bilinear interpolation formula to obtain a bilinear interpolation function;
and calculating a central value corresponding to the grid area by taking the intermediate values of the row coordinates and the column coordinates of all nodes contained in the grid area as arguments according to the bilinear interpolation function.
Optionally, in one embodiment, after obtaining the two-dimensional lookup table to be compressed, the method further includes:
judging whether the row number N and the column number M of the two-dimensional lookup table are equal and are power of 2, if not, expanding the two-dimensional lookup table to L rows and L columns, wherein L is the minimum value which is greater than or equal to N and M and is the power of 2, and the node value corresponding to the expanded node is 0;
and taking the expanded two-dimensional lookup table as a new two-dimensional lookup table, and executing the division of the nodes contained in the two-dimensional lookup table according to the preset grid size.
Optionally, in one embodiment, the dividing the nodes included in the two-dimensional lookup table according to a preset mesh size, and dividing the two-dimensional lookup table into a plurality of mesh regions further includes:
and dividing the two-dimensional lookup table into a plurality of grid areas according to the grid size of 2 x 2, wherein each grid area comprises 4 nodes with 2 rows and 2 columns.
Optionally, in one embodiment, the determining whether the difference is smaller than a preset difference threshold further includes:
acquiring a first difference threshold corresponding to the grid area, wherein the first difference threshold corresponds to a gradient value of the grid area in the two-dimensional lookup table;
and judging whether the calculated difference is smaller than the first difference threshold value, and under the condition that the calculated difference is smaller than the first difference threshold value, judging that the difference is smaller than a preset difference threshold value, otherwise, judging that the difference is not smaller than the preset difference threshold value.
In addition, in order to solve the technical problem of insufficient precision in the scheme of compressing the two-dimensional lookup table in the traditional technology, a device for compressing the two-dimensional lookup table is also provided.
An apparatus for compressing a two-dimensional lookup table, comprising:
the two-dimensional lookup table acquisition module is used for acquiring a two-dimensional lookup table to be compressed, and the two-dimensional lookup table comprises N rows multiplied by M columns of nodes;
the grid division module is used for dividing the nodes contained in the two-dimensional lookup table according to the preset grid size and dividing the two-dimensional lookup table into a plurality of grid areas, wherein the number of the nodes contained in each grid area is equal;
the grid compression module is used for calculating a central value corresponding to each grid area by using node values of all nodes contained in the grid area according to a preset central value calculation formula aiming at each grid area obtained by division; calculating a difference value between the node value of each node and the central value, judging whether the difference value is smaller than a preset difference value threshold value, if so, combining the nodes contained in the grid area to obtain a combined first node, and calling the central value as the node value of the first node; and replacing the nodes contained in the grid area with the first nodes in the two-dimensional lookup table so as to compress the two-dimensional lookup table.
Optionally, in one embodiment, the apparatus further includes a table expansion module, configured to determine whether a number N of rows and a number M of columns of the two-dimensional lookup table are equal to each other and are power of 2, if not, expand the two-dimensional lookup table to L rows and L columns, where L is a minimum value that is greater than or equal to N and M and is the power of 2, and a node value corresponding to an expanded node is 0; taking the expanded two-dimensional lookup table as a new two-dimensional lookup table, and executing the division of the nodes contained in the two-dimensional lookup table according to the preset grid size;
the grid division module is further configured to divide the two-dimensional lookup table into a plurality of grid regions according to a 2 × 2 grid size, where each grid region includes 4 nodes in 2 rows and 2 columns.
Optionally, in one embodiment, the grid compression module is further configured to obtain a first difference threshold corresponding to the grid region, where the first difference threshold corresponds to a gradient value of the grid region in the two-dimensional lookup table; and judging whether the calculated difference is smaller than the first difference threshold value, and under the condition that the calculated difference is smaller than the first difference threshold value, judging that the difference is smaller than a preset difference threshold value, otherwise, judging that the difference is not smaller than the preset difference threshold value.
In another aspect of the present invention, an application of the method for compressing the two-dimensional lookup table as described above by using an FPGA is also provided.
The embodiment of the invention has the following beneficial effects:
after the method and the device for compressing the two-dimensional lookup table are adopted, for the two-dimensional lookup table with the super-large dimension, the two-dimensional lookup table is divided into a plurality of grid areas, whether the grid area is compressed or not is determined according to the difference value between specific values of nodes contained in each grid area, the loss of the unified compression precision to the overall precision of the two-dimensional lookup table is avoided, the compression precision for compressing the two-dimensional lookup table is improved, the size of an address space required by the two-dimensional lookup table is reduced, and therefore the method and the device can be realized on a limited FPGA device.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Wherein:
FIG. 1 is a flow diagram illustrating a method for compressing a two-dimensional lookup table, according to one embodiment;
FIG. 2 is a Comparagram spatial histogram in one embodiment;
FIG. 3 is a two-dimensional lookup table meshing diagram in one embodiment;
FIG. 4 is a diagram illustrating node values within a grid area in one embodiment;
FIG. 5 is a diagram illustrating node values within a grid area in one embodiment;
FIG. 6 is a diagram illustrating compression of a two-dimensional lookup table in one embodiment;
FIG. 7 is a circuit diagram of an FPGA implementation after compression of the two-dimensional lookup table shown in FIG. 7;
FIG. 8 is a block diagram of an apparatus for compressing a two-dimensional lookup table according to an embodiment.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
To solve the technical problem of insufficient precision in the scheme for compressing the two-dimensional lookup table in the conventional technology, in the present embodiment, a method for compressing the two-dimensional lookup table is specifically proposed, which can be implemented by depending on a computer program which can run on a computer system based on the von neumann architecture, and the computer program can be an application program for compressing the two-dimensional lookup table. The computer system may be a server device such as a smart phone, a tablet computer, a personal computer, etc. running the computer program.
It should be noted that, in this embodiment, the implementation of the method for compressing the two-dimensional lookup table may be based on a PC or other devices. That is, the two-dimensional lookup table is compressed on a computer device such as a PC, and after the compression is completed, the two-dimensional lookup table can be used for FPGA implementation.
Specifically, as shown in fig. 1, the method for compressing the two-dimensional lookup table includes the following steps S102 to S106:
step S102: and acquiring a two-dimensional lookup table to be compressed, wherein the two-dimensional lookup table comprises N rows and M columns of nodes.
In this embodiment, when the two-dimensional lookup table needs to be compressed, the two-dimensional lookup table that needs to be compressed is sent to the corresponding computer device to be implemented by the corresponding computer program, for example, the corresponding application program that compresses the two-dimensional lookup table is opened, and the two-dimensional lookup table that needs to be compressed (i.e., the two-dimensional lookup table to be compressed) is obtained, so that the two-dimensional lookup table can be compressed.
In this embodiment, the two-dimensional lookup table is a table data/two-dimensional array composed of N rows and M columns of nodes, and each node includes a corresponding row coordinate, a corresponding column coordinate, and a corresponding node value. For example, the two-dimensional look-up table is defined as follows:
reg[31:0]data_z[addr_y:0][addr_x:0];
or, in another alternative embodiment, in the case of mapping with a three-dimensional cartesian coordinate system, the address of the two-dimensional lookup table is the plane coordinate (addr _ y, addr _ x), and the data of the corresponding address mapping is the data _ z.
For example, in one embodiment, in the case that the two-dimensional lookup table corresponds to a Comparagram space histogram (as shown in fig. 2), Comparagram is a pixel value of an image from different exposures of the same scene in image processing, and corresponds to a two-dimensional array consisting of pixel values corresponding to nodes of several rows and several columns. Since the surface function is stored in a discretized manner, the minimum step of each dimension of the two-dimensional plane ((addr _ y, addr _ x) is 1, and the function value corresponding to the index address (addr _ x, addr _ y) is data _ z.
Step S104: and dividing the nodes contained in the two-dimensional lookup table according to the preset grid size, and dividing the two-dimensional lookup table into a plurality of grid areas, wherein the number of the nodes contained in each grid area is equal.
In this embodiment, when compressing the two-dimensional lookup table, firstly, the two-dimensional lookup table needs to be divided into grid regions, and then, whether compression is needed and a corresponding compression strategy are determined in regions according to specific situations of each grid region.
Specifically, in this embodiment, the grid size may be defined in advance, for example, the grid size is defined to be 2 × 2 or 3 × 3, and the specific situation may be determined according to the requirement of the user on the precision. The larger the grid division is, the larger the corresponding compression rate is, and the smaller the precision is; correspondingly, the smaller the meshing is, the smaller the corresponding compression rate is, and the higher the precision is.
For example, in the application scenario shown in fig. 3, a node in the two-dimensional lookup table corresponds to a grid in fig. 3, and the two-dimensional lookup table is a two-dimensional array of 16 rows by 16 columns. Under the condition that the preset grid size is 2 multiplied by 2, the two-dimensional lookup table is divided into 16 grid areas, wherein each grid area comprises 4 grids or nodes corresponding to 2 rows and 2 columns.
Step S106 is a compression step for each mesh region, which specifically includes:
for each divided grid region, executing the following step S
Step S1061: calculating a central value corresponding to the grid area according to a preset central value calculation formula by using node values of all nodes contained in the grid area;
step S1062: calculating a difference value of the node value of each node from the center value,
step S1063: judging whether the difference value is smaller than a preset difference value threshold value or not;
if yes, go to step S10641: merging the nodes contained in the grid area to obtain a merged first node, and setting the central value as a node value of the first node;
step S10642: replacing the nodes contained in the grid area with first nodes in the two-dimensional lookup table so as to compress the two-dimensional lookup table;
if not, go to step S1065: no treatment is done.
In specific implementation, in order to ensure the compression precision in the two-dimensional lookup table compression process, the compression performed on the two-dimensional lookup table is divided into compression of a plurality of grid areas, and the compression is performed on each grid area in a case-by-case manner.
Specifically, for each grid region, whether to merge multiple nodes in the grid region is determined according to whether there is a large difference between node values corresponding to multiple nodes included in the grid region, that is, one node is used to replace multiple nodes to reduce the requirement for a storage space.
In this embodiment, the process of determining whether there is a large difference between a plurality of nodes included in one grid area may be implemented by:
calculating central values corresponding to a plurality of nodes contained in the grid area, and then judging whether the difference value between each node value and the central value is small enough, if so, determining that the corresponding difference is small, otherwise, determining that the difference is large and the nodes cannot be combined.
The calculation of the center value may be performed in various ways.
First, a corresponding center value may be calculated by calculating an average value of node values of a plurality of nodes;
secondly, the central values corresponding to the node values of the plurality of nodes can be calculated through a preset central value calculation formula;
thirdly, a corresponding interpolation function may be calculated with node values of a plurality of nodes through a preset interpolation formula, and then a corresponding center value may be calculated through the interpolation function.
In a specific embodiment, the calculation of the interpolation function may be calculated by: interpolating all nodes contained in the grid area according to a preset bilinear interpolation formula to obtain a bilinear interpolation function; and calculating a central value corresponding to the grid area by taking the intermediate values of the row coordinates and the column coordinates of all nodes contained in the grid area as arguments according to the bilinear interpolation function.
For example, in the case that each grid region shown in fig. 3 includes 4 nodes, a bilinear interpolation formula may be used to calculate a corresponding interpolation function, and a corresponding center value may be calculated.
Specifically, the bilinear interpolation function is as follows:
Figure GDA0003407257450000071
as shown in fig. 4, 4 nodes included in the mesh node are shown in fig. 4, and the corresponding nodes are:
data_z(addr_x,addr_y)=3.5;
data_z(addr_x,addr_y+1)=4;
data_z(addr_x+1,addr_y)=3.8;
data_z(addr_x+1,addr_y+1)=3.7;
substituting the node values corresponding to the 4 nodes into a bilinear interpolation function, and then substituting the corresponding central value data _ zquadtreeWherein:
data_zquadtree=f(x+0.5,y+0.5)。
in this embodiment, it is also necessary to determine whether there is a large difference between each node value and the center value. In an alternative embodiment, the determination may be made by whether a difference value between the node value and the center value is less than a preset value.
For example, in the application scenario shown in fig. 4, the corresponding difference threshold may be set to 0.3, i.e., the difference threshold E is 0.3. The difference between each node and the center value is then calculated as follows:
|data_z(addr_x,addr_y+1)-data_z(addr_x+0.5,addr_y+0.5)|=|4-3.75|=0.25<E
|data_z(addr_x+1,addr_y+1)-data_z(addr_x+0.5,addr_y+0.5)|=|3.7-3.75|=0.05<E
|data_z(addr_x,addr_y)-data_z(addr_x+0.5,addr_y+0.5)|=|3.5-3.75|=0.25<E
|data_z(addr_x+1,addr_y)-data_z(addr_x+0.5,addr_y+0.5)|=|3.8-3.75|=0.05<E
it can be known that, when the difference value between each node value and the center value is less than the preset difference threshold value of 0.3, the grid areas where the 4 points are located can be combined into one node.
In another alternative embodiment, as shown in fig. 5, the corresponding nodes are:
data_z(addr_x,addr_y)=3.2;
data_z(addr_x,addr_y+1)=4.3;
data_z(addr_x+1,addr_y)=4.1;
data_z(addr_x+1,addr_y+1)=3.6;
after the corresponding bilinear difference formula is obtained through calculation, the corresponding central value data _ z can be obtained through calculationquadtree=f(x+0.5,y+0.5)=3.8。
In the case where the difference threshold is set equal to 0.3, the difference between each node value and the center value is calculated as follows:
|data_z(addr_x,addr_y+1)-data_z(addr_x+0.5,addr_y+0.5)|=|4.3-3.8|=0.5>E
|data_z(addr_x+1,addr_y+1)-data_z(addr_x+0.5,addr_y+0.5)|=|3.6-3.8|=0.2<E
|data_z(addr_x,addr_y)-data_z(addr_x+0.5,addr_y+0.5)|=|3.2-3.8|=0.6>E
|data_z(addr_x+1,addr_y)-data_z(addr_x+0.5,addr_y+0.5)|=|4.1-3.8|=0.3=E
it can be seen that, in the difference values between the node values and the center values of the 4 nodes, there is a case where the difference value is greater than the preset difference value threshold E, and therefore, the 4 nodes cannot be merged and must be all reserved.
In another alternative embodiment, whether the nodes in the grid area need to be merged may be determined by calculating whether the variance or standard deviation between the node value and the center value of each node is smaller than a preset threshold.
Further, in this embodiment, when merging a plurality of nodes in a mesh area, the plurality of nodes are merged into 1 node, and the center value of the mesh area is used as the node value of a new node after merging the mesh area.
That is, in the case where a plurality of nodes in a grid area can be merged, the plurality of nodes in the grid area can be replaced by 1 node (for example, in the case of a grid size of 2 × 2, the size of the occupied grid is reduced from 4 to 1), and the occupation of the storage space is greatly reduced.
It should be noted that, the node values in different grid regions are different from each other in terms of their difference, and the precision requirements of the values in different grid regions by the user are different from each other, so that if the same difference threshold is used for all grid regions, the precision of the values in the partial regions may be affected. In order to improve both the compression rate and the accuracy, in this embodiment, the corresponding difference threshold may be determined according to the variation gradient of different regions of the two-dimensional lookup table.
Specifically, in an optional embodiment, the determining whether the difference is smaller than a preset difference threshold further includes: acquiring a first difference threshold corresponding to the grid area, wherein the first difference threshold corresponds to a gradient value of the grid area in the two-dimensional lookup table; and judging whether the calculated difference is smaller than the first difference threshold value, and under the condition that the calculated difference is smaller than the first difference threshold value, judging that the difference is smaller than a preset difference threshold value, otherwise, judging that the difference is not smaller than the preset difference threshold value.
In this embodiment, the corresponding difference threshold may be determined according to a change gradient of a node value corresponding to each node included in the two-dimensional lookup table, for example, a smaller difference threshold E is used for an area where a change gradient of the node value is obvious, and a larger difference threshold E is used for an area where a change gradient of the node value is not obvious.
In another optional embodiment, a smaller difference threshold may be adopted for an area with a higher use frequency according to the requirement of a user, so as to improve the accuracy of numerical value search; a larger difference threshold is used for areas that are used less frequently to reduce the need for storage space.
In this embodiment, the setting of the difference threshold may be determined according to a preset algorithm after calculating the change gradient value of the node value of the two-dimensional lookup table, or may be set by the user according to the requirement of the user.
It should be noted that, in this embodiment, when performing mesh division, the setting of the mesh size may result in a situation where the two-dimensional lookup table cannot be completely divided, and in this situation, before performing mesh division, the two-dimensional lookup table needs to be expanded to a size matching the preset mesh size.
For example, when the size of the grid is 2 × 2, the number of rows and columns of the two-dimensional lookup table is preferably an nth power of 2, i.e., the number of rows and columns is a power of 2, so as to ensure complete division of the size of the grid.
That is, after the obtaining of the two-dimensional lookup table to be compressed, the method further includes: judging whether the row number N and the column number M of the two-dimensional lookup table are equal and are power of 2, if not, expanding the two-dimensional lookup table to L rows and L columns, wherein L is the minimum value which is greater than or equal to N and M and is the power of 2, and the node value corresponding to the expanded node is 0; and taking the expanded two-dimensional lookup table as a new two-dimensional lookup table, and executing the division of the nodes contained in the two-dimensional lookup table according to the preset grid size.
In this embodiment, the compression of the two-dimensional lookup table may be performed not only once for the mesh region, but also for the second, third, and nth times after the compression of the mesh region is performed once for the two-dimensional lookup table after the compression is performed once.
Specifically, as shown in fig. 6, after the mesh region is compressed once, the second compression may be continued to further improve the compression rate.
In this embodiment, the implementation of the two-dimensional lookup table is divided into two steps, the first step is to compress the two-dimensional lookup table, the completion of this part of the work can be implemented on the PC side, and the second step is to implement the two-dimensional lookup table after compression on the PC side based on the FPGA.
For example, for the results after compression shown in FIG. 6, the circuitry of its corresponding mapped FPGA can be as shown in FIG. 7. That is, the compression result of the two-dimensional lookup table shown in fig. 6 can be realized based on the FPGA circuit shown in fig. 6, thereby realizing the compression ratio of the two-dimensional lookup table, the calculation accuracy, and the fast and efficient lookup efficiency thereof realized on the FPGA.
In addition, in order to solve the technical problem of insufficient precision in the scheme of compressing the two-dimensional lookup table in the conventional technology, in one embodiment, as shown in fig. 8, an apparatus for compressing the two-dimensional lookup table is further provided, which includes:
a two-dimensional lookup table obtaining module 102, configured to obtain a two-dimensional lookup table to be compressed, where the two-dimensional lookup table includes N rows × M columns of nodes;
the grid division module 104 is configured to divide the nodes included in the two-dimensional lookup table according to a preset grid size, and divide the two-dimensional lookup table into a plurality of grid regions, where the number of nodes included in each grid region is equal;
a mesh compression module 106, configured to calculate, for each mesh region obtained by the division, a center value corresponding to the mesh region according to a preset center value calculation formula and node values of all nodes included in the mesh region; calculating a difference value between the node value of each node and the central value, judging whether the difference value is smaller than a preset difference value threshold value, if so, combining the nodes contained in the grid area to obtain a combined first node, and calling the central value as the node value of the first node; and replacing the nodes contained in the grid area with the first nodes in the two-dimensional lookup table so as to compress the two-dimensional lookup table.
Optionally, in an embodiment, the grid compression module 106 is further configured to interpolate all nodes included in the grid region according to a preset bilinear interpolation formula to obtain a bilinear interpolation function; and calculating a central value corresponding to the grid area by taking the intermediate values of the row coordinates and the column coordinates of all nodes contained in the grid area as arguments according to the bilinear interpolation function.
Optionally, in an embodiment, as shown in fig. 8, the apparatus further includes a table expanding module 108, configured to determine whether a row number N and a column number M of the two-dimensional lookup table are equal and are power of 2, if not, expand the two-dimensional lookup table to L rows and L columns, where L is a minimum value that is greater than or equal to N and M and is power of 2, and a node value corresponding to an expanded node is 0; taking the expanded two-dimensional lookup table as a new two-dimensional lookup table, and executing the division of the nodes contained in the two-dimensional lookup table according to the preset grid size; the grid division module 104 is further configured to divide the two-dimensional lookup table into a plurality of grid regions according to a 2 × 2 grid size, where each grid region includes 4 nodes in 2 rows and 2 columns.
Optionally, in an embodiment, the grid compression module 106 is further configured to obtain a first difference threshold corresponding to the grid region, where the first difference threshold corresponds to a gradient value of the grid region in the two-dimensional lookup table; and judging whether the calculated difference is smaller than the first difference threshold value, and under the condition that the calculated difference is smaller than the first difference threshold value, judging that the difference is smaller than a preset difference threshold value, otherwise, judging that the difference is not smaller than the preset difference threshold value.
The embodiment of the invention has the following beneficial effects:
after the method and the device for compressing the two-dimensional lookup table are adopted, for the two-dimensional lookup table with the super-large dimension, the two-dimensional lookup table is divided into a plurality of grid areas, whether the grid area is compressed or not is determined according to the difference value between specific values of nodes contained in each grid area, the loss of the unified compression precision to the overall precision of the two-dimensional lookup table is avoided, the compression precision for compressing the two-dimensional lookup table is improved, the size of an address space required by the two-dimensional lookup table is reduced, and therefore the method and the device can be realized on a limited FPGA device.
In the above embodiments, all or part of the implementation may be realized by software, hardware, firmware, or any combination thereof. When implemented using a software program, may 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 loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (10)

1. A method of compressing a two-dimensional lookup table, comprising:
acquiring a two-dimensional lookup table to be compressed, wherein the two-dimensional lookup table comprises N rows multiplied by M columns of nodes;
dividing nodes contained in the two-dimensional lookup table according to the size of a preset grid, and dividing the two-dimensional lookup table into a plurality of grid areas, wherein the number of the nodes contained in each grid area is equal;
aiming at each grid area obtained by division, calculating a central value corresponding to the grid area according to a preset central value calculation formula by using node values of all nodes contained in the grid area; calculating a difference value between the node value of each node and the central value, judging whether the difference value is smaller than a preset difference value threshold value, if so, combining the nodes contained in the grid area to obtain a combined first node, and taking the central value as the node value of the first node; and replacing all nodes contained in the grid area with the first nodes corresponding to the grid area in the two-dimensional lookup table so as to compress the two-dimensional lookup table.
2. The method according to claim 1, wherein the step of calculating the center value corresponding to the grid area according to a preset center value calculation formula with the node values of all the nodes included in the grid area further comprises:
interpolating all nodes contained in the grid area according to a preset bilinear interpolation formula to obtain a bilinear interpolation function;
and calculating a central value corresponding to the grid area by taking the intermediate values of the row coordinates and the column coordinates of all nodes contained in the grid area as arguments according to the bilinear interpolation function.
3. The method of claim 1, wherein after obtaining the two-dimensional lookup table to be compressed, the method further comprises:
judging whether the row number N and the column number M of the two-dimensional lookup table are equal and are power of 2, if not, expanding the two-dimensional lookup table to L rows and L columns, wherein L is the minimum value which is greater than or equal to N and M and is the power of 2, and the node value corresponding to the expanded node is 0;
and taking the expanded two-dimensional lookup table as a new two-dimensional lookup table, and executing the division of the nodes contained in the two-dimensional lookup table according to the preset grid size.
4. The method of claim 3, wherein the dividing the nodes included in the two-dimensional lookup table according to the preset mesh size divides the two-dimensional lookup table into a plurality of mesh regions, further comprising:
and dividing the two-dimensional lookup table into a plurality of grid areas according to the grid size of 2 x 2, wherein each grid area comprises 4 nodes with 2 rows and 2 columns.
5. The method of claim 3, wherein the determining whether the difference is less than a predetermined difference threshold further comprises:
acquiring a first difference threshold corresponding to the grid area, wherein the first difference threshold corresponds to a gradient value of the grid area in the two-dimensional lookup table;
and judging whether the calculated difference is smaller than the first difference threshold value, and under the condition that the calculated difference is smaller than the first difference threshold value, judging that the difference is smaller than a preset difference threshold value, otherwise, judging that the difference is not smaller than the preset difference threshold value.
6. An apparatus for compressing a two-dimensional lookup table, comprising:
the two-dimensional lookup table acquisition module is used for acquiring a two-dimensional lookup table to be compressed, and the two-dimensional lookup table comprises N rows multiplied by M columns of nodes;
the grid division module is used for dividing the nodes contained in the two-dimensional lookup table according to the preset grid size and dividing the two-dimensional lookup table into a plurality of grid areas, wherein the number of the nodes contained in each grid area is equal;
the grid compression module is used for calculating a central value corresponding to each grid area by using node values of all nodes contained in the grid area according to a preset central value calculation formula aiming at each grid area obtained by division; calculating a difference value between the node value of each node and the central value, judging whether the difference value is smaller than a preset difference value threshold value, if so, combining the nodes contained in the grid area to obtain a combined first node, and calling the central value as the node value of the first node; and replacing all nodes contained in the grid area with the first nodes corresponding to the grid area in the two-dimensional lookup table so as to compress the two-dimensional lookup table.
7. The apparatus according to claim 6, wherein the mesh compression module is further configured to interpolate all nodes included in the mesh region according to a preset bilinear interpolation formula to obtain a bilinear interpolation function; and calculating a central value corresponding to the grid area by taking the intermediate values of the row coordinates and the column coordinates of all nodes contained in the grid area as arguments according to the bilinear interpolation function.
8. The apparatus of claim 6, further comprising a table expansion module, configured to determine whether the number of rows N and the number of columns M of the two-dimensional lookup table are equal to each other and are a power of 2, and if not, expand the two-dimensional lookup table to L rows and L columns, where L is a minimum value that is greater than or equal to N and M and is a power of 2, and a node value corresponding to an expanded node is 0; taking the expanded two-dimensional lookup table as a new two-dimensional lookup table, and executing the division of the nodes contained in the two-dimensional lookup table according to the preset grid size;
the grid division module is further configured to divide the two-dimensional lookup table into a plurality of grid regions according to a 2 × 2 grid size, where each grid region includes 4 nodes in 2 rows and 2 columns.
9. The apparatus according to any of claims 6 to 8, wherein the grid compression module is further configured to obtain a first difference threshold corresponding to the grid region, and the first difference threshold corresponds to a gradient value of the grid region in the two-dimensional lookup table; and judging whether the calculated difference is smaller than the first difference threshold value, and under the condition that the calculated difference is smaller than the first difference threshold value, judging that the difference is smaller than a preset difference threshold value, otherwise, judging that the difference is not smaller than the preset difference threshold value.
10. An FPGA device implementing the method of compressing a two-dimensional lookup table of any one of claims 1-5.
CN201810175611.8A 2018-03-02 2018-03-02 Method and device for compressing two-dimensional lookup table Active CN108648136B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810175611.8A CN108648136B (en) 2018-03-02 2018-03-02 Method and device for compressing two-dimensional lookup table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810175611.8A CN108648136B (en) 2018-03-02 2018-03-02 Method and device for compressing two-dimensional lookup table

Publications (2)

Publication Number Publication Date
CN108648136A CN108648136A (en) 2018-10-12
CN108648136B true CN108648136B (en) 2022-04-15

Family

ID=63744159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810175611.8A Active CN108648136B (en) 2018-03-02 2018-03-02 Method and device for compressing two-dimensional lookup table

Country Status (1)

Country Link
CN (1) CN108648136B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112907664B (en) * 2021-02-08 2023-04-25 明峰医疗系统股份有限公司 Image pixel position searching method, system and computer readable storage medium
TWI780696B (en) 2021-05-10 2022-10-11 創鑫智慧股份有限公司 Look-up table compression method and look-up table reading method and computation equipment, host and device thereof

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751897A (en) * 2008-12-10 2010-06-23 扬智科技股份有限公司 Lookup table compression and decompression method and relevant device thereof
CN106682366A (en) * 2017-02-04 2017-05-17 哈尔滨工大泰铭科技有限公司 Method for extracting finite element node coordinates based on image processing
EP3267672A1 (en) * 2016-07-08 2018-01-10 Hewlett-Packard Development Company L.P. Color look up table compression

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6757438B2 (en) * 2000-02-28 2004-06-29 Next Software, Inc. Method and apparatus for video compression using microwavelets

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751897A (en) * 2008-12-10 2010-06-23 扬智科技股份有限公司 Lookup table compression and decompression method and relevant device thereof
EP3267672A1 (en) * 2016-07-08 2018-01-10 Hewlett-Packard Development Company L.P. Color look up table compression
CN106682366A (en) * 2017-02-04 2017-05-17 哈尔滨工大泰铭科技有限公司 Method for extracting finite element node coordinates based on image processing

Also Published As

Publication number Publication date
CN108648136A (en) 2018-10-12

Similar Documents

Publication Publication Date Title
US11321423B2 (en) Operation accelerator
TWI694381B (en) Image processing method and device
US20200218509A1 (en) Multiplication Circuit, System on Chip, and Electronic Device
CN111966649B (en) Lightweight online file storage method and device capable of efficiently removing weight
TWI694700B (en) Data processing method and device, user terminal
CN111079917A (en) Tensor data block access method and device
CN108648136B (en) Method and device for compressing two-dimensional lookup table
CN116227209A (en) Multi-dimensional linear difference method for point cloud data, terminal equipment and storage medium
WO2023093721A1 (en) Resource recall method and apparatus, and network-side device
TW202138999A (en) Data dividing method and processor for convolution operation
CN109272567B (en) Three-dimensional model optimization method and device
CN117435129A (en) Storage cluster expansion method and device, computer equipment and storage medium
CN116304212A (en) Data processing system, method, equipment and storage medium
CN111427887A (en) Method, device and system for rapidly scanning HBase partition table
WO2023155348A1 (en) Game data processing method and apparatus, computer device, and storage medium
CN111476872A (en) Image drawing method and image drawing device
CN116955271A (en) Method and device for storing data copy, electronic equipment and storage medium
CN114706687B (en) Distribution method and device of computing tasks, computer equipment and storage medium
CN113268646B (en) Abnormal user data determination method, device, server and storage medium
CN117094268B (en) Inter-grid data transmission method and device, storage medium and electronic equipment
CN115134301B (en) Flow control method, flow control device, computer equipment and storage medium
WO2023245891A1 (en) Etching process simulation method and system
CN105376505A (en) Domain block fusion method and device utilizing method
CN108363736B (en) Storage method, device and storage system of line entity
CN111340215A (en) Network model reasoning acceleration method and device, storage medium and intelligent equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant