Real-time CT data compression method

By preprocessing the CT data and parallel processing of FPGA, a unique encoding table and hash table are generated, and the CT data is encoded in real time, solving the problem that Hoffman encoding in the prior art is difficult to meet the real-time requirements of CT data compression, and achieving efficient and real-time CT data compression.

CN119628655AInactive Publication Date: 2025-03-14BEIJING FUTONG KANGYING MEDICAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411676952.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-03-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing Hoffman encoding is difficult to complete the compression of CT data within 0.25 milliseconds, and cannot meet the real-time requirements of CT data compression.

Method used

By disassembling the data to be encoded into the form of quotient and remainder, the dynamic range of the data is narrowed, and the frequency of occurrence of different characters is used to count and sort the FPGA, a unique encoding table of different lengths is pre-created, a unique encoding comparison hash table is established, and the data to be encoded is encoded.

Benefits of technology

It realizes the completion of CT data compression within 0.25 milliseconds, which meets the real-time requirements of CT data compression, while retaining the high efficiency of static encoding and reducing hardware costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119628655A_ABST
    Figure CN119628655A_ABST
Patent Text Reader

Abstract

The invention discloses a real-time CT (Computed Tomography) data compression method, which comprises the following steps of: S1, according to a selected disassembly coefficient, disassembling data to be coded into a quotient and remainder form, and narrowing the dynamic range of the data; s2, counting the occurrence frequency of different characters in the disassembled data and the number of the different characters by utilizing an FPGA (Field Programmable Gate Array); s3, sorting the different characters from small to large according to the frequency; s4, generating unique coding tables with different lengths in advance according to a Huffman coding principle; s5, selecting a unique code table of which the length is the same as the number of the different characters, and establishing a unique code comparison hash table according to the occurrence frequency of the different characters; and S6, coding the to-be-coded data according to the unique code contrast hash table. Real-time coding of Huffman coding is achieved based on the FPGA, the overall efficiency of a compression algorithm is improved, and the scene requirements of CT data compression and the like for high real-time performance requirements are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of lossless data compression, and in particular relates to a real-time CT data compression method. Background Art

[0002] With the rapid development of high-resolution, multi-level CT imaging technology, the contradiction between the amount of data scanned by CT and the transmission rate is becoming increasingly prominent. Data compression algorithms can effectively alleviate the contradiction between the amount of data scanned and the transmission rate. Among them, Huffman coding is a lossless compression coding method with an optimal binary tree as the core, which has been widely used in the field of data compression. For example, the classic JPEG image compression, GIF image compression, Zstandard compression algorithm, ZIP compression algorithm, Deflate compression algorithm, MPEG compression algorithm, etc. all use Huffman coding. Therefore, in most compression algorithms, the efficiency of Huffman coding is often a key factor restricting the overall efficiency of the compression algorithm. Taking the photon counting CT with high-resolution, multi-level imaging as an example, the amount of CT data generated per second is as high as hundreds of Gbps. However, even the more advanced multi-channel parallel optical fiber transmission has a transmission rate of only 40Gbps per second. In addition, CT data compression has high requirements for the real-time performance of the compression algorithm. For example, photon counting CT needs to complete more than 4,000 data acquisitions in 1 second, and the time interval between two adjacent data acquisitions is only 0.25 milliseconds. This requires the compression algorithm to complete the compression of single acquisition data within 0.25 milliseconds, otherwise there will be a risk of data transmission errors. Most existing compression algorithms are based on Huffman coding, but existing Huffman coding is difficult to complete data compression within 0.25 milliseconds.

[0003] Due to the wide application of Huffman coding in various compression algorithms, the efficiency of Huffman coding has become a key factor restricting the overall efficiency of compression algorithms. However, since Huffman coding is a serial coding and requires multiple sorting during the coding process, it is difficult to meet the needs of real-time data compression scenarios such as CT data compression.

[0004] In response to the above problems, patent CN118381512A proposes a method for grouping the data to be encoded according to the value distribution ratio of the data to be encoded, and then processing each grouped data in parallel, thereby realizing parallel compression of Huffman coding.

[0005] Patent CN112737596A proposes a sorting network that differentiates elements to be sorted into Literal elements and Length elements, and proposes a dynamic Huffman coding method based on the sorting network, which simplifies the Huffman coding sorting steps and related operations.

[0006] Patent CN113824449A proposes a static Huffman parallel coding method that uses the static coding code table specified in RFC1951 and performs 8-way parallel coding after looking up and translating the code words of the data to be processed one by one.

[0007] Patent CN116505954A proposes a parallel Huffman coding method that limits the maximum length of Huffman coding by constraining the depth of the Huffman coding tree.

[0008] In the prior art, static coding or parallel computing is often used to improve the efficiency of Huffman coding. Although static coding improves the operation speed of Huffman coding, since static coding is not optimized for specific data distribution, the compression of static coding is relatively low. Parallel computing often requires the use of hardware such as FPGA and GPU. Although the high compression ratio of the original Huffman coding is retained, it does not change the essence of Huffman coding that requires multiple sorting. It only reduces the number of sorting times, and it is still difficult to meet the needs of CT data compression and other scenarios that require real-time data compression. Summary of the invention

[0009] In order to solve the defects and shortcomings in the above-mentioned prior art, the present invention provides a real-time CT data compression method to improve the overall efficiency of the compression algorithm and meet the real-time requirements of CT data compression.

[0010] The technical solution of the present invention is as follows: A real-time CT data compression method, the steps are as follows:

[0011] S1. Decomposing the data to be encoded into the form of quotient and remainder according to the selected decomposition coefficient, thereby reducing the dynamic range of the data;

[0012] S2, using FPGA to count the frequency of occurrence of different characters and the number of different characters in the disassembled data;

[0013] S3, sorting different characters in ascending order of frequency of occurrence;

[0014] S4, pre-generate unique coding tables of different lengths according to the Huffman coding principle;

[0015] S5, select a unique code table with the same length as the number of different characters, and establish a unique code comparison hash table according to the frequency of occurrence of different characters;

[0016] S6. Encode the data to be encoded according to the unique code and the hash table.

[0017] Preferably, in step S1, the data to be encoded is decomposed into the form of a quotient and a remainder according to the selected decomposition coefficient, so as to reduce the dynamic range of the data. The specific method is to decompose the original data to be encoded into the form of a quotient and a remainder; the formula is as follows:

[0018]

[0019] Among them, d quo and d rem Represent the quotient and remainder after decomposition, d ori Represents the original data to be encoded, k represents the decomposition coefficient, floor represents the floor function, and mod represents the remainder function.

[0020] Preferably, the step S1 decomposes the data to be encoded into the form of quotients and remainders according to the selected decomposition coefficient, thereby reducing the dynamic range of the data. The significance of this is that the dynamic range of the data can be reduced while the total size of the data remains unchanged without any data loss, without affecting parallel computing, and being suitable for FPGA processing. The value of the decomposition coefficient K should be 2 to the power of n, so that the decomposition quotient and remainder can be directly read in the FPGA without calculation. For example, assuming that the original data to be encoded is 35362, which requires 16-bit binary storage, and the decomposition coefficient is selected as 256, the quotient and remainder after decomposition are 138 and 34 respectively. At this time, the quotient and remainder after decomposition only require 8-bit binary storage respectively, thereby reducing the dynamic range of the data while keeping the total data size unchanged; the binary code of the original data 35362 is 1000101000100010, and the decomposition coefficient 256 is 2 to the 8th power. At this time, the high 8 bits 10001010 in the binary code of the original data are the quotient 138, and the low 8 bits 00100010 are the remainder 34.

[0021] Preferably, the step S2 utilizes FPGA to count the frequency of occurrence of different characters and the number of different characters in the disassembled data. The specific method is to utilize the parallel characteristics of FPGA and design it so that when the data is input for the first time, the data is stored in a new register, and when the data is not input for the first time, the register corresponding to the data is incremented by 1, so that when the last data is read in, the histogram statistics can be completed, thereby obtaining the number of different characters and the corresponding frequency of the data to be encoded read in this time.

[0022] Preferably, the step S3 of sorting different characters from small to large according to the frequency of occurrence can be designed as a multi-level register structure in the FPGA, and the frequency in the first-level register is set to 0, and then the data to be encoded and the corresponding frequency are compared with the frequency in the first-level register, and the number with a larger frequency is stored in the register of this level, and the number with a smaller frequency enters the next-level register and is compared with the frequency in the next-level register; due to the parallel characteristics of the FPGA, the sorting can be completed when the last data and its corresponding frequency are read in, and only one sorting is required.

[0023] Preferably, the step S4 pre-generates unique coding tables of different lengths according to the Huffman coding principle. This is different from the static Huffman coding in which a fixed coding table cannot be optimized for a specific data distribution. Since the data to be encoded is stored in fixed binary bits, the theoretical maximum dynamic range of the data to be encoded can be calculated in advance. Then, based on the theoretical maximum dynamic range of the data to be encoded, that is, the theoretical maximum number of different characters, unique coding tables of different lengths are pre-generated. For example, the data to be encoded is stored in 16-bit binary, and after the data preprocessing step, it is stored in 8-bit binary. The theoretical maximum dynamic range is 0 to 255. At this time, it is necessary to pre-generate unique coding tables with lengths of 1 to 255. Afterwards, since when generating the Huffman coding tree in Huffman coding, only the two characters with the smallest frequency of occurrence need to be merged each time, and the specific frequency is not concerned, different frequencies can be pre-set according to the length of the unique coding table, and a unique coding table can be generated according to the Huffman coding.

[0024] Preferably, the unique coding tables of different lengths are pre-generated in step S4 according to the Huffman coding principle. The specific method is as follows: after data preprocessing, the data to be encoded is encoded using n-bit binary coding, and its theoretical maximum dynamic range is 2 n , that is, the theoretical maximum number of different characters is 2 n , then generate lengths of 1 to 2 respectively n A unique coding table is generated. When generating, assuming that the length of the coding table is m, the different characters in the coding table are assigned values ​​of 1 to m, and the frequencies of occurrence are also assigned values ​​of 1 to m, and then the unique coding table is generated according to the Huffman coding method. In addition, the cache space required for pre-generating the unique coding table is reduced by data preprocessing. For example, when the number of different characters is 4, that is, the length of the unique coding table is 4, the frequencies are set to 1, 2, 3, and 4 respectively. At this time, the generated unique coding table is 110, 111, 10, and 0; when the frequencies are set to 3, 5, 9, and 10, the generated unique coding table is 100, 101, 11, and 0; when the number of different characters is the same, that is, the length of the unique coding table is the same, but the frequencies are different, the generated unique coding tables are composed of 2 3-bit binary codes, 1 2-bit binary code, and 1 1-bit binary code, and there is no difference in encoding speed and compression rate. When the data to be encoded is stored in 16-bit binary format, if data preprocessing is not used, the theoretical maximum number of characters is 65535. At this time, 65535 unique encoding tables with lengths from 1 to 65535 need to be generated. The required cache size is After data preprocessing, the data to be encoded is stored in 8-bit binary format, and the theoretical maximum number of characters is 255. It is necessary to generate 255 encoding tables with a length of 1 to 255. The required cache size is By adopting the data preprocessing method, the cache space required for pre-generating the unique coding table can be greatly reduced.

[0025] Preferably, the step S5 selects a unique coding table with the same length as the number of different characters, and establishes a unique coding comparison hash table according to the frequency of occurrence of different characters. The specific method is: according to the statistical results, the number of different characters in the data to be encoded is obtained, and the unique coding table with the same length as the number of different characters is selected; then, according to the sorting results of the frequencies of different characters, the occurrence frequencies are sorted into the pth order according to the hash table method. i The character with the setting frequency is p i Corresponding to the unique coding value, a unique coding comparison hash table is generated. The use of a hash table can reduce the complexity of the table lookup process to O(1).

[0026] Preferably, in step S6, the data to be encoded is encoded according to the unique code reference hash table. Since the previous and next data do not affect each other during encoding, the encoding of all data can be completed in FPGA when the last data to be encoded is read in.

[0027] Existing methods for improving the efficiency of Huffman coding often use static coding and parallel computing; although static coding has a fast coding speed, it cannot be optimized for specific data distribution, which affects the compression rate of Huffman coding; the parallel computing method only uses the parallel characteristics of hardware such as FPGA and GPU to reduce the number of required sorting times, but does not change the essence of requiring multiple sorting; in view of the above shortcomings, the present invention generates unique coding tables of different lengths in advance, and then selects the optimal unique coding table according to the data distribution of the data to be encoded, thereby retaining the advantages of high efficiency of static coding while avoiding the limitation that static coding cannot be optimized for specific data distribution, and the present invention only requires one sorting, and uses the parallel characteristics of FPGA to realize real-time coding of Huffman coding. In addition, through data preprocessing, the cache space required for pre-generated unique coding tables is reduced, while meeting the requirements of scenes requiring real-time data compression such as CT data compression, the hardware cost is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0029] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] Example 1

[0032] A real-time CT data compression method, the basic process is as follows Figure 1 As shown, the method mainly includes the following steps:

[0033] S1. According to the selected decomposition coefficient, the data to be encoded is decomposed into the form of quotient and remainder to reduce the dynamic range of the data: Since the dynamic range of CT data is large, the depth of the Huffman coding tree will be too deep, affecting the Huffman coding compression rate. Therefore, it is necessary to reduce the dynamic range of CT data and improve the Huffman coding compression rate through data preprocessing. The specific method is to decompose the original data to be encoded into the form of quotient and remainder. The formula is as follows:

[0034]

[0035] Among them, d quo and d rem Represent the quotient and remainder after decomposition, d ori Represents the original data to be encoded, k represents the decomposition coefficient, floor represents the floor function, and mod represents the remainder function.

[0036] The present invention adopts the form of disassembling the original data into quotients and remainders, which is significant in that the dynamic range of data is reduced under the condition that the total size of data remains unchanged without data loss, parallel computing is not affected, and FPGA processing is suitable. For example, the original data to be encoded is 35362, which requires 16-bit binary storage. The disassembly coefficient is selected as 256, and the quotient and remainder after disassembly are 138 and 34 respectively. At this time, the quotient and remainder after disassembly only need 8-bit binary storage, respectively, which realizes the dynamic range of data under the condition of total data size. The method is simple to calculate and there is no data loss, and the front and back data are independent of each other and do not affect each other, which is suitable for parallel processing of FPGA. In addition, the value of the disassembly coefficient K should be 2 to the power of n, so that the quotient and remainder after disassembly can be directly read in the FPGA without calculation. For example, assuming that the original data to be encoded is 35362, which requires 16-bit binary storage, and the decomposition coefficient is selected as 256, the quotient and remainder after decomposition are 138 and 34 respectively. At this time, the quotient and remainder after decomposition only require 8-bit binary storage respectively, thereby reducing the dynamic range of the data while keeping the total data size unchanged; the binary code of the original data 35362 is 1000101000100010, and the decomposition coefficient 256 is 2 to the 8th power. At this time, the high 8 bits 10001010 in the binary code of the original data are the quotient 138, and the low 8 bits 00100010 are the remainder 34.

[0037] S2. Use FPGA to count the frequency of occurrence of different characters and the number of different characters in the disassembled data: Using the parallel characteristics of FPGA, it can be designed that when the data is input for the first time, the data is stored in a new register, and when the data is not input for the first time, the register corresponding to the data is added by 1, so that when the last data is read in, the histogram statistics can be completed, thereby obtaining the number of different characters and the corresponding frequency of the data to be encoded read this time.

[0038] S3, sorting different characters from small to large according to the frequency of occurrence: According to the statistical results, sorting different characters from small to large according to the frequency. In FPGA, it can be designed as a multi-level register structure, and the frequency in the first-level register is set to 0, and then the data to be encoded and the corresponding frequency are compared with the frequency in the first-level register. The number with a larger frequency is stored in the register of this level, and the number with a smaller frequency enters the next-level register and is compared with the frequency in the next-level register. Due to the parallel characteristics of FPGA, the sorting can be completed when the last data and its corresponding frequency are read in. In addition, the present invention only needs to perform one sorting.

[0039] S4. Pre-generate unique coding tables of different lengths according to the Huffman coding principle: The present invention adopts a method of pre-generating unique coding to replace the process of generating Huffman coding trees in Huffman coding. Different from the method of using a fixed coding table in static Huffman coding that cannot be optimized for a specific data distribution, the present invention adopts a method of pre-generating unique coding tables of different lengths according to the theoretical maximum dynamic range of the data to be encoded, that is, the theoretical maximum number of different characters, and then selecting the optimal coding table according to the distribution of the data to be encoded.

[0040] The specific method of pre-generating unique coding tables of different lengths is as follows: the data to be coded is encoded using n-bit binary code after data pre-processing, and its theoretical maximum dynamic range is 2 n , that is, the theoretical maximum number of different characters is 2 n , then generate lengths of 1 to 2 respectively n When generating, assuming that the length of the code table is m, the different characters in the code table are assigned values ​​1 to m, and the frequencies of occurrence are also assigned values ​​1 to m, and then a unique code table of length m is generated according to the Huffman coding method.

[0041] Since the data to be encoded is stored in fixed binary bits, the theoretical maximum dynamic range of the data to be encoded can be calculated in advance. For example, the data to be encoded is stored in 16-bit binary. After the data preprocessing step, it is stored in 8-bit binary. The theoretical maximum dynamic range is 0 to 255. At this time, it is necessary to pre-generate a unique coding table with a length of 1 to 255. Afterwards, since when generating the Huffman coding tree in Huffman coding, only the two characters with the smallest frequency of occurrence need to be merged each time, and the specific frequency is not concerned, different frequencies can be pre-set according to the length of the unique coding table, and a unique coding table can be generated according to the Huffman coding. For example, when the number of different characters is 4, that is, when the length of the unique coding table is 4, the frequencies are set to 1, 2, 3, and 4 respectively. At this time, the generated unique coding table is 110, 111, 10, and 0. When the frequency is set to 3, 5, 9, and 10, the generated unique coding table is 100, 101, 11, and 0. When the number of different characters is the same, that is, the length of the unique coding table is the same, but the frequency is different, the generated unique coding table consists of 2 3-bit binary codes, 1 2-bit binary code, and 1 1-bit binary code, and there is no difference in encoding speed and compression rate.

[0042] When the data to be encoded is stored in 16-bit binary format, if data preprocessing is not used, the theoretical maximum number of characters is 65535. At this time, 65535 unique encoding tables with lengths from 1 to 65535 need to be generated. The required cache size is After data preprocessing, the data to be encoded is stored in 8-bit binary format, and the theoretical maximum number of characters is 255. It is necessary to generate 255 encoding tables with a length of 1 to 255. The required cache size is By adopting the data preprocessing method, the cache space required for pre-generating the unique coding table can be greatly reduced.

[0043] S5. Select a unique coding table with the same length as the number of different characters, and establish a unique coding comparison hash table according to the frequency of occurrence of different characters: according to the statistical results, obtain the number of different characters in the data to be encoded, and select a unique coding table with the same length as the number of different characters; then, according to the sorting results of the frequencies of different characters, sort the occurrence frequencies into the pth order according to the hash table method. i The character with the setting frequency is p i Corresponding to the unique coding value, a unique coding comparison hash table is generated. The use of a hash table can reduce the complexity of the table lookup process to O(1).

[0044] S6, encoding the data to be encoded according to the unique code and the hash table: encoding the data to be encoded by using a table lookup method according to the unique code and the hash table. In addition, since the previous and next data do not affect each other during encoding, the encoding of all data can be completed in the FPGA when the last data to be encoded is read in.

[0045] Example 2

[0046] Assume that the data to be encoded is 1526 11926 7996 8126 5983 6154 12005 35689 1526 81268126 6154 5983 5983 7996 7996 7996 6154

[0047] According to the selected decomposition coefficient, the data to be encoded is decomposed into the form of quotient and remainder to reduce the dynamic range of the data: if the decomposition coefficient is selected as 256, the data to be encoded can be decomposed into:

[0048] Table 1 Decomposition results of the data to be encoded

[0049] 1526 11926 7996 8126 5983 6154 12005 35689 business 5 46 31 31 23 24 46 139 Remainder 246 150 60 190 95 10 229 105

[0050] The data after disassembly are: 5 246 46 150 31 60 31 190 23 95 24 10 46 229 139 105 5246 31 190 31 190 24 10 23 95 23 95 31 60 31 60 31 60 24 10

[0051] Use FPGA to count the frequency of occurrence of different characters and the number of different characters in the disassembled data: Perform histogram statistics on the disassembled results. The statistical results of different characters and their corresponding frequencies are shown in Table 2. The number of different characters is 14.

[0052] Table 2 Statistical results of different characters

[0053]

[0054]

[0055] Sort different characters by frequency of occurrence: The results of sorting different characters by frequency from small to large are: 150 229 139 105 5 246 46 190 23 95 24 10 60 31

[0057] According to the Huffman coding principle, unique coding tables of different lengths are generated in advance: after the encoded data is disassembled, it is stored in 8-bit binary. The theoretical maximum dynamic range is 0 to 255. At this time, it is necessary to pre-generate unique coding tables with lengths of 1 to 255. Take a unique coding table with a length of 14 as an example.

[0058] The different characters are set to 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, and 14. The corresponding frequencies of different characters are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, and 14. The unique coding table generated by the Huffman coding method is shown in Table 3.

[0059] Table 3 Unique encoding table of length 14

[0060] character Unique code 1 010110 2 010111 3 01010 4 11100 5 11101 6 0100 7 1100 8 1101 9 1111 10 000 11 001 12 011 13 100 14 101

[0061] Select a unique coding table with the same length as the number of different characters, and establish a unique coding comparison hash table according to the frequency of occurrence of different characters: According to the statistical results, the number of different characters is 14, so a unique coding table with a length of 14 is selected. Then, according to the hash table method, different characters are matched one by one with unique codes according to the sorting results. Since the data to be encoded is stored in 8-bit binary after data preprocessing, the theoretical maximum dynamic range is 0 to 255, and different characters are unique, the input value to be encoded is directly used as the hash value. Taking a unique coding table with a length of 14 as an example, the generated unique coding comparison hash table is shown in Table 4.

[0062] Table 4 Unique code comparison hash table of length 14

[0063] character Hash value Unique code 150 150 010110 229 229 010111 139 139 01010 105 105 11100 5 5 11101 246 246 0100 46 46 1100 190 190 1101 23 23 1111 95 95 000 24 24 001 10 10 011 60 60 100 31 31 101

[0064] Encode the data to be encoded according to the unique encoding comparison hash table: Encode the disassembled data to be encoded according to the unique encoding comparison table. The encoded data is shown in Table 5.

[0065] Table 5 Data encoding after disassembly

[0066]

[0067]

[0068]

[0069] To prove the validity of the present invention, 1526 11926 7996 8126 5983 6154 12005 356891526 8126 8126 6154 5983 5983 7996 7996 7996 6154 is used as the data to be encoded, and compared with the static Huffman coding and the dynamic Huffman coding, and the comparison results are shown in Table 6. The original data has 18 characters in total, and each character is encoded in 16 bits of binary. The size of the original data is 18*16=288 bits, and the size after compression by the patent method is 132 bits. Static Huffman coding uses the static coding table specified in RFC1951. Since the static coding table specified in RFC1951 only gives a data range of 0 to 287, the pre-processed data is used as the data to be encoded and static Huffman coding is performed. The total size of the encoded data is 238 bits. Since both the patent method and static Huffman coding use pre-processed data as input, in order to facilitate comparison in the same dimension, dynamic Huffman coding also uses pre-processed data as input. The dynamic Huffman coding table is shown in Table 7, and the total size of the encoded data is 131 bits.

[0070] Generally speaking, in FPGA, statistical data frequency requires 1 clock cycle, sorting requires 1 clock cycle, and encoding requires 1 clock cycle. The patent of the present invention only requires 1 statistics and 1 sorting. Static Huffman coding does not require statistics and sorting, but when there are n different characters, dynamic Huffman coding requires 1 statistics and n-1 sorting. In actual CT data, the number of different characters is often as high as tens of thousands. If 16-bit binary coding is used, the number of different characters is theoretically up to 65535. The number of sorting times required for dynamic Huffman coding is as high as 65534. Even parallel Huffman coding technology only reduces the number of sorting times required, and still does not change the nature that the number of sorting times increases with the number of different characters. When faced with data with a large number of different characters such as CT data, it is often difficult to meet real-time requirements. For example, when the frequency of FPGA is 100MHz, one clock cycle is 0.00002 milliseconds. When CT data is stored in 16-bit data, the theoretical maximum number of different characters is 65535. The present invention requires 3 clock cycles and takes 0.00006 milliseconds. Dynamic Huffman coding requires 65535 clock cycles and takes 1.3107 milliseconds. In addition, since dynamic Huffman coding needs to perform the next sorting based on the last sorting result, it is a serial calculation method and cannot effectively utilize the parallel characteristics of FPGA to meet the needs of achieving real-time compression. For traditional serial CPUs, taking bubble sorting as an example, it takes 65535*65535 clock cycles to sort 65535 characters only once, which is even more difficult to meet the needs of real-time compression. However, the patent of the present invention only requires 1 sorting, and the required number of sorting times is independent of the number of different characters. It can achieve a compression rate similar to that of dynamic Huffman coding while meeting real-time coding.

[0071] In summary, the effectiveness of the method of the present invention is demonstrated.

[0072] Table 6 Comparison results of the patent method of the present invention with static Huffman coding and dynamic Huffman coding

[0073] Size before compression Compressed size Run time Patented method of the present invention 288bit 132bit 3 clock cycles Static Huffman Coding 288bit 238bit 1 clock cycle Dynamic Huffman Coding 288bit 131bit 15 clock cycles

[0074] Table 7 Dynamic Huffman coding table

[0075]

[0076]

[0077] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

[0078] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.

Claims

1. A real-time CT data compression method, characterized in that: Here are the steps: S1. Decomposing the data to be encoded into the form of quotient and remainder according to the selected decomposition coefficient, thereby reducing the dynamic range of the data; S2, using FPGA to count the frequency of occurrence of different characters and the number of different characters in the disassembled data; S3, sorting different characters in ascending order of frequency of occurrence; S4, pre-generate unique coding tables of different lengths according to the Huffman coding principle; S5, select a unique code table with the same length as the number of different characters, and establish a unique code comparison hash table according to the frequency of occurrence of different characters; S6. Encode the data to be encoded according to the unique code and the hash table.

2. A real-time CT data compression method according to claim 1, characterized in that: In step S1, the data to be encoded is decomposed into the form of quotient and remainder according to the selected decomposition coefficient, so as to reduce the dynamic range of the data. The specific method is to decompose the original data to be encoded into the form of quotient and remainder; the formula is as follows: Among them, d quo and d rem Represent the quotient and remainder after decomposition, d ori Represents the original data to be encoded, k represents the decomposition coefficient, floor represents the floor function, and mod represents the remainder function.

3. A real-time CT data compression method according to claim 2, characterized in that: The step S1 decomposes the data to be encoded into the form of quotients and remainders according to the selected decomposition coefficients, thereby reducing the dynamic range of the data. The significance of this is that the dynamic range of the data can be reduced without affecting the total size of the data without data loss, parallel computing, and being suitable for FPGA processing. The value of the decomposition coefficient K should be 2 to the power of n, so that the decomposition quotient and remainder can be directly read in the FPGA without calculation.

4. A real-time CT data compression method according to claim 1, characterized in that: The step S2 uses FPGA to count the frequency of occurrence of different characters and the number of different characters in the disassembled data. The specific method is to use the parallel characteristics of FPGA and design it so that when the data is input for the first time, the data is stored in a new register. When the data is not input for the first time, the register corresponding to the data is added by 1, so that when the last data is read in, the histogram statistics can be completed, thereby obtaining the number of different characters and the corresponding frequency of the data to be encoded read this time.

5. The real-time CT data compression method according to claim 1, characterized in that: The step S3 of sorting different characters in ascending order of frequency of occurrence can be designed as a multi-level register structure in FPGA, and the frequency in the first-level register is set to 0, and then the data to be encoded and the frequency corresponding to it are compared with the frequency in the first-level register, and the number with a larger frequency is stored in the register of this level, and the number with a smaller frequency enters the next-level register and is compared with the frequency in the next-level register; due to the parallel characteristics of FPGA, the sorting can be completed when the last data and its corresponding frequency are read in, and only one sorting is required.

6. A real-time CT data compression method according to claim 1, characterized in that: The step S4 pre-generates unique coding tables of different lengths according to the Huffman coding principle, which is different from the static Huffman coding in which a fixed coding table cannot be optimized for a specific data distribution. Since the data to be encoded is stored in fixed binary bits, the theoretical maximum dynamic range of the data to be encoded can be calculated in advance; then, based on the theoretical maximum dynamic range of the data to be encoded, that is, the theoretical maximum number of different characters, unique coding tables of different lengths are pre-generated.

7. A real-time CT data compression method according to claim 6, characterized in that: The step S4 generates unique coding tables of different lengths in advance according to the Huffman coding principle. The specific method is as follows: after data preprocessing, the data to be coded is coded using n-bit binary coding, and its theoretical maximum dynamic range is 2 n , that is, the theoretical maximum number of different characters is 2 n , then generate lengths of 1 to 2 respectively. n When generating, assuming that the length of the coding table is m, different characters in the coding table are assigned values ​​from 1 to m, and the frequencies of occurrence are also assigned values ​​from 1 to m, and then unique coding tables of different lengths are generated according to the Huffman coding method.

8. The real-time CT data compression method according to claim 1, characterized in that: The step S5 selects a unique coding table with the same length as the number of different characters, and establishes a unique coding comparison hash table according to the frequency of occurrence of different characters. The specific method is to obtain the number of different characters in the data to be encoded according to the statistical results, select a unique coding table with the same length as the number of different characters; then, according to the sorting results of the frequencies of different characters, sort the occurrence frequencies into the pth order according to the hash table method. i The character with the setting frequency is p i Corresponding to the unique coding value, a unique coding comparison hash table is generated. The use of a hash table can reduce the complexity of the table lookup process to O(1).

9. The real-time CT data compression method according to claim 1, characterized in that: In the step S6, the data to be encoded is encoded according to the unique code and the hash table. Since the previous and next data do not affect each other during encoding, the encoding of all data can be completed in the FPGA when the last data to be encoded is read in.

Citation Information

Patent Citations

  • Dynamic Huffman coding method, device and equipment based on sorting network

    CN112737596A

  • Static Huffman parallel coding method and system, storage medium and equipment

    CN113824449A