A dynamic image compression method, system, device and storage medium

CN116781922BActive Publication Date: 2026-09-25EASTCOM NETWORK SECURITY (SHENZHEN) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310874320.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-14
Publication Date
2026-09-25
Estimated Expiration
2043-07-14

AI Technical Summary

Technical Problem

[0009]对于GIF体积压缩,通过减色、删除帧、帧图片压缩和透明度压缩的方法无法改变图像格式,本身还是动态图片,对于针对静态图片训练的现有的内容识别模型/OCR模型适用性低,非常容易漏掉动图的内容,而且图片信息损失处于不可控状态,压缩后容易丢失重要信息;而合并帧的方式可能直接丢失单帧的内容,造成内容混淆或无法识别

Benefits of technology

[0051]本发明与现有技术相比,具有的优点为:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116781922B_ABST
    Figure CN116781922B_ABST
Patent Text Reader

Abstract

The application discloses a dynamic image compression method, system, device and storage medium, belongs to the technical field of dynamic image compression, and solves the technical problem that existing dynamic image compression technology is prone to causing content recognition model recognition failure, and the method comprises the following steps: reading data, setting a detection threshold and a similarity threshold; converting the data into matrix data of an RGB color space; recording the frame number of matrix data of each frame and the width and height pixel number thereof; comparing subsequent frames with the first frame as a reference, recording the position of inconsistent pixels; taking the minimum position and the maximum position as the coordinates of cropping, cropping the original frame sequence to generate a new image data matrix sequence; calculating a target similarity threshold, performing frame iteration on the new data matrix, and calculating the cosine similarity of subsequent frames and the first frame; discarding the frames equal to or greater than the target similarity threshold to generate a residual frame sequence; generating a new canvas according to the frame width and height data, and splicing the base frame and the residual frame sequence to generate a new single image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of dynamic image compression technology, and more specifically, to a dynamic image compression method, system, device, and storage medium. Background Technology

[0002] GIF compression technology, which reduces the number of bytes a GIF occupies on disk, can be implemented in five ways:

[0003] a. Color reduction: This method reduces the color space of an original image by merging similar colors, thereby increasing compression efficiency.

[0004] b. Frame deletion: Some image frames are randomly / in order, or duplicate frames are extracted and deleted to reduce the size of the animated image.

[0005] c. Frame image compression: Each frame of the image is compressed pixel by pixel to reduce the number of bytes occupied by each frame and thus reduce the overall size.

[0006] d. Transparency compression: Repeated colors in each frame are removed, and the overlapping parts of the original RGB / RGBA color space are all set to 100% transparency to form a transparent layer, thereby increasing compression efficiency.

[0007] e. Merge frames, combining all frames into a single image.

[0008] GIF frame tiling involves tiling all frames onto an expanded canvas to facilitate OCR recognition of the content.

[0009] For GIF compression, methods such as color reduction, frame deletion, frame image compression, and transparency compression cannot change the image format, as the image itself is still a dynamic image. This has low applicability to existing content recognition / OCR models trained on static images, making it very easy to miss the content of the GIF. Moreover, the loss of image information is uncontrollable, and important information is easily lost after compression. On the other hand, merging frames may directly lose the content of a single frame, causing content confusion or inability to be recognized.

[0010] While GIF frame tiling technology does not lose any image content information, if there are many frames, the length / width ratio of the tiled image will be very large, causing the content recognition model / OCR model to fail or take too long to recognize. Summary of the Invention

[0011] The technical problem to be solved by the present invention is to address the above-mentioned shortcomings of the prior art. The objective of the present invention is to provide a dynamic image compression method.

[0012] The second objective of this invention is to provide a dynamic image compression system.

[0013] The third objective of this invention is to provide a computer device.

[0014] The fourth objective of this invention is to provide a computer storage medium.

[0015] To achieve the first objective mentioned above, the present invention provides a dynamic image compression method, comprising the following steps:

[0016] Step S1. Read the original dynamic image data and set the detection threshold and similarity threshold; if the original dynamic image data is greater than or equal to the detection threshold, exit; otherwise, proceed to step S2.

[0017] Step S2. Convert the binary data read in step S1 into matrix data in the RGB color space;

[0018] Step S3. Extract the matrix data of each frame in sequence and record the frame number and the number of pixels in width and height;

[0019] Step S4. Using the first frame as a reference, compare the subsequent frames in turn and record the positions where the pixels are inconsistent; the final set of positions is called the set of positions that cannot be removed; based on this, copy the data of the first frame as the base frame, and use the minimum and maximum positions in the set as the cropping coordinates to crop the pixel matrix of each frame of the original frame sequence that does not contain the base frame, generating a new image data matrix sequence.

[0020] Step S5. Based on the set similarity threshold and the specific data of the image, calculate a suitable target similarity threshold; then perform frame traversal on the cropped new data matrix, using the first frame as the reference, calculate the cosine similarity between the subsequent frames and the first frame; discard frames with cosine similarity values ​​equal to or exceeding the target similarity threshold, retain frames with cosine similarity values ​​lower than the target similarity threshold, and generate a new frame sequence, called the cosine frame sequence.

[0021] Step S6. Based on the frame width and height data recorded in step S3, generate a new canvas, and combine the base frame and the remaining frame sequence into the new canvas according to the longest baseline stitching method to generate a new single image;

[0022] Step S7. Export the new single image to the subsequent image content recognition model.

[0023] As a further improvement, in step S1, if no user sets a detection threshold and a similarity threshold, the detection threshold is set to 10MB by default, and the similarity threshold is set to 90 by default.

[0024] Further, in step S5, the formula for calculating the target similarity threshold is:

[0025] Cr = C × (X × Y × A) / (S × An)

[0026] Where Cr is the target similarity threshold, C is the set similarity threshold, X and Y are the pixel width and height of a single frame, A is the average pixel smoothness, S is the standard number of pixels, and An is the standard smoothness.

[0027] Furthermore, during the frame traversal process, the color value (R, B, G) of each pixel in the frame is used as a three-dimensional vector. The cosine similarity of the same position in two frames is calculated according to the position. The number of pixels whose similarity exceeds the target similarity threshold Cr is recorded. Finally, the ratio of the number of similar pixels to the total number of pixels is calculated.

[0028] If the value is equal to or greater than 95%, the frame is discarded; otherwise, the frame is recorded in a new frame sequence.

[0029] After traversal is complete, insert the first frame and generate a new frame sequence, called the remaining frame sequence.

[0030] Furthermore, in step S6, if the number of pixels at the bottom edge of the base frame is greater than that at the right edge, the number of horizontally parallel frames in the remaining frame sequence is calculated with the bottom edge as the baseline.

[0031] If the number of right pixels of the base frame is greater than or equal to the number of bottom pixels, then the number of vertically parallel frames in the remaining frame sequence is calculated with the right side as the baseline.

[0032] Then, an empty pixel matrix is ​​generated according to the calculated new canvas size, and the base frame and the remaining frame sequences are sequentially concatenated into the empty pixel matrix.

[0033] Convert this pixel matrix back to binary data and save it as a single stitched image in JPG format.

[0034] Furthermore, with the bottom edge as the baseline, let the width and height of the base frame be Lk and Lg, respectively, the number of frames in the remaining frame sequence be n, and the frame pixel width and height of the remaining frame sequence be a and b.

[0035] The number of frames that can be arranged horizontally in the remaining frame sequence is int(Lk / a), where int() represents rounding down the data inside the function. The number of frames that can be arranged vertically is int(n / int(Lk / a))+1.

[0036] The width of the new canvas is Lk, and the height is Lg+(int(n / int(Lk / a))+1)*b. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas.

[0037] Furthermore, with the right side as the baseline, let the width and height of the base frame be Lk and Lg, respectively, the number of frames in the remaining frame sequence be n, and the pixel width and height of the remaining frame sequence be a and b.

[0038] The number of frames that can be arranged vertically side-by-side is int(Lg / b), and the number of frames that can be arranged horizontally side-by-side is int(n / int(Lg / b))+1;

[0039] The width of the new canvas is Lk+(int(n / int(Lg / b))+1)*a, and the height is Lg. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas.

[0040] To achieve the second objective mentioned above, the present invention provides a dynamic image compression system, comprising:

[0041] The reading module is used to read the original dynamic image data, set the detection threshold and similarity threshold; if the original dynamic image data is greater than or equal to the detection threshold, the compression process will exit.

[0042] The conversion module is used to convert the read binary data into matrix data in the RGB color space;

[0043] The recording module is used to extract the matrix data of each frame sequentially and record the frame number and the number of pixels in width and height.

[0044] The cropping module is used to compare subsequent frames sequentially with the first frame as a reference, and record the positions where pixels are inconsistent. The final set of positions is called the set of non-removable positions. Based on this, the data of the first frame is copied as the base frame, and the minimum and maximum positions in the set are used as the cropping coordinates to crop the pixel matrix of each frame of the original frame sequence that does not contain the base frame, generating a new image data matrix sequence.

[0045] The traversal module is used to calculate a suitable target similarity threshold based on the set similarity threshold and the specific data of the image; then, it performs frame traversal on the cropped new data matrix, using the first frame as a reference, and calculates the cosine similarity between the subsequent frames and the first frame; frames with cosine similarity values ​​equal to or exceeding the target similarity threshold are discarded, and frames with cosine similarity values ​​lower than the target similarity threshold are retained to generate a new frame sequence, called the co-frame sequence;

[0046] The stitching module is used to generate a new canvas based on the recorded frame width and height data, and stitch the base frame and the remaining frame sequences onto the new canvas according to the longest baseline stitching method to generate a new single image;

[0047] The export module is used to export new single images to subsequent image content recognition models.

[0048] To achieve the above-mentioned objective three, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-mentioned dynamic image compression method.

[0049] To achieve the fourth objective mentioned above, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the aforementioned dynamic image compression method.

[0050] Beneficial effects

[0051] Compared with the prior art, the advantages of this invention are as follows:

[0052] This application combines the preservation of original GIF frame information with the filtering of duplicate content between frames, as well as the removal of highly similar frames. This significantly reduces redundant information in the original GIF while preserving the integrity of the content information as much as possible, resulting in a substantial improvement in the efficiency and accuracy of subsequent image content recognition or OCR text recognition. It boasts advantages such as simple computation, high efficiency, few third-party dependencies, and ease of implementation in various programming languages. It is suitable for integration into existing OCR recognition models or other image content recognition applications as a pre-optimization tool, or it can be flexibly deployed as a standalone tool. Attached Figure Description

[0053] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation

[0054] The present invention will be further described below with reference to specific embodiments shown in the accompanying drawings.

[0055] See Figure 1 A dynamic image compression method includes the following steps:

[0056] Step S1. Read the original dynamic image data and set the detection threshold and similarity threshold; if the original dynamic image data is greater than or equal to the detection threshold, exit; otherwise, proceed to step S2.

[0057] Step S2. Convert the binary data read in step S1 into matrix data in the RGB color space;

[0058] Step S3. Take out the matrix data of each frame in sequence and record the frame number and the number of pixels in width and height, for example, the frame width and height X and Y, the number of pixels in a single frame Pt ​​= X*Y, and the number of frames n;

[0059] Step S4. Using the first frame as a reference, compare the subsequent frames in turn and record the positions where the pixels are inconsistent; the final set of positions is called the set of non-removable positions; based on this, copy the data of the first frame as the base frame, and use the minimum and maximum positions in the set as the cropping coordinates to crop the image pixel matrix of each frame of the original frame sequence (i.e. the frame converted in step S2) that does not contain the base frame, and generate a new image data matrix sequence.

[0060] Step S5. Based on the set similarity threshold and combined with the specific data of the image, including the pixel width and height of a single frame, average pixel smoothness, standard number of pixels, and standard smoothness, calculate a suitable target similarity threshold; then perform frame traversal on the cropped new data matrix, using the first frame as a reference, calculate the cosine similarity between the subsequent frames and the first frame; discard frames whose cosine similarity value is equal to or exceeds the target similarity threshold, and retain frames whose cosine similarity value is lower than the target similarity threshold to generate a new frame sequence, called the cosine frame sequence;

[0061] Step S6. Based on the frame width and height data recorded in step S3, generate a new canvas, and combine the base frame and the remaining frame sequence into the new canvas according to the longest baseline stitching method to generate a new single image;

[0062] Step S7. Export the new single image to a subsequent image content recognition model, such as an OCR model.

[0063] In step S1, if no user-defined detection threshold and similarity threshold are set, the detection threshold is set to 10MB by default, and the similarity threshold is set to 90 by default. GIF images exceeding 10MB are generally considered large, complex, and dynamic images, potentially containing numerous frames or extremely large pixels in a single frame, and are rarely seen in practice. Exceeding 10MB not only significantly increases computational resource consumption, potentially leading to lower system efficiency and instability, but also does not bring much efficiency improvement to subsequent image recognition.

[0064] The similarity threshold is the initial value used to control whether a result is considered "approximate" in the cosine similarity calculation. It can be set by the user based on the application scenario. The default value is 90, which is an empirical value. Cosine similarity originally refers to the dot product of vectors, a calculation method to determine the consistency of vector directions. In machine learning, it is often used for similarity calculations of images, sounds, and text, providing a basis for judging whether two things are the same. The original calculated value of cosine similarity falls between -1 and 1; the closer to 1, the more similar they are, and the closer to -1, the more opposite they are. A value of 0 indicates that the two are positively intersecting. This application only considers the similarity between image frames, so it only takes the first quadrant of the cosine value, i.e., the result of 0-1. For ease of understanding, a linear transformation is used to correspond to the value range of 0-100; the closer to 100, the more similar the two are. Since the input images may be complex and varied, a single threshold cannot completely cover all scenarios. Therefore, the parameters will be fine-tuned through a transformation formula in subsequent calculations. The formula contains two main parameters: the average smoothness of all frames of the dynamic image (calculated using the gradient of adjacent pixels) and the total number of pixels in a single frame.

[0065] In step S5, the formula for calculating the target similarity threshold is:

[0066] Cr = C × (X × Y × A) / (S × An)

[0067] Where Cr is the target similarity threshold, C is the set similarity threshold, X and Y are the pixel width and height of a single frame, A is the average pixel smoothness, S is the standard number of pixels, and An is the standard smoothness.

[0068] For example: Assuming C = 90, the pixel width and height of a single frame are X = 100 and Y = 100, the average pixel smoothness A = 75, the standard number of pixels S = 10000, and the standard smoothness An = 80, then according to the formula, we can obtain...

[0069] Cr=(100x 100x 75) / (10000x 80)x 90=84.375

[0070] As the final standard for determining whether two frames are "similar".

[0071] During the frame traversal, the color value (R, B, G) of each pixel in the frame is used as a three-dimensional vector. The cosine similarity of the same position in two frames is calculated according to the position. The number of pixels whose similarity exceeds the target similarity threshold Cr is recorded. Finally, the ratio of the number of similar pixels to the total number of pixels is calculated.

[0072] If the value is equal to or greater than 95%, the frame is discarded; otherwise, the frame is recorded in a new frame sequence.

[0073] After traversal is complete, insert the first frame and generate a new frame sequence, called the remaining frame sequence.

[0074] In step S6, the splicing method is divided into two cases: if the number of pixels at the bottom edge of the base frame is greater than that on the right edge, then the bottom edge is used as the baseline to calculate the number of horizontally parallel frames in the remaining frame sequence.

[0075] If the number of right pixels of the base frame is greater than or equal to the number of bottom pixels, then the number of vertically parallel frames in the remaining frame sequence is calculated with the right side as the baseline.

[0076] Then, an empty pixel matrix is ​​generated according to the calculated new canvas size, and the base frame and the remaining frame sequences are sequentially concatenated into the empty pixel matrix.

[0077] Convert this pixel matrix back to binary data and save it as a single stitched image in JPG format.

[0078] For example: Let the width and height of the base frame be Lk and Lg respectively, the number of frames in the remaining frame sequence be n, and the pixel width and height of the remaining frame sequence be a and b.

[0079] If Lk > Lg, then the bottom edge is used as the baseline; the number of frames that can be horizontally arranged in the remaining frame sequence is int(Lk / a), where int() represents rounding down the data inside the function, and the number of frames that can be vertically arranged is int(n / int(Lk / a)) + 1; the width of the new canvas is Lk, and the height is Lg + (int(n / int(Lk / a)) + 1) * b. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas.

[0080] Otherwise, the right side is used as the baseline; the number of frames that can be arranged vertically is int(Lg / b), and the number of frames that can be arranged horizontally is int(n / int(Lg / b))+1; the width of the new canvas is Lk+(int(n / int(Lg / b))+1)*a, and the height is Lg;

[0081] The size of the new canvas and the specific stitching positions of each frame are determined based on the width and height of the new canvas.

[0082] A dynamic image compression system, comprising:

[0083] The reading module is used to read the original dynamic image data, set the detection threshold and similarity threshold; if the original dynamic image data is greater than or equal to the detection threshold, the compression process will exit.

[0084] The conversion module is used to convert the read binary data into matrix data in the RGB color space;

[0085] The recording module is used to extract the matrix data of each frame sequentially and record the frame number and the number of pixels in width and height.

[0086] The cropping module is used to compare subsequent frames sequentially with the first frame as a reference, and record the positions where pixels are inconsistent. The final set of positions is called the set of non-removable positions. Based on this, the data of the first frame is copied as the base frame, and the minimum and maximum positions in the set are used as the cropping coordinates to crop the pixel matrix of each frame of the original frame sequence that does not contain the base frame, generating a new image data matrix sequence.

[0087] The traversal module is used to calculate a suitable target similarity threshold based on the set similarity threshold and the specific data of the image; then, it performs frame traversal on the cropped new data matrix, using the first frame as a reference, and calculates the cosine similarity between the subsequent frames and the first frame; frames with cosine similarity values ​​equal to or exceeding the target similarity threshold are discarded, and frames with cosine similarity values ​​lower than the target similarity threshold are retained to generate a new frame sequence, called the co-frame sequence;

[0088] The stitching module is used to generate a new canvas based on the recorded frame width and height data, and stitch the base frame and the remaining frame sequences onto the new canvas according to the longest baseline stitching method to generate a new single image;

[0089] The export module is used to export new single images to subsequent image content recognition models.

[0090] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the aforementioned dynamic image compression method.

[0091] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned dynamic image compression method.

[0092] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the structure of the present invention, and these will not affect the effectiveness of the implementation of the present invention or the practicality of the patent.

Claims

1. A dynamic image compression method, characterized in that, Includes the following steps: Step S1. Read the original dynamic image data, set the detection threshold and similarity threshold; if the original dynamic image data is greater than or equal to the detection threshold, exit; Otherwise, proceed to step S2; Step S2. Convert the binary data read in step S1 into matrix data in the RGB color space; Step S3. Extract the matrix data of each frame in sequence and record the frame number and the number of pixels in width and height; Step S4. Using the first frame as a reference, compare the subsequent frames sequentially and record the positions where pixels are inconsistent; the final set of positions is called the set of non-removable positions. Based on this, the first frame data is copied as the base frame, and the minimum and maximum positions in the set are used as the cropping coordinates to crop the image pixel matrix of each frame of the original frame sequence that does not contain the base frame, generating a new image data matrix sequence. Step S5. Based on the set similarity threshold and the specific data of the image, calculate a suitable target similarity threshold; then perform frame traversal on the cropped new data matrix, using the first frame as the reference, calculate the cosine similarity between the subsequent frames and the first frame; discard frames with cosine similarity values ​​equal to or exceeding the target similarity threshold, retain frames with cosine similarity values ​​lower than the target similarity threshold, and generate a new frame sequence, called the cosine frame sequence. Step S6. Based on the frame width and height data recorded in step S3, generate a new canvas, and combine the base frame and the remaining frame sequence into the new canvas according to the longest baseline stitching method to generate a new single image; Step S7. Export the new single image to the subsequent image content recognition model; In step S6, the splicing method is divided into two cases: if the number of pixels at the bottom edge of the base frame is greater than that on the right edge, then the bottom edge is used as the baseline to calculate the number of horizontally parallel frames in the remaining frame sequence. If the number of right pixels of the base frame is greater than or equal to the number of bottom pixels, then the number of vertically parallel frames in the remaining frame sequence is calculated with the right side as the baseline. Then, an empty pixel matrix is ​​generated according to the calculated new canvas size, and the base frame and the remaining frame sequences are sequentially concatenated into the empty pixel matrix. Convert this pixel matrix back to binary data and save it as a single stitched image in JPG format; With the bottom edge as the baseline, let the width and height of the base frame be Lk and Lg, respectively, the number of frames in the remaining frame sequence be n, and the pixel width and height of the remaining frame sequence be a and b. The number of frames that can be arranged horizontally in the remaining frame sequence is int(Lk / a), where int() represents rounding down the data inside the function. The number of frames that can be arranged vertically is int(n / int(Lk / a))+1. The width of the new canvas is Lk, and the height is Lg+(int(n / int(Lk / a))+1)*b. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas. With the right side as the baseline, let the width and height of the base frame be Lk and Lg, respectively, the number of frames in the remaining frame sequence be n, and the pixel width and height of the remaining frame sequence be a and b. The number of frames that can be arranged vertically side-by-side is int(Lg / b), and the number of frames that can be arranged horizontally side-by-side is int(n / int(Lg / b))+1; The width of the new canvas is Lk+(int(n / int(Lg / b))+1)*a, and the height is Lg. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas.

2. The dynamic image compression method according to claim 1, characterized in that, In step S1, if no user sets a detection threshold and a similarity threshold, the detection threshold is set to 10MB by default, and the similarity threshold is set to 90 by default.

3. The dynamic image compression method according to claim 1, characterized in that, In step S5, the formula for calculating the target similarity threshold is: in, The target similarity threshold, For the set similarity threshold, , These represent the pixel width and height of a single frame, respectively. Average pixel smoothness, Standard pixel count, Standard smoothness; During the frame traversal, the color value (R, B, G) of each pixel in the frame is used as a three-dimensional vector. The cosine similarity of the same position in two frames is calculated according to the position. The number of pixels whose similarity exceeds the target similarity threshold Cr is recorded. Finally, the ratio of the number of similar pixels to the total number of pixels is calculated. If the value is equal to or greater than 95%, the frame is discarded; otherwise, the frame is recorded in a new frame sequence. After traversal is complete, insert the first frame and generate a new frame sequence, called the remaining frame sequence.

4. A dynamic image compression system, characterized in that, include: The reading module is used to read raw dynamic image data and set detection thresholds and similarity thresholds; If the original dynamic image data is greater than or equal to the detection threshold, compression is terminated; The conversion module is used to convert the read binary data into matrix data in the RGB color space; The recording module is used to extract the matrix data of each frame sequentially and record the frame number and the number of pixels in width and height. The cropping module is used to compare subsequent frames sequentially with the first frame as a reference, recording the positions where pixels are inconsistent; the final set of positions is called the set of positions that cannot be removed. Based on this, the first frame data is copied as the base frame, and the minimum and maximum positions in the set are used as the cropping coordinates to crop the image pixel matrix of each frame of the original frame sequence that does not contain the base frame, generating a new image data matrix sequence. The traversal module is used to calculate a suitable target similarity threshold based on the set similarity threshold and the specific data of the image; then, it performs frame traversal on the cropped new data matrix, using the first frame as a reference, and calculates the cosine similarity between the subsequent frames and the first frame; frames with cosine similarity values ​​equal to or exceeding the target similarity threshold are discarded, and frames with cosine similarity values ​​lower than the target similarity threshold are retained to generate a new frame sequence, called the co-frame sequence; The stitching module is used to generate a new canvas based on the recorded frame width and height data, and stitch the base frame and the remaining frame sequences onto the new canvas according to the longest baseline stitching method to generate a new single image; The export module is used to export new single images to subsequent image content recognition models; There are two cases for the splicing method: if the number of pixels at the bottom edge of the base frame is greater than that at the right edge, then the bottom edge is used as the baseline to calculate the number of horizontally parallel frames in the remaining frame sequence. If the number of right pixels of the base frame is greater than or equal to the number of bottom pixels, then the number of vertically parallel frames in the remaining frame sequence is calculated with the right side as the baseline. Then, an empty pixel matrix is ​​generated according to the calculated new canvas size, and the base frame and the remaining frame sequences are sequentially concatenated into the empty pixel matrix. Convert this pixel matrix back to binary data and save it as a single stitched image in JPG format; With the bottom edge as the baseline, let the width and height of the base frame be Lk and Lg, respectively, the number of frames in the remaining frame sequence be n, and the pixel width and height of the remaining frame sequence be a and b. The number of frames that can be arranged horizontally in the remaining frame sequence is int(Lk / a), where int() represents rounding down the data inside the function. The number of frames that can be arranged vertically is int(n / int(Lk / a))+1. The width of the new canvas is Lk, and the height is Lg+(int(n / int(Lk / a))+1)*b. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas. With the right side as the baseline, let the width and height of the base frame be Lk and Lg, respectively, the number of frames in the remaining frame sequence be n, and the pixel width and height of the remaining frame sequence be a and b. The number of frames that can be arranged vertically side-by-side is int(Lg / b), and the number of frames that can be arranged horizontally side-by-side is int(n / int(Lg / b))+1; The width of the new canvas is Lk+(int(n / int(Lg / b))+1)*a, and the height is Lg. The size of the new canvas and the specific stitching position of each frame are determined based on the width and height of the new canvas.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements a dynamic image compression method according to any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements a dynamic image compression method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Compressing images in documents

    CN101331480A

  • Dynamic image compression method and device, computer equipment and storage medium

    CN109429067A