Decompression method and device for TIFF image file in LZW compression format
By using multiple pipelines to decompress TIFF image files in parallel and optimizing the write range of the LZW dictionary, the problem of low decompression efficiency of TIFF image files is solved, and the decompression speed is improved.
Patent Information
- Application Number
- CN202310537342.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-14
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-05-14
AI Technical Summary
The existing technology addresses the problem of low decompression efficiency for TIFF image files in LZW compression format.
By reading the DE data in the header of the TIFF image file, the value of Differentiating Predictor is determined. If it is 0, multiple pipelines are set up to decompress each frame of the image file in parallel. If it is not 0, multiple frames of the image file are decompressed in parallel. During the decompression process, the data of consecutive identical target pixels are encoded and written into a preset LZW dictionary. Different dictionary writing intervals are allocated to reduce the synchronization probability.
The efficiency of the decompression process has been improved, enabling parallel decompression of multiple image files, reducing the pipeline synchronization probability, and improving the efficiency of the dictionary in the parallel decompression process.
Smart Images

Figure CN116546215B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of LZW compression technology, and more particularly to a method and apparatus for decompressing TIFF image files in LZW compression format. Background Technology
[0002] TIFF image files are generally multi-frame data in LZW compressed format. Currently, the decompression method for multi-frame data is sequential decompression, that is, decompressing each frame one by one, which has the problem of low decompression efficiency. Summary of the Invention
[0003] This invention provides a method and apparatus for decompressing TIFF image files in LZW compression format, thereby solving the technical problem of low decompression efficiency of TIFF image files in LZW compression format in the prior art.
[0004] On the one hand, the present invention provides the following technical solution:
[0005] A method for decompressing LZW compressed TIFF image files, comprising:
[0006] Read the DE data from the header of the TIFF image file to obtain the DifferentiationPredictor in the DE data;
[0007] If the Differentiation Predictor is 0, then multiple pipelines are set to decompress each frame of the TIFF image file in parallel, and the multiple pipelines decompress one frame of the TIFF image file at a time;
[0008] If the Differentiation Predictor is not 0, then multiple pipelines are set to decompress multiple frames of the TIFF image file in parallel, with each pipeline decompressing one frame of the TIFF image file at a time.
[0009] Preferably, before reading the DE data from the header of the TIFF image file and obtaining the Differentiation Predictor from the DE data, the method further includes:
[0010] The data sequence consisting of multiple consecutive identical target pixel data is encoded and written into a preset LZW dictionary.
[0011] Preferably, the pixel value of each channel in the target pixel data is 0 or 255.
[0012] Preferably, the decompression method for LZW compressed TIFF image files further includes:
[0013] A different LZW dictionary write interval is assigned to each pixel value of the target channel, and the newly added pixel data during the decompression process is encoded and written into the LZW dictionary write interval corresponding to the pixel value of the target channel of the pixel data.
[0014] On the other hand, the present invention also provides the following technical solution:
[0015] A decompression device for LZW compressed TIFF image files, comprising:
[0016] The reading module is used to read the DE data in the header of the TIFF image file and obtain the Differentiation Predictor in the DE data;
[0017] The decompression module is used to set up multiple pipelines to decompress each frame of the TIFF image file in parallel if the Differentiation Predictor is 0, with multiple pipelines decompressing one frame of the TIFF image file at a time;
[0018] The decompression module is further configured to set up multiple pipelines to decompress multiple frames of the TIFF image file in parallel if the Differentiation Predictor is not 0, with each pipeline decompressing one frame of the TIFF image file at a time.
[0019] Preferably, the decompression device for LZW compressed TIFF image files further includes:
[0020] The dictionary update module is used to encode a data sequence consisting of multiple consecutive identical target pixel data and write it into a preset LZW dictionary.
[0021] Preferably, the pixel value of each channel in the target pixel data is 0 or 255.
[0022] Preferably, the decompression device for LZW compressed TIFF image files further includes:
[0023] The dictionary update module is used to allocate different LZW dictionary write intervals for each pixel value of the target channel, and to encode and write the newly added pixel data during the decompression process into the LZW dictionary write interval corresponding to the pixel value of the target channel of the pixel data.
[0024] On the other hand, the present invention also provides the following technical solution:
[0025] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a decompression method for any of the LZW compression formats of TIFF image files.
[0026] On the other hand, the present invention also provides the following technical solution:
[0027] A computer-readable storage medium storing a computer program that, when executed by a processor, implements a decompression method for any of the LZW compressed TIFF image files described above.
[0028] One or more technical solutions provided by this invention have at least the following technical effects or advantages:
[0029] This invention reads the DE data from the header of a TIFF image file to obtain the DifferentiationPredictor. If the DifferentiationPredictor is 0, multiple pipelines are set up to decompress each frame of the TIFF image file in parallel, with each pipeline decompressing one frame at a time. If the DifferentiationPredictor is not 0, multiple pipelines are set up to decompress multiple frames of TIFF image files in parallel, with each pipeline decompressing one frame at a time. Setting up multiple pipelines to decompress each or multiple frames of TIFF image files in parallel can greatly improve decompression efficiency. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a flowchart of the decompression method for LZW compressed TIFF image files in an embodiment of the present invention;
[0032] Figure 2 This is a schematic diagram of a device for decompressing LZW compressed TIFF image files in an embodiment of the present invention. Detailed Implementation
[0033] This invention provides a method and apparatus for decompressing TIFF image files in LZW compression format, thereby solving the technical problem of low decompression efficiency of TIFF image files in LZW compression format in the prior art.
[0034] To better understand the technical solution of the present invention, the technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0035] like Figure 1As shown, the decompression method for LZW compressed TIFF image files in this embodiment includes:
[0036] Step S1: Read the DE data from the header of the TIFF image file to obtain the DifferentiationPredictor in the DE data;
[0037] Step S2: If the Differentiation Predictor is 0, then set up multiple pipelines to decompress each frame of TIFF image file in parallel, and decompress one frame of TIFF image file at a time.
[0038] Step S3: If the Differentiation Predictor is not 0, then set up multiple pipelines to decompress multiple TIFF image files in parallel, with each pipeline decompressing one TIFF image file at a time.
[0039] The DE data in the header of a TIFF image file includes the resolution of a single frame, SamplesPerPixel, and Differencing Predictor. A resolution of m*n means that one frame of image data has m*n pixels. SamplesPerPixel represents the components of each pixel; for example, each pixel in an RGB image has three components (R, G, B). TIFF files use two types of LZW compression: absolute compression, where preceding and following pixel data are independent and each pixel is compressed individually; and relative compression, where preceding and following pixel data are related, and the compressed result is the difference between the current pixel and the previous pixel, but there is no correlation between frames. Differencing Predictor indicates whether LZW compression is pixel-independent; a Differencing Predictor of 0 indicates absolute LZW compression, while a non-zero value indicates relative LZW compression.
[0040] In this embodiment, if N pipelines are set up, and if the TIFF image file is absolutely compressed, with no correlation between preceding and following pixel data, the N pipelines process the image data within a frame in parallel, processing one frame of image data at a time. The size of the data rectangle processed by each pipeline at one time is equal to the resolution * SamplesPerPixel / N. If the TIFF image file is relatively compressed, with no correlation between frames, the N pipelines process multiple frames of image data in parallel, processing one frame of image data at a time. The size of the data rectangle of one frame of image data is equal to the resolution * SamplesPerPixel, and the N pipelines can process N frames of image data at one time. It can be seen that this embodiment, by setting up multiple pipelines to decompress each frame or multiple frames of TIFF image files in parallel, can greatly improve decompression efficiency.
[0041] This embodiment uses RGB image data as an example. Each RGB pixel data includes pixel values in 3 channels, with each pixel value being 8 bits. Each channel has 256 pixel values (0-255), and the range of pixel data is (0,0,0) to (255,255,255). The initialized LZW dictionary can include the encoding corresponding to (0,0,0) to (255,255,255). In traditional decoding schemes, if the pixel data corresponding to the encoding can be found in the initialized LZW dictionary, the pixel data can be directly restored; if the pixel data corresponding to the encoding cannot be found, the LZW dictionary needs to be updated sequentially. Since the initialized LZW dictionary contains relatively few encodings, the probability of updating the dictionary is high, which reduces decoding efficiency.
[0042] To improve decoding efficiency, this embodiment preferably places step S1 before the decompression method of the TIFF image file, which further includes: encoding a data sequence consisting of multiple consecutive identical target pixel data and writing it into a preset LZW dictionary. Taking two target pixel data as an example, where each channel of the target pixel data has a pixel value of 0 or 255, the data sequence and corresponding encoding in Table 1 can be written into the LZW dictionary.
[0043] Table 1
[0044] coding Data sequence N+1 (0,0,0),(0,0,0) N+2 (0,0,255),(0,0,255) N+3 (0,255,0),(0,255,0) N+4 (255,0,0),(255,0,0) N+5 (0,255,255),(0,255,255) N+6 (255,0,255),(255,0,255) N+7 (255,255,0),(255,255,0) N+8 (255,255,255),(255,255,255)
[0045] Here, N represents the initial encoding size of the LZW dictionary. This way, when encoding N+1 is read during decoding, two consecutive identical pixel data points (0,0,0) and (0,0,0) can be directly restored without updating the dictionary. This reduces the probability of dictionary lookups and updates during decompression, improving decompression efficiency. Of course, the pixel value of each channel in the target pixel data can also be 0 or 128, 128 or 255, etc., and can be a data sequence consisting of three consecutive identical target pixel data points. It's understandable that the more encodings in the preset LZW dictionary, the lower the probability of updating the dictionary during decoding.
[0046] For multiple pipelines in this embodiment, if two pipelines need to add new encodings simultaneously, since the new encodings in the LZW dictionary are written sequentially, one pipeline needs to wait for the other pipeline to write the new encodings before it can write its own, reducing the pipeline decoding efficiency. To reduce the synchronization probability of pipeline decompression and improve decompression efficiency, this embodiment preferably further includes, after steps S2 and S3, the decompression method for LZW compressed TIFF image files: allocating different LZW dictionary writing intervals for each pixel value of the target channel, and writing the newly added pixel data encodings during decompression into the LZW dictionary writing interval corresponding to the pixel value of the target channel of the pixel data.
[0047] Specifically, taking the target channel as the R channel as an example, the pixel value range of the R channel is 0 to 255. The pixel data (0,0,0) to (0,255,255), (1,0,0) to (1,255,255), ..., (255,0,0) to (255,255,255) each correspond to a write interval of the LZW dictionary. If two pipelines update their dictionaries synchronously, assuming the first pipeline needs to update the encoding corresponding to the data sequence (1,1,1) and the second pipeline needs to update the encoding corresponding to the data sequence (220,2,2) and the second pipeline, then the first pipeline can write the encoding corresponding to the data sequence (1,1,1) and the second pipeline into the LZW dictionary corresponding to the pixel data range (1,0,0) to (1,255,255) and write it to the end of the range. Similarly, the second pipeline can write the encoding corresponding to the data sequence (220,2,2) and the second pipeline into the LZW dictionary corresponding to the pixel data range (220,0,0) and the second pipeline can write it to the end of the range. The two pipelines do not need to suspend and wait, reducing the synchronization probability of pipeline decoding and improving pipeline decoding efficiency. Of course, the target channel can also be a G channel or a B channel.
[0048] like Figure 2 As shown, this embodiment also provides a decompression device for LZW compressed TIFF image files, including:
[0049] The reading module is used to read the DE data from the header of a TIFF image file and obtain the Differentiation Predictor from the DE data;
[0050] The decompression module is used to set up multiple pipelines to decompress each frame of TIFF image file in parallel if the Differentiation Predictor is 0, with multiple pipelines decompressing one frame of TIFF image file at a time;
[0051] The decompression module is also used to set up multiple pipelines to decompress multiple TIFF image files in parallel if the Differentiation Predictor is not 0, with each pipeline decompressing one TIFF image file at a time.
[0052] Furthermore, the decompression device for LZW compressed TIFF image files may also include:
[0053] The dictionary update module is used to encode a data sequence consisting of multiple consecutive identical target pixel data and write it into a preset LZW dictionary.
[0054] Furthermore, the pixel value for each channel in the target pixel data can be 0 or 255.
[0055] Furthermore, the decompression device for LZW compressed TIFF image files may also include:
[0056] The dictionary update module is used to allocate different LZW dictionary write intervals for each pixel value of the target channel, and to encode and write the newly added pixel data during the decompression process into the LZW dictionary write interval corresponding to the pixel value of the target channel of the pixel data.
[0057] Based on the same inventive concept as the decompression method for LZW compressed TIFF image files described above, this embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of any of the methods described above for decompressing LZW compressed TIFF image files.
[0058] The bus architecture (represented by a bus) can include any number of interconnected buses and bridges, linking various circuits including one or more processors (represented by a processor) and memory (represented by memory). The bus can also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface between the bus and receivers and transmitters. Receivers and transmitters can be the same element, a transceiver, providing a unit for communicating with various other devices over a transmission medium. The processor is responsible for managing the bus and general processing, while memory can be used to store data used by the processor during operation.
[0059] Since the electronic device described in this embodiment is the one used to implement the decompression method for LZW compressed TIFF image files in this embodiment of the invention, those skilled in the art can understand the specific implementation and various variations of the electronic device in this embodiment based on the decompression method for LZW compressed TIFF image files described in this embodiment of the invention. Therefore, how the electronic device implements the method in this embodiment of the invention will not be described in detail here. Any electronic device used by those skilled in the art to implement the decompression method for LZW compressed TIFF image files in this embodiment of the invention falls within the scope of protection of this invention.
[0060] Based on the same inventive concept as the decompression method for TIFF image files in LZW compression format described above, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the decompression method for any of the aforementioned LZW compression format TIFF image files.
[0061] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0062] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0063] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0064] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0065] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for decompressing TIFF image files in LZW compression format, characterized in that, include: Read the DE data from the header of the TIFF image file to obtain the DifferentiationPredictor in the DE data; If the Differentiation Predictor is 0, then multiple pipelines are set to decompress each frame of the TIFF image file in parallel, and the multiple pipelines decompress one frame of the TIFF image file at a time; If the Differentiation Predictor is not 0, then multiple pipelines are set to decompress multiple frames of the TIFF image file in parallel, with each pipeline decompressing one frame of the TIFF image file at a time.
2. The method for decompressing LZW compressed TIFF image files as described in claim 1, characterized in that, Before reading the DE data from the header of the TIFF image file to obtain the Differentiation Predictor in the DE data, the process further includes: The data sequence consisting of multiple consecutive identical target pixel data is encoded and written into a preset LZW dictionary.
3. The method for decompressing LZW compressed TIFF image files as described in claim 2, characterized in that, The pixel value of each channel in the target pixel data is 0 or 255.
4. The method for decompressing LZW compressed TIFF image files as described in claim 1, characterized in that, Also includes: A different LZW dictionary write interval is assigned to each pixel value of the target channel, and the newly added pixel data during the decompression process is encoded and written into the LZW dictionary write interval corresponding to the pixel value of the target channel of the pixel data.
5. A decompression device for LZW compressed TIFF image files, characterized in that, include: The reading module is used to read the DE data in the header of the TIFF image file and obtain the Differentiation Predictor in the DE data; The decompression module is used to set up multiple pipelines to decompress each frame of the TIFF image file in parallel if the Differentiation Predictor is 0, with multiple pipelines decompressing one frame of the TIFF image file at a time; The decompression module is further configured to set up multiple pipelines to decompress multiple frames of the TIFF image file in parallel if the Differentiation Predictor is not 0, with each pipeline decompressing one frame of the TIFF image file at a time.
6. The decompression apparatus for LZW compressed TIFF image files as described in claim 5, further comprising: The dictionary update module is used to encode a data sequence consisting of multiple consecutive identical target pixel data and write it into a preset LZW dictionary.
7. The decompression device for LZW compressed TIFF image files as described in claim 6, characterized in that, The pixel value of each channel in the target pixel data is 0 or 255.
8. The decompression device for LZW compressed TIFF image files as described in claim 5, characterized in that, Also includes: The dictionary update module is used to allocate different LZW dictionary write intervals for each pixel value of the target channel, and to encode and write the newly added pixel data during the decompression process into the LZW dictionary write interval corresponding to the pixel value of the target channel of the pixel data.
9. An electronic device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the decompression method for TIFF image files in LZW compression format as described in any one of claims 1-4.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the decompression method for TIFF image files in LZW compression format as described in any one of claims 1-4.
Citation Information
Patent Citations
Efficient LZW decompression processing method and system, terminal and medium
CN115276663A
Interleaving of variable bitrate streams for GPU implementations
US20230057492A1