Infrared image lossless compression method and device based on FPGA
Lossless compression of infrared images is achieved through FPGA, dynamically distinguishing low-frequency and high-frequency information and adopting adaptive compression methods, solving the bandwidth bottleneck problem of high-resolution and high-frame rate infrared image transmission, and achieving efficient and stable transmission and accurate restoration.
Patent Information
- Application Number
- CN202510524951.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-07-29
AI Technical Summary
The prior art is difficult to achieve efficient transmission of high-resolution, high-frame rate infrared images without replacing the existing communication interface, resulting in a degradation of imaging timeliness and measurement performance.
The lossless compression method of infrared image based on FPGA is adopted. Through pixel-by-pixel difference analysis, low-frequency information and high-frequency information are dynamically distinguished, and adaptive compression is performed using 8-bit difference encoding combined with unique flag data and original value. Real-time lossless compression is achieved using ping-pong buffer structure and parallel processing channels.
Without changing the existing communication bandwidth, real-time lossless compression and efficient and stable transmission of high-resolution and high-frame rate infrared images are achieved, ensuring the integrity and reversibility of image data, and improving the system's data throughput capability and processing continuity.
Smart Images

Figure CN120390091A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of image processing, and particularly to a lossless compression method and device for infrared images based on FPGA. Background Art
[0002] With the continuous evolution of infrared imaging technology, the spatial resolution of infrared detectors has been continuously improved. Currently, commercial devices generally have a high planar array specification of 1280×1024 and can achieve an image refresh rate of 50Hz. In infrared temperature measurement applications, in order to achieve high-precision temperature monitoring at each pixel level, it is usually necessary to transmit uncompressed raw image data. Each pixel of this type of raw image data uses a 14-bit quantization accuracy and fills zeros at the high bits to form a 16-bit structure, which means that the total amount of data required for each frame of image is huge, far exceeding the early common specifications of 640×512 or 384×288. When using Gigabit Ethernet as the transmission interface, its bandwidth can only meet the 50Hz transmission requirement under the condition of relatively low detector resolution.
[0003] However, when the resolution is increased to 1280×1024 and the 50Hz frame rate still needs to be maintained, the required bandwidth significantly exceeds the maximum theoretical limit of the Gigabit network. Existing solutions usually use high-speed communication interfaces such as CameraLink or 10 Gigabit Ethernet to achieve data transmission, but these solutions generally have engineering bottlenecks such as complex software and hardware development, long deployment cycles, and high system integration difficulties. Moreover, in some restricted industrial sites, only Gigabit Ethernet is available, making it difficult to adapt to high-speed interface solutions. Eventually, the frame rate can only be reduced to below 25Hz for operation, resulting in a significant decline in imaging timeliness and measurement performance. Therefore, there is an urgent need to design a lossless compression method with high real-time performance and compression ratio to achieve efficient transmission of high-resolution and high-frame-rate infrared images without replacing the existing communication interface, and fundamentally solve the system performance constraints brought by the bandwidth bottleneck. Summary of the Invention
[0004] This application provides a lossless compression method and device for infrared images based on FPGA, which can achieve lossless compression of the transmitted data of infrared images, thereby realizing efficient transmission of high-resolution and high-frame-rate infrared images.
[0005] In the first aspect of this application, a lossless compression method for infrared images based on FPGA is provided, and the method includes:
[0006] Convert each pixel of the infrared image into a raw pixel value in 16-bit form;
[0007] Determine whether the target pixel is the first pixel, where the target pixel is any one of the multiple pixel data of the infrared image, and the first pixel is the first pixel data of each row of pixel data;
[0008] If it is determined that the target pixel is not the first pixel, calculate the pixel difference between the previous pixel of the target pixel and the target pixel;
[0009] Determine the low-frequency information and high-frequency information of the image based on the pixel difference;
[0010] Process and store the low-frequency information and high-frequency information of the subsequent pixels in the current row in sequence to obtain compressed bytes.
[0011] Based on the above technical solution, preferably, the determining the low-frequency information and high-frequency information of the image based on the pixel difference specifically includes:
[0012] Judge the magnitude relationship between the absolute value of the pixel difference and a preset threshold;
[0013] If it is determined that the absolute value is less than or equal to the preset threshold, store the pixel difference in the form of eight-bit data as the low-frequency information;
[0014] If it is determined that the absolute value is greater than the preset threshold, insert a sixteen-bit unique flag data, and store the flag data and the original pixel value in sequence as the high-frequency information.
[0015] Based on the above technical solution, preferably, after determining whether the target pixel is the first pixel, the method further includes:
[0016] If it is determined that the target pixel is the first pixel, store the original pixel value in the form of sixteen bits.
[0017] Based on the above technical solution, preferably, after processing and storing the low-frequency information and high-frequency information of the subsequent pixels in the current row in sequence to obtain compressed bytes, the method further includes:
[0018] Determine the row number of the current row;
[0019] Judge the parity of the row number of the current row;
[0020] Write the compressed bytes of the current row into two independent random access memory buffer areas according to the parity of the row number of the current row, where it is set that the first buffer area in the two random access memory buffer areas corresponds to the compressed bytes of odd rows, and the second buffer area in the two random access memory buffer areas corresponds to the compressed bytes of even rows; or it is set that the second buffer area corresponds to the compressed bytes of odd rows, and the first buffer area corresponds to the compressed bytes of even rows.
[0021] Based on the above technical solutions, preferably, writing the compressed bytes of the current row into two independent random access memory buffer areas respectively according to the parity of the line number of the current row specifically includes:
[0022] The odd rows and the even rows are processed alternately in different buffers, and two parallel processing channels are set in terms of timing. When the odd rows are reading and processing the current row data of the first buffer, the even rows receive the next row of image data and write it into the second buffer.
[0023] Based on the above technical solutions, preferably, after sequentially and circularly processing and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain the compressed bytes, the method further includes:
[0024] If it is determined that the target pixel is the first pixel, after storing the original pixel value, add a preset value to the number of bytes compressed in the current row of the counter;
[0025] If it is determined that the target pixel is not the first pixel, after storing the low-frequency information or the high-frequency information, add the preset value to the number of bytes compressed in the current row of the counter.
[0026] Based on the above technical solutions, preferably, after sequentially and circularly processing and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain the compressed bytes, the method further includes:
[0027] During the decoding process, read the first preset number of compressed bytes of any row;
[0028] Construct the original pixel value by splicing the first preset number of compressed bytes, and record it as the first original value of the first pixel of any row;
[0029] Read the first preset number of first compressed bytes in byte order, where the first compressed byte is any compressed byte in any row;
[0030] Judge whether the first preset number of first compressed bytes is the flag data;
[0031] If it is determined that the first compressed byte is the flag data, splice the first preset number of second compressed bytes to obtain the original pixel value of the current pixel, where the second compressed byte is the subsequent compressed byte adjacent to the first compressed byte in any row;
[0032] If it is determined that the first compressed byte is not the flag data, perform an addition operation on the first compressed byte and the third compressed byte, and the result is the original pixel value of the current pixel, where the third compressed byte is the previous compressed byte adjacent to the first compressed byte in any row.
[0033] In a second aspect of the present application, there is provided an infrared image lossless compression device based on FPGA, the device includes an acquisition module, a processing module, and an output module, where:
[0034] The acquisition module is used to convert each pixel of the infrared image into an original pixel value in a sixteen-bit form;
[0035] The processing module is used to determine whether the target pixel is the first pixel, where the target pixel is any one of the multiple pixel data of the infrared image, and the first pixel is the first pixel data of each row of pixel data;
[0036] The processing module is used to calculate the pixel difference between the previous pixel of the target pixel and the target pixel if it is determined that the target pixel is not the first pixel;
[0037] The processing module is used to determine the low-frequency information and high-frequency information of the image based on the pixel difference;
[0038] The output module is used to sequentially and circularly process and store the low-frequency information and high-frequency information of the subsequent pixels in the current row to obtain compressed bytes.
[0039] On the basis of the above technical solutions, preferably, the processing module is used to determine the magnitude relationship between the absolute value of the pixel difference and a preset threshold;
[0040] The output module is used to store the pixel difference in an eight-bit data form as the low-frequency information if it is determined that the absolute value is less than or equal to the preset threshold;
[0041] The output module is used to insert a sixteen-bit unique flag data and sequentially store the flag data and the original pixel value as the high-frequency information if it is determined that the absolute value is greater than the preset threshold.
[0042] On the basis of the above technical solutions, preferably, the output module is used to store the original pixel value in a sixteen-bit form if it is determined that the target pixel is the first pixel.
[0043] On the basis of the above technical solutions, preferably, the acquisition module is used to determine the row number of the current row;
[0044] The processing module is used to determine the parity of the row number of the current row;
[0045] The processing module is configured to write the compressed bytes of the current line into two independent random access memory buffer areas respectively according to the parity of the line number of the current line, wherein the first buffer area in the two random access memory buffer areas corresponds to the compressed bytes of odd lines, and the second buffer area in the two random access memory buffer areas corresponds to the compressed bytes of even lines; or it is set that the second buffer area corresponds to the compressed bytes of odd lines, and the first buffer area corresponds to the compressed bytes of even lines.
[0046] Based on the above technical solutions, preferably, the processing module is configured to process the odd lines and the even lines alternately in different buffer areas, and set two parallel processing channels in terms of timing. When the odd lines are reading and processing the current line data in the first buffer area, the even lines receive the next line of image data and write it into the second buffer area.
[0047] Based on the above technical solutions, preferably, the output module is configured to, if it is determined that the target pixel is the first pixel, after storing the original pixel value, add a preset value to the number of compressed bytes of the current line of the counter;
[0048] The output module is configured to, if it is determined that the target pixel is not the first pixel, after storing the low-frequency information or the high-frequency information, add the preset value to the number of compressed bytes of the current line of the counter.
[0049] Based on the above technical solutions, preferably, the acquisition module is configured to read the first preset number of compressed bytes of any line during the decoding process;
[0050] The processing module is configured to construct the original pixel value by splicing the first preset number of compressed bytes, and record it as the first original value of the first pixel of any line;
[0051] The acquisition module is configured to read the first compressed bytes of a preset number in byte order, wherein the first compressed byte is any compressed byte in any line;
[0052] The processing module is configured to determine whether the first compressed bytes of the preset number are the flag data;
[0053] The processing module is configured to, if it is determined that the first compressed byte is the flag data, splice the second compressed bytes of the preset number to obtain the original pixel value of the current pixel, wherein the second compressed byte is the subsequent compressed byte adjacent to the first compressed byte in any line;
[0054] The processing module is used to add the first compressed byte and the third compressed byte if it is determined that the first compressed byte is not the flag data, and the result is the original pixel value of the current pixel, wherein the third compressed byte is the previous compressed byte adjacent to the first compressed byte in any row.
[0055] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device performs any of the methods described above.
[0056] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions. When the instructions are executed, any one of the methods described above is executed.
[0057] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0058] 1. This application performs pixel-by-pixel difference analysis on each row of pixel data in an infrared image in a field programmable gate array, dynamically distinguishes low-frequency information from high-frequency information based on the amplitude of the difference between pixels, and uses eight-bit difference encoding combined with unique marker data plus the original value to achieve adaptive compression. This not only significantly reduces the amount of redundant data, but also ensures the integrity and reversibility of the image data, thereby achieving real-time lossless compression and efficient and stable transmission of high-resolution and high-frame-rate infrared images without changing the existing communication bandwidth.
[0059] 2. This application introduces a judgment mechanism based on the absolute value of pixel difference and a preset threshold value, compresses and stores the slowly changing low-frequency information in the infrared image in the form of eight-bit difference, and accurately retains the rapidly changing high-frequency information in the structure of unique marker data plus original pixel value. While significantly reducing the overall data volume, it ensures the point-by-point restoration accuracy of image pixels, achieves an image compression effect that takes into account both compression rate and losslessness, thereby effectively supporting the stable real-time transmission of high-resolution infrared images under limited bandwidth.
[0060] 3. This application constructs a ping-pong buffer structure by writing the compressed bytes into two independent random access memory cache areas according to the parity of the image row number, so that odd rows and even rows are processed interleaved in time and space, avoiding cross-row write conflicts caused by changes in data length during the compression process, thereby improving the real-time performance of image compression and the continuity of system processing, and effectively ensuring the stable compression and efficient transmission of high frame rate infrared images on the field programmable gate array platform.
[0061] 4. In this application, the odd rows and even rows are processed alternately in two independent buffers, and two parallel processing channels are configured to achieve decoupling of reading and writing compressed data. When one channel performs data reading and compressed output, the other channel can synchronously receive the next row of image data, effectively avoiding data blockage or inter-line interference caused by compression processing delay, thereby improving the data throughput capacity and processing continuity of the system, and ensuring stable compression and efficient transmission of high-resolution and high-frame-rate infrared images under real-time conditions.
[0062] 5. In this application, after storing the original pixel value of the first pixel or the low-frequency information or high-frequency information of the subsequent pixels each time, the byte count counter after compression of the current row is updated in real time to ensure accurate recording of the compressed data length, enabling the system to precisely control the boundary of the compressed data of each row during the reading stage, avoiding data truncation or out-of-bounds reading, and improving the data consistency and system stability during the compression and decompression processes, thereby ensuring the integrity and reliability of the compressed transmission of high-resolution infrared images.
[0063] 6. In this application, during the decoding process, the flag data and difference data are identified according to the compressed byte order, and each pixel is restored by using the original value splicing or difference addition operation respectively, ensuring pixel-by-pixel lossless restoration of the compressed image data without adding redundant information, effectively ensuring the accuracy and efficiency of the decoding process, and thereby achieving complete data reconstruction and reliable image reproduction of infrared images under high compression ratio conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 is a schematic flowchart of a method for lossless compression of infrared images based on FPGA disclosed in an embodiment of this application;
[0065] Figure 2 is a schematic diagram of a method for lossless compression of infrared images based on FPGA disclosed in an embodiment of this application;
[0066] Figure 3 is a schematic diagram of writing compressed bytes into a buffer according to the parity of row numbers disclosed in an embodiment of this application;
[0067] Figure 4 is a schematic diagram of row synchronization timing when a field programmable gate array realizes lossless compression of infrared image data disclosed in an embodiment of this application;
[0068] Figure 5 is a schematic diagram of modules of a device for lossless compression of infrared images based on FPGA disclosed in an embodiment of this application;
[0069] Figure 6 is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application.
[0070] Explanation of the reference numerals: 501, acquisition module; 502, processing module; 503, output module; 601, processor; 602, communication bus; 603, user interface; 604, network interface; 605, memory. DETAILED DESCRIPTION
[0071] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0072] In the description of the embodiments of this application, words such as "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "for example" or "for instance" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "for example" or "for instance" is intended to present the relevant concepts in a concrete manner.
[0073] In the description of the embodiments of the present application, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0074] With the significant improvement in the resolution and frame rate of infrared detectors, traditional Gigabit Ethernet can no longer meet the transmission requirements of 1280×1024 resolution 50Hz frame rate infrared image raw data. Existing solutions that rely on high-speed interfaces have problems such as complex software and hardware development, long deployment cycles, and poor field adaptability. Especially in industrial scenarios where only Gigabit Ethernet is available, it is difficult to balance system real-time performance and measurement accuracy. Therefore, a lossless compression method for infrared images that can achieve efficient transmission under limited bandwidth conditions is urgently needed to break through the performance bottleneck caused by bandwidth limitations.
[0075] This embodiment discloses a method for lossless compression of infrared images based on FPGA. Figure 1 , including the following steps S110-S150:
[0076] S110 , converting each pixel of the infrared image into a 16-bit original pixel value.
[0077] An infrared image lossless compression method disclosed in an embodiment of the present application is applied to a server, which includes, but is not limited to, electronic devices such as mobile phones, tablet computers, wearable devices, and PCs (Personal Computers). It can also be a background server running an infrared image lossless compression method based on FPGA. The server can be implemented by an independent server or a server cluster composed of multiple servers.
[0078] During the infrared image acquisition process, each image pixel output by the infrared detector usually represents its gray intensity in a fourteen-bit form, representing the infrared radiation intensity or temperature information at the corresponding position. To facilitate data alignment and subsequent transmission and processing, this fourteen-bit gray value needs to be extended to a sixteen-bit format by padding zeros at the high positions. Specifically, the high positions of the original fourteen-bit gray value are aligned, and zeros are padded at its two high positions to construct a standard sixteen-bit form of the original pixel value. This sixteen-bit form of the original pixel value serves as the basic unit for infrared image data compression, transmission, and decoding, maintaining a unified data structure and precision expression throughout the image processing link to ensure the accuracy of pixel-by-pixel calculations and the consistency of data restoration.
[0079] S120, determine whether the target pixel is the first pixel.
[0080] During the lossless compression process of infrared image data based on a field-programmable gate array, to achieve row-by-row processing and pixel difference coding, it is first necessary to determine the position of the current processing object, that is, the target pixel, in each row of the infrared image to confirm whether it is the first pixel. The target pixel is any pixel data that is sequentially read and processed in the infrared image row data, and the first pixel specifically refers to the first pixel data arranged in the row scanning order in each row of the infrared image. When executing the compression algorithm, before reading the target pixel, it is judged based on the index position of the pixel in the current row. If the index is zero, it indicates that the target pixel is the first pixel; if the index is not zero, the target pixel is a non-first pixel in the current row.
[0081] In a possible implementation manner, after determining whether the target pixel is the first pixel, the method further includes: if it is determined that the target pixel is the first pixel, store the original pixel value in a sixteen-bit form.
[0082] Specifically, in the lossless compression method of infrared image data based on field-programmable gate arrays, after determining whether the target pixel is the first pixel, if it is confirmed that the currently processed target pixel is the first pixel of the current row, there is no need to perform pixel difference calculation and coding determination operations. Instead, the sixteen-bit original pixel value corresponding to this target pixel is directly retained in its original data format and written into the compression buffer storage structure in sixteen-bit form. Since the first pixel has no previous pixel in its row for reference, the pixel difference calculation required for compression cannot be performed, and its data must remain unchanged to ensure the correct establishment of the compression reference for subsequent non-first pixels. This sixteen-bit original pixel value serves as the decoding starting point of the image data in this row in the compressed data stream, has the role of the first benchmark in the compression decoding process, is an indispensable structural data node in the compression algorithm, and is of crucial significance for the correctness of decoding and the integrity of image data.
[0083] S130. If it is determined that the target pixel is not the first pixel, calculate the pixel difference between the previous pixel of the target pixel and the target pixel.
[0084] In the lossless compression process of infrared image data based on field-programmable gate arrays, if it is confirmed through position judgment that the currently processed target pixel is not the first pixel of the current row, then based on the intensity change between this target pixel and the pixel data at the previous position in the row data, a pixel difference calculation operation needs to be performed. This pixel difference is defined as the result obtained by subtracting the sixteen-bit original pixel value of its previous pixel from the sixteen-bit original pixel value of the current target pixel. The calculated pixel difference is used to determine whether this target pixel belongs to the low-frequency information area or the high-frequency information area of the image. If the absolute value of this pixel difference is within the preset range, that is, it does not exceed the preset threshold, it means that the change between this target pixel and its previous pixel is gentle and can be effectively represented by an eight-bit signed difference; conversely, if the absolute value of the pixel difference exceeds the preset threshold, it is determined as a significant change area, and flag data needs to be inserted into the compressed data and the sixteen-bit original pixel value of this target pixel needs to be retained. This pixel difference calculation serves as the core determination basis in the compression algorithm, determines the subsequent coding structure, and directly affects the compression efficiency and decoding restoration accuracy.
[0085] In the lossless compression method of infrared image data proposed in the present invention, the preset threshold is preferably set to 127. Its basis is not arbitrarily set, but the result of comprehensive consideration strictly in combination with the data representation range of the pixel difference and the compressed data structure. The core purpose of setting this threshold is to achieve an effective and compact representation of the difference between the target pixel and its previous pixel, and to ensure the unambiguity of signed integer coding and the feasibility of decoding restoration in the eight-bit structure after data compression.
[0086] Specifically, during the compression process, a difference operation is performed on the sixteen-bit original pixel values of the target pixel and the previous pixel. If the absolute value of the difference does not exceed 127, that is, it falls within the numerical range of [-127, +127], then the difference can be completely encoded as an eight-bit signed integer, which conforms to the binary encoding specification of signed integers. In two's complement representation, the value range that an eight-bit signed integer can represent is [-128, +127], where -128 is a single value for special purposes or reserved, and +127 is the maximum positive number limit. Therefore, to avoid boundary conflicts and ensure the uniqueness of data identification during the compression process, setting the upper limit of the compressible difference range to 127 is the most reasonable and safest technical option.
[0087] In addition, considering that 0x8080 needs to be introduced as the only flag data in the compressed data stream to distinguish the insertion position of high-frequency information, any boundary value that may be confused with the compression difference must be avoided. Therefore, by setting 127 as the preset threshold, not only is the storage structure of the compressed data ensured to be clear, but also the boundary between the difference information and the original pixel information in the compressed data stream can be unambiguously identified during the decoding process, thus realizing a lossless, stable, and reversible image compression process. In summary, selecting 127 as the preset threshold is the optimal technical strategy for balancing the utilization of the encoding space, compression efficiency, and stability.
[0088] S140, determine the low-frequency information and high-frequency information of the image based on the pixel difference.
[0089] Due to the characteristics of infrared imaging, compared with visible light, there are fewer details. In the image, the low-frequency part occupies the vast majority of the image, and the high-frequency part occupies a small part of the image. The low-frequency information in the image, that is, the change between adjacent points is relatively small, and the high-frequency information is that the change between adjacent points is relatively large. Therefore, using this feature, the low-frequency part can be losslessly compressed to ensure that the original data can be accurately restored during decoding.
[0090] In a possible implementation, determining the low-frequency information and high-frequency information of the image based on the pixel difference specifically includes: judging the magnitude relationship between the absolute value of the pixel difference and the preset threshold; if it is determined that the absolute value is less than or equal to the preset threshold, store the pixel difference in the form of eight-bit data as the low-frequency information; if it is determined that the absolute value is greater than the preset threshold, insert a sixteen-bit unique flag data, and sequentially store the flag data and the original pixel value as the high-frequency information.
[0091] Specifically, when implementing the compression method for judging the low-frequency information and high-frequency information of an image based on pixel differences in a field-programmable gate array, it is first necessary to calculate the absolute value of the pixel difference between each target pixel and its previous pixel. This pixel difference is the result obtained by subtracting the 16-bit original pixel value of the previous pixel from the 16-bit original pixel value of the current target pixel. The absolute value of the pixel difference is used to characterize the local change amplitude of the image at this pixel point and is a key quantity for determining whether the image belongs to a flat region or a mutation region.
[0092] After completing the calculation of the absolute value of the pixel difference, it is necessary to judge the size relationship between the absolute value of this pixel difference and a preset threshold. The preset threshold is the largest positive value that can be completely expressed within the range of 8-bit signed integers. This comparison process is completed by the compression control logic module and is used as a binary branch judgment condition for selecting the coding methods of the low-frequency information and high-frequency information in the image.
[0093] If the judgment result is that the absolute value of the pixel difference is less than or equal to the preset threshold, it indicates that the change amplitude of the current target pixel relative to the previous pixel is small and belongs to the low-frequency information region of the image. At this time, convert the pixel difference into an 8-bit signed integer and write it into the compression data buffer in the form of 8-bit data. This 8-bit data can restore the complete original value of the target pixel through addition with the 16-bit original pixel value of the previous pixel during the decoding process. Therefore, it has lossless reversibility and effectively reduces data redundancy.
[0094] If the judgment result is that the absolute value of the pixel difference is greater than the preset threshold, it indicates that the change amplitude of the current target pixel relative to the previous pixel is large and belongs to the high-frequency information region of the image. To ensure the accuracy of such mutation information in the compressed data, a group of 16-bit flag data (such as 0x8080) will be inserted first as the high-frequency information identifier in the compressed data. The flag data is unique and will not appear in the natural pixel data of the image, so it has a clear identification function during the decoding stage. Subsequently, directly write the 16-bit original pixel value of the current target pixel into the compression data buffer to form a continuous three-byte data structure: the flag data and the original pixel value, which together represent the high-frequency image information.
[0095] The above steps are executed logically in series pixel by pixel in the pipeline structure of the field-programmable gate array, and the output length is managed by the current row compression byte count counter to ensure that all compression and writing operations are completed within the limited row valid time, guaranteeing the compression efficiency and data integrity.
[0096] S150, sequentially loop to process and store the low-frequency information and high-frequency information of the subsequent pixels in the current row to obtain the compressed bytes.
[0097] In the implementation of the lossless compression process of infrared image data in a field-programmable gate array, after storing the 16-bit original pixel value of the first pixel, the process enters the sequential loop processing stage for all non-first target pixels in the current row. The core of this stage lies in the selective encoding strategy of continuously performing pixel difference calculation, pixel difference absolute value judgment, low-frequency information compression storage, and high-frequency information insertion flag data, to complete the compressed representation of each target pixel one by one. The specific compression algorithm is as follows:
[0098]
[0099] Among them, i represents the index of each data in the current row (0 to 127), y represents the result after processing the original pixel data, and x i represents the original data.
[0100] During this process, pixel difference calculation is performed between each target pixel and its previous pixel, and the absolute value of the difference is compared with a preset threshold. According to the comparison result, it is determined whether the target pixel should be encoded as low-frequency information or high-frequency information. If it is determined to be low-frequency information, the pixel difference is converted into 8-bit data and written into the compressed data buffer; if it is determined to be high-frequency information, 16-bit flag data is first written, and then the 16-bit original pixel value of the target pixel is written into the compressed data buffer to form a three-byte compression structure. This processing process is sequentially executed by the compression algorithm control module in the order of pixel index until all target pixels in the current image row are processed, and finally the compressed data stream of the current row is formed. After each write operation, the compressed byte count counter of the current row is updated to record the total number of compressed bytes written cumulatively, so that the subsequent reading module can obtain an accurate reading range when reading the compression result. This sequential loop processing mechanism for each pixel ensures that the entire row of image data is efficiently compressed and an optimal balance is achieved between compression accuracy and compression ratio.
[0101] For example, referring to Figure 2 , the figure shows a set of pixel compression examples in the lossless compression method of infrared image data based on a field-programmable gate array, where the upper part is the original image data, and the middle part is the corresponding compressed result data, showing the encoding method differences and the execution logic of the compression process of low-frequency information and high-frequency information in the compression structure.
[0102] In the original data, each unit represents a 16-bit original pixel value. For example, the first pixel in the figure is 0x2100, and the subsequent ones are 0x2105, 0x2108, 0x2106, 0x2210, 0x2211, 0x2214, etc. These 16-bit original pixel values are the continuous pixel gray values of a certain row in the image, all represented in 16-bit form and having precise infrared radiation measurement significance.
[0103] In the compressed data, the first pixel 0x2100 is the starting pixel of each row of the image. Since there is no previous pixel for reference, its original value is directly retained in its entirety in 16-bit form as the initial reference during decoding. The pixel difference between the second pixel 0x2105 and the first pixel is 5, and the absolute value is less than the preset threshold of 127. It is determined to be low-frequency information and is only represented by the 8-bit integer 5 after compression. The difference between the third pixel 0x2108 and the previous pixel is 3, and the difference between the fourth pixel 0x2106 and the previous pixel is -2. Both meet the conditions for low-frequency information and are therefore represented by the 8-bit differences 3 and -2 respectively.
[0104] The difference between the fifth pixel 0x2210 and the previous pixel 0x2106 is 0x010A in hexadecimal, which is equal to 266 and exceeds the preset threshold of 127. It is determined to be high-frequency information. At this time, a 16-bit unique flag data 0x8080 is inserted into the compression process, and the 16-bit original pixel value of 0x2210 is written immediately after it. This flag data does not appear in natural images and can be used as a basis for identifying the high-frequency information structure during decoding to ensure the restoration accuracy.
[0105] The difference between the sixth pixel 0x2211 and 0x2210 is 1, and the difference between the seventh pixel 0x2214 and 0x2211 is 3. The absolute values of the differences are both within the preset threshold range, so they are still regarded as low-frequency information and are represented by the 8-bit integers 1 and 3 respectively.
[0106] In a possible implementation, after sequentially looping through and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain the compressed bytes, the method further includes: determining the row number of the current row; judging the parity of the row number of the current row; writing the compressed bytes of the current row into two independent random access memory buffer areas according to the parity of the row number of the current row, where it is set that the first buffer area among the two random access memory buffer areas corresponds to the compressed bytes of odd rows, and the second buffer area among the two random access memory buffer areas corresponds to the compressed bytes of even rows; or setting the second buffer area to correspond to the compressed bytes of odd rows and the first buffer area to correspond to the compressed bytes of even rows.
[0107] Specifically, the row number of the current row is identified through the image synchronization timing logic. This row number is the sequential number of each row in the image data within the frame, usually generated by the cooperation of the vertical synchronization signal and the row clock signal with the counter incrementing. This row number is stored in the memory in the form of an unsigned integer and is used to indicate the row processing state during the compression process.
[0108] After obtaining the row number of the current row, the parity of the row number is immediately judged. The judgment logic is usually implemented by performing a modulo operation on the least significant bit of the row number. If the result is 0, it is an even row, and if the result is 1, it is an odd row. This judgment result serves as the sole basis for subsequent data buffer selection.
[0109] Based on the parity of the current line number, the compressed byte data of the current line is written into one of two independent random access memory buffers. Specifically, if the current line number is odd, the compressed bytes of that line are written into the first buffer; if it is even, they are written into the second buffer. Or in the design, it can also be set reversely, that is, the second buffer corresponds to the compressed bytes of odd lines, and the first buffer corresponds to the compressed bytes of even lines. The two random access memory buffers are independent resources with completely separate address spaces and read / write control logics, capable of simultaneously receiving data write requests from different sources and supporting parallel data stream processing.
[0110] The mechanism of dividing the write path based on the parity of the line number constitutes the core logic of the ping-pong buffer structure, ensuring that when one set of buffers is performing the operation of writing the compression result during the compression process, the other set of buffers can independently execute the operation of reading the compression result, avoiding the risk of line timing overlap caused by the uncertain number of compressed bytes, thereby improving the real-time performance and robustness of compression in high-resolution and high-frame-rate infrared image processing scenarios.
[0111] Refer to Figure 3 , first determine the parity based on the line number of the image. If the current line is an odd line, it enters the corresponding "odd-line RAM write control" module through the upper path. This module writes the compressed data of the current odd line into the upper left RAM module. Subsequently, the compression module reads the original image data from this RAM, performs logical processing such as pixel difference judgment, low-frequency information and high-frequency information compression, and flag data insertion, writes the processed compressed data into the right RAM, and finally, the "odd-line RAM read control" module controls the reading of the compressed bytes and outputs them to the subsequent transmission.
[0112] If the current line is an even line, it enters the corresponding "even-line RAM write control" module through the lower path, and writes the original image data of the even line into the lower left RAM. This part of the process is the same as that of odd lines, read and compressed by the corresponding compression module and written into the right RAM, and the reading and output are completed through the "even-line RAM read control" module. The odd and even line paths are independent and completely parallel, and will not cross-access the same RAM at any time, thus realizing the timing isolation and data decoupling of the structure.
[0113] Using two independent compression channels and two sets of RAM resources, a ping-pong buffer mechanism based on the parity switch of the line number is constructed. In the engineering scenario of high-speed input of image data, dynamically changing compressed byte lengths, and limited line blanking time, this mechanism controls the write and read operations to alternate between odd and even lines, avoiding the extension of compression delay caused by inserting high-frequency information during the compression process, thereby effectively preventing data overwrite between adjacent lines and ensuring the real-time performance and stability of compression under high resolution and high frame rate conditions.
[0114] In a possible implementation, the compressed bytes of the current line are written into two independent random access memory buffer areas respectively according to the parity of the line number of the current line, which specifically includes: odd lines and even lines are processed alternately in different buffer areas, and two parallel processing channels are set in terms of timing. When the odd line is reading and processing the current line data in the first buffer area, the even line receives the next line of image data and writes it into the second buffer area.
[0115] Specifically, in the lossless compression method of infrared image data based on a field programmable gate array, to solve the problem of line timing overlap caused by the uncertain length of the compressed data, a ping-pong buffer mechanism based on the parity division of line numbers is introduced in the image compression structure. Specifically, it realizes the interleaved processing by using two independent random access memory buffer areas for odd lines and even lines respectively, and configures two completely independent parallel processing channels to ensure that the image line compression process is separated both spatially and temporally.
[0116] First, when each line of infrared image data is received, the line number of this line is obtained through the image timing synchronization logic, and the parity determination is performed. According to the determination result, if it is an odd line, the compressed byte data of the current line is written into the first random access memory buffer area; if it is an even line, it is written into the second random access memory buffer area. This step completes the physical space division of the compressed data, ensuring that subsequent compression reading and output operations do not access the same address area.
[0117] Secondly, during the actual operation, two parallel processing channels are simultaneously enabled, corresponding to the odd line processing link and the even line processing link respectively. At a certain moment, if the odd line channel is reading the compressed odd line data in the first random access memory buffer area and outputting the compressed bytes of this line to the network interface module through the decoding module, then at this time the even line channel is in the writing stage, receiving the next line of even line raw image data from the image acquisition interface and writing it into the second random access memory buffer area to prepare the input data for the next compression.
[0118] The mechanism of alternating processing of these two channels forms a "ping-pong interleaving" in the logical sense. Its essence is to utilize the non-overlapping compression reading and data writing operations in time to improve the data throughput capacity of compression, and avoid the writing delay caused by the increase in the length of compressed data from affecting the receiving and processing timing of subsequent image lines. Each buffer area operates independently between odd and even lines, the read-write control logic is completely decoupled, and the compression channel is dynamically scheduled according to the processing status. On the premise of meeting the compression accuracy and image quality, the inter-line processing delay is compressed to the maximum extent, and the adaptability to high-frame-rate and high-resolution image data streams is improved.
[0119] Further, referring to Figure 4Starting from the top, the "field signal" in the figure represents the frame synchronization start signal for the current frame, providing a unified timing reference for each subsequent line of image data. The "line signal" indicates the period during which valid data exists for each line during the image acquisition process. A high level indicates the valid data area, and a low level indicates the line blanking area. As can be seen in the figure, the first and third lines are typical active image lines, while the blank "line blanking" area in the middle represents the transition period between lines after the frame scan reaches the current line during image acquisition.
[0120] The "Raw Data" and "Compressed Data" rows correspond to two separate channels in the field programmable gate array (FPGA), each dedicated to odd and even rows, illustrating the interleaved data processing process on the timeline. In the "Raw Data" channel, the raw pixel data for odd rows (such as the first and third rows) is sequentially written into the odd row buffer. In the "Compressed Data" channel, the corresponding odd row compression module reads the data from the odd row buffer during the row blanking period, performs compression processing, and outputs the compressed bytes. Even row data undergoes the same processing synchronously in a separate channel, without interfering with each other.
[0121] Odd and even rows are completely staggered on the timeline. That is, while one channel is performing compression processing, the other is receiving and writing the next row of raw data. This structure clearly separates image acquisition and compression processing, preventing compression delays from blocking the writing of the next row of image data.
[0122] By physically separating odd and even rows in the buffer and processing channel, we ensure that the compression time delay of each row of data will not interfere with the normal acquisition of the next row of data, thereby achieving high efficiency, real-time and stability of the image compression process.
[0123] In one possible embodiment, after looping and storing the low-frequency information and high-frequency information of subsequent pixels in the current row to obtain compressed bytes, the method further includes: if it is determined that the target pixel is the first pixel, then after storing the original pixel value, adding a preset value to the number of bytes after compression of the current row of the counter; if it is determined that the target pixel is not the first pixel, then after storing the low-frequency information or the high-frequency information, adding a preset value to the number of bytes after compression of the current row of the counter.
[0124] Specifically, in the field programmable gate array-based lossless compression method for infrared image data, in the process of completing the sequential cyclic processing of all target pixels in the current row and outputting the compressed byte data, it is also necessary to maintain in real time a compressed byte counter for recording the total number of bytes after compression of the current row. The counter is used to calibrate the length range of the compressed data of the current row so that the subsequent reading module can accurately output the compression result and ensure the boundary integrity of the compressed data stream.
[0125] First, when it is determined that the current target pixel is the first pixel in the row, according to the requirements of the compression logic, its sixteen-bit original pixel value needs to be directly retained in its complete form and written into the compression buffer without participating in the pixel difference calculation. At this time, immediately add a preset value of "2" to the compression byte counter. This value corresponds to the two eight-bit storage units occupied by the original pixel value of the first pixel, that is, a total of 16 bits, which is used to accurately accumulate the length of the compressed data that has been written.
[0126] Next, when it is determined that the current target pixel is not the first pixel but any subsequent target pixel in the current row, it is necessary to determine whether the target pixel should be encoded as low-frequency information or high-frequency information based on the absolute value of the pixel difference between it and the previous pixel. After completing the encoding, update the compression byte counter according to the encoding form: if the current target pixel belongs to low-frequency information, it is written as an eight-bit signed difference, occupying only 1 byte, and add 1 to the compression byte counter; if the current target pixel belongs to high-frequency information, the compression data structure includes sixteen-bit flag data plus sixteen-bit original pixel value, totaling 4 bytes. First, add 2 to the compression byte counter to record the flag data, then add 2 to record the original pixel value, and finally add 4 to the compression byte counter to ensure that the total number of bytes corresponding to the high-frequency data structure is accurately accumulated.
[0127] The update operation of the entire compression byte counter is strictly synchronized with the process of writing the compressed data and is bound to the processing state of the target pixel, so that the cumulative length of the compressed data in the current row can be known in real time internally at any time. The value of this counter is ultimately used as the boundary reference for the compression reading module to read the length of the compressed data in the current row, preventing data reading insufficiency or out-of-bounds errors, and serving as the scheduling basis for alternating reading and writing in the ping-pong buffer mechanism. It is the core control parameter in the compression structure to ensure the effectiveness and stability of compression.
[0128] In a possible implementation manner, after successively and cyclically processing and storing the low-frequency information and high-frequency information of the subsequent pixels in the current row to obtain the compressed bytes, the method further includes: during the decoding process, reading a preset number of the previous compressed bytes of any row; constructing the original pixel value by splicing the preset number of the previous compressed bytes, which is recorded as the first original value of the first pixel of any row; reading the preset number of the first compressed bytes in byte order, where the first compressed byte is any compressed byte in any row; determining whether the preset number of the first compressed bytes is flag data; if it is determined that the first compressed byte is flag data, then splice the preset number of the second compressed bytes to obtain the original pixel value of the current pixel, where the second compressed byte is the subsequent compressed byte adjacent to the first compressed byte in any row; if it is determined that the first compressed byte is not flag data, then perform an addition operation on the first compressed byte and the third compressed byte, and the result is the original pixel value of the current pixel, where the third compressed byte is the previous compressed byte adjacent to the first compressed byte in any row.
[0129] Specifically, in the lossless compression method for infrared image data based on field programmable gate arrays, to achieve the complete restoration of compressed data at the receiving end, it is necessary to gradually parse each row of compressed bytes and reconstruct pixel values during the image decoding process to ensure the accurate recovery of the original image data without distortion. This decoding process strictly performs reverse processing based on the flag data insertion and difference coding mechanisms used during compression. The following are the specific implementation steps.
[0130] First, when starting to decode any row of compressed data, read a preset number of compressed bytes from the compressed byte data stream of that row. The preset number is 2 bytes, corresponding to the 16-bit structure occupied by the first original pixel value in the compressed data. By concatenating these two consecutive eight-bit compressed bytes, the original pixel value of the first pixel in that row is restored and used as the decoding reference value. All subsequent non-first pixels need to be based on this pixel for difference or reconstruction. The decoding formula is as follows:
[0131]
[0132] Among them, [] represents that two 8-bit bytes form a 16-bit original data. During decoding, the first pixel in each row is composed of the first 2 bytes received. For the decoding of subsequent pixels, it is necessary to determine whether the data is the flag data 0x8080.
[0133] Read the remaining compressed bytes of that row one by one in byte order, and identify whether each read compressed byte is flag data. This flag data is uniformly defined as the 16-bit value 0x8080 during compression. During decoding, it is necessary to determine whether two consecutive compressed bytes combine to form this unique flag. If the currently read compressed byte combines with its adjacent subsequent byte to form 0x8080, it is confirmed as a high-frequency information flag.
[0134] When it is confirmed that the current compressed byte is flag data, skip this flag data and continue to read the two compressed bytes immediately following it. Concatenate these two eight-bit data into a new 16-bit data, which is the original pixel value of the current target pixel. Without performing any difference operation with any other pixel, it is directly output as the restored current pixel and updated as the latest reference value in the decoding sequence.
[0135] If the currently read compressed byte is not flag data, it means it is a compressed pixel difference, belonging to low-frequency information. At this time, interpret this compressed byte as an eight-bit signed integer and perform an addition operation with the previously decoded original pixel value in that row. The result is the original pixel value of the current target pixel. This value is then also used as the reference benchmark for the decoding of subsequent target pixels.
[0136] The decoding operation continues. Based on the judgment of whether each compressed byte is flag data each time, the original pixel value splicing or difference addition restoration is alternately executed until all the compressed bytes in this row are parsed and a complete row of original image data is formed. Through this structural decoding process, based on the sequentiality of the compressed byte sequence and the uniqueness of the flag, efficient and unambiguous image data restoration can be achieved, ensuring that the gray structure and accuracy of the image are fully restored at the decoding end, providing reliable data support for high-precision scenarios such as infrared temperature measurement.
[0137] Referring to Figure 2 , decoding starts from 0x2100 and is directly stored as the first pixel. Thereafter, for each read compressed byte, it is judged whether it is the flag data 0x8080. If it is a difference byte, the value is added to the previous decoded pixel value to restore the original value of the current pixel. If 0x8080 is read, the next two bytes 0x2210 are taken and directly spliced into a sixteen-bit original pixel value. Through this strategy, the finally reconstructed decompressed data is successively 0x2100, 0x2105, 0x2108, 0x2106, 0x2210, 0x2211, 0x2214, which is consistent with the original data bit by bit, verifying the losslessness and reliability of the decoding process.
[0138] This embodiment also discloses an infrared image lossless compression device based on FPGA. Referring to Figure 5 , it includes an acquisition module 501, a processing module 502, and an output module 503, where:
[0139] The acquisition module 501 is used to convert each pixel of the infrared image into an original pixel value in sixteen-bit form.
[0140] The processing module 502 is used to judge whether the target pixel is the first pixel, where the target pixel is any one of the pixel data of the infrared image, and the first pixel is the first pixel data of each row of pixel data.
[0141] The processing module 502 is used to calculate the pixel difference between the previous pixel of the target pixel and the target pixel if it is determined that the target pixel is not the first pixel.
[0142] The processing module 502 is used to determine the low-frequency information and high-frequency information of the image based on the pixel difference.
[0143] The output module 503 is used to sequentially process and store the low-frequency information and high-frequency information of the subsequent pixels in the current row to obtain compressed bytes.
[0144] In a possible implementation manner, the processing module 502 is used to judge the magnitude relationship between the absolute value of the pixel difference and a preset threshold.
[0145] The output module 503 is configured to store the pixel difference as low-frequency information in the form of eight-bit data if it is determined that the absolute value is less than or equal to a preset threshold.
[0146] The output module 503 is configured to insert sixteen-bit unique flag data and sequentially store the flag data and the original pixel value as high-frequency information if it is determined that the absolute value is greater than the preset threshold.
[0147] In a possible implementation, the output module 503 is configured to store the original pixel value in the form of sixteen bits if it is determined that the target pixel is the first pixel.
[0148] In a possible implementation, the acquisition module 501 is configured to determine the line number of the current line.
[0149] The processing module 502 is configured to determine the parity of the line number of the current line.
[0150] The processing module 502 is configured to write the compressed bytes of the current line into two independent random access memory 605 buffer areas respectively according to the parity of the line number of the current line, where the first buffer area in the two random access memory 605 buffer areas corresponds to the compressed bytes of odd lines, and the second buffer area in the two random access memory 605 buffer areas corresponds to the compressed bytes of even lines. Or it is set that the second buffer area corresponds to the compressed bytes of odd lines, and the first buffer area corresponds to the compressed bytes of even lines.
[0151] In a possible implementation, the processing module 502 is configured to perform interleaved processing on odd lines and even lines in different buffer areas, and set two parallel processing channels in terms of timing. When the odd line is reading and processing the current line data in the first buffer area, the even line receives the next line of image data and writes it into the second buffer area.
[0152] In a possible implementation, the output module 503 is configured to add a preset value to the number of compressed bytes of the current line of the counter after storing the original pixel value if it is determined that the target pixel is the first pixel.
[0153] The output module 503 is configured to add a preset value to the number of compressed bytes of the current line of the counter after storing the low-frequency information or the high-frequency information if it is determined that the target pixel is not the first pixel.
[0154] In a possible implementation, the acquisition module 501 is configured to read the first preset number of compressed bytes of any line during the decoding process.
[0155] The processing module 502 is configured to construct the original pixel value by splicing the first preset number of compressed bytes, which is recorded as the first original value of the first pixel of any line.
[0156] An acquisition module 501 is configured to read a preset number of first compressed bytes in byte order, where the first compressed byte is any compressed byte in any row.
[0157] A processing module 502 is configured to determine whether the preset number of first compressed bytes are flag data.
[0158] The processing module 502 is configured to, if it is determined that the first compressed byte is flag data, splice a preset number of second compressed bytes to obtain the original pixel value of the current pixel, where the second compressed byte is a subsequent compressed byte adjacent to the first compressed byte in any row.
[0159] The processing module 502 is configured to, if it is determined that the first compressed byte is not flag data, perform an addition operation on the first compressed byte and a third compressed byte, and the result is the original pixel value of the current pixel, where the third compressed byte is a preceding compressed byte adjacent to the first compressed byte in any row.
[0160] It should be noted that: when the device provided in the above embodiment implements its functions, only the division of the above function modules is used for illustration. In actual applications, the above functions can be allocated to different function modules according to needs, that is, the internal structure of the device is divided into different function modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process can be seen in the method embodiment, which will not be elaborated here.
[0161] This embodiment also discloses an electronic device. Referring to Figure 6 , the electronic device may include: at least one processor 601, at least one communication bus 602, a user interface 603, a network interface 604, and at least one memory 605.
[0162] Among them, the communication bus 602 is used to realize the connection and communication between these components.
[0163] Among them, the user interface 603 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 603 may further include a standard wired interface and a wireless interface.
[0164] Among them, the network interface 604 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0165] Among them, the processor 601 may include one or more processing cores. The processor 601 connects various parts within the entire server through various interfaces and lines. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 605, and by calling the data stored in the memory 605, it performs various functions of the server and processes data. Optionally, the processor 601 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 601 may integrate a combination of one or several of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes operations, user interfaces, and application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 601 and may be implemented separately by a single chip.
[0166] Among them, the memory 605 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory includes a non-transitory computer-readable storage medium. The memory 605 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 605 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing operations, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store the data involved in the above-mentioned various method embodiments. Optionally, the memory 605 may also be at least one storage device located far from the aforementioned processor 601. The memory 605, as a computer storage medium, may include operations, a network communication module, a user interface 603 module, and an application program for an infrared image lossless compression method based on FPGA.
[0167] In Figure 6In the electronic device shown, the user interface 603 is mainly used to provide an input interface for the user and obtain the data input by the user; while the processor 601 can be used to call the application program stored in the memory 605, which is an FPGA-based infrared image lossless compression method. When executed by one or more processors 601, the electronic device is caused to execute the method of one or more of the above embodiments.
[0168] It should be noted that, for the foregoing method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0169] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0170] In several embodiments provided by this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some service interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical or other form.
[0171] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0172] In addition, in each embodiment of this application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0173] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 605 and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of various embodiments of this application. And the aforementioned memory 605 includes: various media such as USB flash drives, mobile hard disks, magnetic disks, or optical discs that can store program codes.
[0174] This application also discloses a computer-readable storage medium that stores instructions. When executed by one or more processors 601, it causes the electronic device to execute one or more of the methods as described in the above embodiments.
[0175] The foregoing are only exemplary embodiments of the present disclosure and should not be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made in accordance with the teachings of the present disclosure still fall within the scope covered by the present disclosure. After considering the specification and the disclosure of the practical truth, those skilled in the art will readily think of other implementation schemes of the present disclosure. This application aims to cover any variations, uses, or adaptive changes of the present disclosure, and these variations, uses, or adaptive changes follow the general principles of the present disclosure and include the common general knowledge or conventional technical means in the technical field not recorded in the present disclosure. The specification and the embodiments are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. An infrared image lossless compression method based on FPGA, characterized in that, The method includes: Converting each pixel of the infrared image into a raw pixel value in 16-bit form; Determining whether the target pixel is the first pixel, where the target pixel is any one of the multiple pixel data of the infrared image, and the first pixel is the first pixel data of each row of pixel data; If it is determined that the target pixel is not the first pixel, calculating the pixel difference between the previous pixel of the target pixel and the target pixel; Determining the low-frequency information and high-frequency information of the image based on the pixel difference; Sequentially and circularly processing and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain compressed bytes.
2. The infrared image lossless compression method based on FPGA according to claim 1, characterized in that, The determining the low-frequency information and high-frequency information of the image based on the pixel difference specifically includes: Judging the magnitude relationship between the absolute value of the pixel difference and a preset threshold; If it is determined that the absolute value is less than or equal to the preset threshold, storing the pixel difference in 8-bit data form as the low-frequency information; If it is determined that the absolute value is greater than the preset threshold, inserting a 16-bit unique flag data, and sequentially storing the flag data and the raw pixel value as the high-frequency information.
3. The lossless compression method for infrared images based on FPGA according to claim 2, characterized in that, After determining whether the target pixel is the first pixel, the method further includes: If it is determined that the target pixel is the first pixel, storing the raw pixel value in 16-bit form.
4. A lossless compression method for infrared images based on FPGA according to claim 1, characterized in that, After sequentially and circularly processing and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain compressed bytes, the method further includes: Determining the row number of the current row; Judging the parity of the row number of the current row; Writing the compressed bytes of the current row into two independent random access memory buffer areas according to the parity of the row number of the current row, where it is set that the first buffer area in the two random access memory buffer areas corresponds to the compressed bytes of odd rows, and the second buffer area in the two random access memory buffer areas corresponds to the compressed bytes of even rows; or it is set that the second buffer area corresponds to the compressed bytes of odd rows, and the first buffer area corresponds to the compressed bytes of even rows.
5. A lossless compression method for infrared images based on FPGA according to claim 4, characterized in that, The writing the compressed bytes of the current row into two independent random access memory buffer areas according to the parity of the row number of the current row specifically includes: Processing the odd rows and the even rows alternately in different buffer areas, and setting two parallel processing channels in terms of timing. When the odd rows are reading and processing the current row data of the first buffer area, the even rows receive the next row of image data and write it into the second buffer area.
6. A lossless compression method for infrared images based on FPGA according to claim 3, characterized in that, After sequentially and circularly processing and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain compressed bytes, the method further includes: If it is determined that the target pixel is the first pixel, after storing the raw pixel value, adding a preset value to the number of compressed bytes of the current row of the counter; If it is determined that the target pixel is not the first pixel, after storing the low-frequency information or high-frequency information, adding the preset value to the number of compressed bytes of the current row of the counter.
7. An infrared image lossless compression method based on FPGA according to claim 2, characterized in that, After sequentially cyclically processing and storing the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain compressed bytes, the method further includes: During the decoding process, read the first preset number of compressed bytes of any row; Construct the original pixel value by splicing the first preset number of compressed bytes, and record it as the first original value of the first pixel of the any row; Read the first preset number of first compressed bytes in byte order, where the first compressed byte is any compressed byte in the any row; Determine whether the first preset number of first compressed bytes is the flag data; If it is determined that the first compressed byte is the flag data, splice the first preset number of second compressed bytes to obtain the original pixel value of the current pixel, where the second compressed byte is the subsequent compressed byte adjacent to the first compressed byte in the any row; If it is determined that the first compressed byte is not the flag data, perform an addition operation on the first compressed byte and the third compressed byte, and the result is the original pixel value of the current pixel, where the third compressed byte is the previous compressed byte adjacent to the first compressed byte in the any row.
8. An infrared image lossless compression device based on FPGA, characterized in that, The device is used to execute a method for lossless compression of infrared images based on FPGA as described in any one of claims 1-7. The device includes an acquisition module (501), a processing module (502), and an output module (503), where: The acquisition module (501) is used to convert each pixel of the infrared image into an original pixel value in a sixteen-bit form; The processing module (502) is used to determine whether the target pixel is the first pixel, where the target pixel is any one of the multiple pixel data of the infrared image, and the first pixel is the first pixel data of each row of pixel data; The processing module (502) is used to calculate the pixel difference between the previous pixel of the target pixel and the target pixel if it is determined that the target pixel is not the first pixel; The processing module (502) is used to determine the low-frequency information and high-frequency information of the image based on the pixel difference; The output module (503) is used to sequentially cyclically process and store the low-frequency information and high-frequency information of the subsequent pixels of the current row to obtain compressed bytes.
9. An electronic device, characterized in that, It includes a processor (601), a communication bus (602), a user interface (603), a network interface (604), and a memory (605). The memory (605) is used to store instructions. The user interface (603) and the network interface (604) are both used to communicate with other devices. The communication bus (602) is used to realize the connection and communication between components in the electronic device. The processor (601) is used to execute the instructions stored in the memory (605) so that the electronic device executes the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions, and when the instructions are executed, the method as described in any one of claims 1-7 is executed.