Image decompression method and device, electronic equipment and storage medium
By reading the frame header of the image frame in reverse order and positioning the starting position of the image data area, the problem of slow image frame resolution in the prior art is solved, efficient image decompression is achieved, and analysis efficiency and work efficiency are improved.
Patent Information
- Application Number
- CN202411174437.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-06
AI Technical Summary
In the prior art, the image frame resolution speed output by satellite cameras is slow, resulting in low resolution efficiency and affecting work efficiency. It is mainly because when the image data is compressed, it is necessary to read byte byte until the frame identifier is read, and a large number of them are traversed. Bytes to find the image data area.
By reading the frame header forward from the byte position at the end of the image identification area of the image frame, the byte length of the image data area is obtained, and positioned to the start of the image data area based on the known byte lengths of the image identification area and the auxiliary data area. The position is decompressed and directly positioned to the byte position at the end of the image identification area of the previous frame. Repeat the above steps until the decompression of the first frame is completed to reduce the number of traversed bytes.
This greatly improves image parsing speed and work efficiency, reduces the number of bytes traversed during the compression process, and improves analysis efficiency.
Smart Images

Figure CN119094774A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image decompression method, device, electronic equipment and storage medium. Background Art
[0002] Image frames are the original image structures output from satellite cameras. Satellite images are recorded through image frames before being extracted and restored into common image file formats. Image frame files contain many closely arranged image frames, and two adjacent image frames are connected end to end without redundant data. An image frame usually contains three parts, namely the image data area, the auxiliary data area, and the image identification area. The image frame structure of some cameras stores the image data area first, and then stores the auxiliary data area and the image identification area. When the image data is compressed (the length of the compressed data is unknown), the recognition and extraction of the image data area needs to be read byte by byte in a positive order search until the frame identification is read. All image data can only be found after a large number of byte traversals. Therefore, the image parsing speed is slow, resulting in low parsing efficiency, which affects work efficiency. Summary of the invention
[0003] In order to solve the above problems existing in the prior art, the present invention provides an image decompression method, device, electronic device and storage medium. The technical problem to be solved by the present invention is achieved through the following technical solutions:
[0004] A first aspect of an embodiment of the present invention provides an image decompression method, comprising the following steps:
[0005] The traversal step includes: reading forward from the end byte position of the current image identification area to determine the current frame header;
[0006] Obtain the byte length of the current image frame corresponding to the current frame header;
[0007] Determine the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0008] Decompressing the current frame header and the starting byte position of the current image data area to obtain the current image frame;
[0009] According to the starting byte position of the current image data area, determining the ending byte position of the image identification area of the previous image frame as the ending byte position of the current image identification area;
[0010] Return to execute the traversal steps until the current image frame is the first image frame.
[0011] In one embodiment of the present invention, before the step of performing the traversal, the method further includes:
[0012] Read forward from the end of the image compression file to determine the end frame header;
[0013] Obtain the byte length of the last image frame of the image data area corresponding to the last frame header;
[0014] Determining the starting byte position of the image data area according to the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0015] Decompressing the last frame header and the starting byte position of the image data area corresponding to the last frame header to obtain the last image frame;
[0016] According to the starting byte position of the image data area corresponding to the last frame header, the last byte position of the image identification area of the previous image frame is determined as the last byte position of the current image identification area.
[0017] In one embodiment of the present invention, the step of reading forward from the end byte position of the current image identification area to determine the current frame header includes:
[0018] The current frame header is determined by traversing and reading forward byte by byte from the end byte position of the current image identification area.
[0019] In one embodiment of the present invention, determining the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area, and the byte length of the image identification area includes:
[0020] Calculate the sum of the byte length of the current image frame, the byte length of the auxiliary data area, and the byte length of the image identification area to obtain the total length of the data;
[0021] The end byte position is taken as the starting position, and the total length of the data is moved forward to locate the starting byte position of the current image data area.
[0022] A second aspect of an embodiment of the present invention provides a guide image decompression device, comprising:
[0023] The first determination module is used to perform the traversal step, including: reading forward from the end byte position of the current image identification area to determine the current frame header;
[0024] An acquisition module, used for acquiring the byte length of the current image frame corresponding to the current frame header;
[0025] A second determining module is used to determine the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0026] A processing module, used for decompressing according to the current frame header and the starting byte position of the current image data area to obtain a current image frame;
[0027] A third determination module is used to determine the end byte position of the image identification area of the previous image frame according to the start byte position of the current image data area as the end byte position of the current image identification area;
[0028] The loop module is used to return to execute the traversal steps until the current image frame is the first image frame.
[0029] In one embodiment of the present invention, the first determining module is further used to read from the end of the image compression file forward to determine the end frame header;
[0030] The acquisition module is further used to acquire the byte length of the last image frame of the image data area corresponding to the last frame header;
[0031] The second determination module is further used to determine the starting byte position of the image data area according to the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0032] The processing module is further used to decompress according to the last frame header and the starting byte position of the image data area corresponding to the last frame header to obtain the last image frame;
[0033] The third determination module is further used to determine the end byte position of the image identification area of the previous image frame according to the starting byte position of the image data area corresponding to the end frame header as the end byte position of the current image identification area.
[0034] In one embodiment of the present invention, the first determination module is further used to traverse and read forward bytes one by one from the end byte position of the current image identification area to determine the current frame header.
[0035] In one embodiment of the present invention, the second determining module is further used to calculate the sum of the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area to obtain the total data length;
[0036] The end byte position is taken as the starting position, and the total length of the data is moved forward to locate the starting byte position of the current image data area.
[0037] A third aspect of an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, an image decompression method provided by the first aspect of an embodiment of the present invention is implemented.
[0038] A fourth aspect of the embodiments of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the image decompression method provided by the first aspect of the embodiments of the present invention is implemented.
[0039] Beneficial effects of the present invention:
[0040] The present invention reads out the frame header in reverse order starting from the image identification area of the image frame, and then can obtain the byte length of the image data area, and then based on the known byte lengths of the image identification area and the auxiliary data area, can locate the starting position of the image data area and decompress it. It can also directly locate the end byte position of the image identification area of the previous frame and read the frame header of the next frame of image, repeating the above steps until the first frame of image is decompressed, which greatly reduces the number of bytes traversed during the decompression process, improves the image parsing speed, and improves the parsing efficiency and work efficiency.
[0041] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0042] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0044] Figure 1 A schematic diagram of a flow chart of an image decompression method provided by an embodiment of the present invention;
[0045] Figure 2 A schematic diagram of the composition of an image compression file provided by an embodiment of the present invention;
[0046] Figure 3 A schematic block diagram of an image decompression device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.
[0048] like Figure 1 As shown, a first aspect of an embodiment of the present invention provides an image decompression method, comprising the following steps:
[0049] Step 11, reading forward from the last byte position of the current image identification area to determine the current frame header;
[0050] Step 12, obtaining the byte length of the current image frame corresponding to the current frame header;
[0051] Step 13, determining the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0052] Step 14, decompressing according to the current frame header and the starting byte position of the current image data area to obtain the current image frame;
[0053] Step 15, determining the end byte position of the image identification area of the previous image frame according to the start byte position of the current image data area as the end byte position of the current image identification area;
[0054] Step 16, return to step 11 until the current image frame is the first image frame.
[0055] In this embodiment, the frame header is read out in reverse order starting from the image identification area of the image frame, and then the byte length of the image data area can be obtained. Based on the known byte lengths of the image identification area and the auxiliary data area, the starting position of the image data area can be located and decompressed. It is also possible to directly locate the last byte position of the image identification area of the previous frame and read the frame header of the next frame of the image. The above steps are repeated until the first frame of the image is decompressed. This greatly reduces the number of bytes traversed during the decompression process, improves the image parsing speed, and improves the parsing efficiency and work efficiency.
[0056] It should be noted that if Figure 2 As shown in the figure, the red part represents the image data area, the green part represents the auxiliary data area, and the yellow part represents the image identification area. The image data area generally reduces the amount of data by compression, so the length is not fixed. The byte length of the auxiliary data area in the green part is fixed. There are two most important information in the yellow image identification area. One is the image identification located at the starting position of the image identification area, which is called the frame header, and the other important information is the image byte length that records the byte length of the image data area after compression. In the prior art, a common reading method is to start reading from the starting position of the red file header, first traverse the red and green parts byte by byte to find the frame header of the first image frame, and then read the image frame byte length value of this image frame, locate the starting position of the image data area of the image frame by reverse deduction, and then read and decompress to restore the image. After reading and processing, start traversing the next image frame, and the process is the same until the last image frame is traversed and read. The whole process here requires traversing a large number of bytes.
[0057] A second aspect of an embodiment of the present invention provides an image decompression method, comprising the following steps:
[0058] Step 21, read forward from the end of the image compression file to determine the end frame header.
[0059] In this step, the last frame header is determined by reading byte by byte in reverse order from the end of the image compression file, that is, reading in reverse order from the end position of the image identification area of the last image frame (the end position of the data of the entire image compression file) to obtain the frame header of the last image frame.
[0060] Step 22, obtaining the byte length of the last image frame of the image data area corresponding to the last frame header.
[0061] In this step, the image frame byte length of the image data area of the last image frame is obtained.
[0062] Step 23, determining the starting byte position of the image data area according to the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area.
[0063] The specific steps of step 23 include step 231-step 232:
[0064] Step 231, calculate the sum of the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area of the last image frame to obtain the total data length.
[0065] Step 232, starting from the last byte position of the last image frame (ie the end of the image compression file) and moving forward by the total length of data, the starting byte position of the image data area of the last image frame is located.
[0066] Step 24, decompressing is performed according to the last frame header and the starting byte position of the image data area of the last image frame to obtain the last image frame, and the decompression of the last frame is completed.
[0067] Step 25, determining the end byte position of the image identification area of the previous image frame according to the starting byte position of the image data area corresponding to the end frame header as the end byte position of the current image identification area.
[0068] In this step, one byte is positioned forward from the start byte position of the image data area of the last frame, that is, the end of the image identification area of the previous image frame, as the end byte position of the current image identification area.
[0069] Step 26, read forward from the end byte position of the current image identification area to determine the current frame header. In this step, read forward byte by byte from the end byte position of the current image identification area to determine the current frame header.
[0070] Step 27, obtaining the current image frame byte length corresponding to the current frame header. In this step, the image frame byte length of the image data area of the image frame currently being parsed is obtained.
[0071] Step 28, determining the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area.
[0072] The specific steps of step 28 include step 281-step 282:
[0073] Step 281, calculate the sum of the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area to obtain the total data length.
[0074] Step 282, starting from the last byte position as the starting position, moving forward by the total length of the data, and locating to the starting byte position of the current image data area.
[0075] Step 29, decompressing is performed according to the current frame header and the starting byte position of the current image data area to obtain the current image frame. The decompression of the current image frame is completed.
[0076] Step 30, according to the starting byte position of the current image data area, determine the ending byte position of the image identification area of the previous image frame as the ending byte position of the current image identification area.
[0077] In this step, one byte is positioned forward from the starting byte position of the current image data area, that is, the end of the image identification area of the previous image frame, as the end byte position of the current image identification area.
[0078] Step 31, returns to step 26, until decompression is performed according to the current frame header and the starting byte position of the current image data area, and the current image frame is obtained as the first image frame of the image compression file, and the decompression is completed to obtain a complete image.
[0079] In this embodiment, the frame header is read out in reverse order starting from the image identification area of the image frame, and then the byte length of the image data area can be obtained. Based on the known byte lengths of the image identification area and the auxiliary data area, the starting position of the image data area can be located and decompressed. It is also possible to directly locate the end byte position of the image identification area of the previous frame and read the frame header of the next frame of the image. The above steps are repeated until the first frame of the image is decompressed. In this process, there is no need to traverse the bytes of the red and green parts, which greatly reduces the number of bytes traversed during the decompression process, improves the image parsing speed, and improves the parsing efficiency and work efficiency.
[0080] like Figure 3 As shown, a third aspect of an embodiment of the present invention provides an image decompression device, comprising:
[0081] The first determination module 41 is used to perform the traversal step, including: reading forward from the end byte position of the current image identification area to determine the current frame header;
[0082] An acquisition module 42 is used to acquire the byte length of the current image frame corresponding to the current frame header;
[0083] A second determination module 43 is used to determine the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0084] The processing module 44 is used to decompress according to the current frame header and the starting byte position of the current image data area to obtain the current image frame;
[0085] The third determination module 45 is used to determine the end byte position of the image identification area of the previous image frame according to the start byte position of the current image data area as the end byte position of the current image identification area;
[0086] The loop module 46 is used to return to execute the traversal step until the current image frame is the first image frame.
[0087] In one embodiment of the present invention, the first determining module is further used to read from the end of the image compression file forward to determine the end frame header;
[0088] The acquisition module is also used to obtain the byte length of the last image frame of the image data area corresponding to the last frame header;
[0089] The second determination module is further used to determine the starting byte position of the image data area according to the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area;
[0090] The processing module is further used to decompress according to the end frame header and the starting byte position of the image data area corresponding to the end frame header to obtain the end image frame;
[0091] The third determination module is further used to determine the end byte position of the image identification area of the previous image frame according to the starting byte position of the image data area corresponding to the end frame header as the end byte position of the current image identification area.
[0092] In one embodiment of the present invention, the first determination module is further configured to traverse and read bytes one by one from the end byte position of the current image identification area to determine the current frame header.
[0093] In one embodiment of the present invention, the second determination module is further used to calculate the sum of the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area to obtain the total length of the data;
[0094] Starting from the last byte position as the starting position and moving forward by the total length of the data, the starting byte position of the current image data area is located.
[0095] A fourth aspect of an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, an image decompression method provided by the above-mentioned embodiment of the present invention is implemented.
[0096] A fifth aspect of an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of an image decompression method provided by the above-mentioned embodiment of the present invention are implemented.
[0097] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0098] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware systems.
[0099] The method provided in the embodiment of the present invention can be applied to electronic devices. Specifically, the electronic device can be: a desktop computer, a portable computer, an intelligent mobile terminal, a server, etc. This is not limited here, and any electronic device that can implement the present invention belongs to the protection scope of the present invention.
[0100] As for the device / electronic device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0101] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0104] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. An image decompression method, characterized in that: The following steps are involved: The traversal step includes: reading forward from the end byte position of the current image identification area to determine the current frame header; Obtain the byte length of the current image frame corresponding to the current frame header; Determine the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area; Decompressing the current frame header and the starting byte position of the current image data area to obtain the current image frame; According to the starting byte position of the current image data area, determining the ending byte position of the image identification area of the previous image frame as the ending byte position of the current image identification area; Return to execute the traversal steps until the current image frame is the first image frame.
2. The method according to claim 1, characterized in that Before the step of performing the traversal, the method further includes: Read forward from the end of the image compression file to determine the end frame header; Obtain the byte length of the last image frame of the image data area corresponding to the last frame header; Determining the starting byte position of the image data area according to the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area; Decompressing the last frame header and the starting byte position of the image data area corresponding to the last frame header to obtain the last image frame; According to the starting byte position of the image data area corresponding to the last frame header, the last byte position of the image identification area of the previous image frame is determined as the last byte position of the current image identification area.
3. The method according to claim 2, characterized in that The step of reading forward from the end byte position of the current image identification area to determine the current frame header includes: The current frame header is determined by traversing and reading forward byte by byte from the end byte position of the current image identification area.
4. The method according to claim 1, characterized in that The step of determining the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area, and the byte length of the image identification area comprises: Calculate the sum of the byte length of the current image frame, the byte length of the auxiliary data area, and the byte length of the image identification area to obtain the total length of the data; The end byte position is taken as the starting position, and the total length of the data is moved forward to locate the starting byte position of the current image data area.
5. A guide image decompression device, characterized in that: include: The first determination module is used to perform the traversal step, including: reading forward from the end byte position of the current image identification area to determine the current frame header; An acquisition module, used for acquiring the byte length of the current image frame corresponding to the current frame header; A second determining module is used to determine the starting byte position of the current image data area according to the end byte position, the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area; A processing module, used for decompressing according to the current frame header and the starting byte position of the current image data area to obtain a current image frame; A third determination module is used to determine the end byte position of the image identification area of the previous image frame according to the start byte position of the current image data area as the end byte position of the current image identification area; The loop module is used to return to execute the traversal steps until the current image frame is the first image frame.
6. The device according to claim 5, characterized in that The first determination module is further used to read from the end of the image compression file forward to determine the end frame header; The acquisition module is further used to acquire the byte length of the last image frame of the image data area corresponding to the last frame header; The second determination module is further used to determine the starting byte position of the image data area according to the byte length of the last image frame, the byte length of the auxiliary data area and the byte length of the image identification area; The processing module is further used to decompress according to the last frame header and the starting byte position of the image data area corresponding to the last frame header to obtain the last image frame; The third determination module is further used to determine the end byte position of the image identification area of the previous image frame according to the starting byte position of the image data area corresponding to the end frame header as the end byte position of the current image identification area.
7. The device according to claim 5, characterized in that The first determination module is further used to traverse and read forward bytes one by one from the end byte position of the current image identification area to determine the current frame header.
8. The device according to claim 5, characterized in that The second determination module is further used to calculate the sum of the byte length of the current image frame, the byte length of the auxiliary data area and the byte length of the image identification area to obtain the total length of the data; The end byte position is taken as the starting position, and the total length of the data is moved forward to locate the starting byte position of the current image data area.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the image decompression method according to any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image decompression method according to any one of claims 1 to 4 is implemented.
Citation Information
Cited By
Device and method for verifying HDMI prototype with any resolution
CN120614427A
