CN113068040A - Image compression method and device, electronic equipment and readable storage medium - Google Patents

Image compression method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN113068040A
CN113068040A CN202110613360.9A CN202110613360A CN113068040A CN 113068040 A CN113068040 A CN 113068040A CN 202110613360 A CN202110613360 A CN 202110613360A CN 113068040 A CN113068040 A CN 113068040A
Authority
CN
China
Prior art keywords
image
target
compressed
image block
historical
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110613360.9A
Other languages
Chinese (zh)
Inventor
魏红杨
张贞雷
于锦辉
袁秀阳
宋金凤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202110613360.9A priority Critical patent/CN113068040A/en
Publication of CN113068040A publication Critical patent/CN113068040A/en
Priority to PCT/CN2021/127411 priority patent/WO2022252488A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/85Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression
    • H04N19/86Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression involving reduction of coding artifacts, e.g. of blockiness

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The application discloses an image compression method, an image compression device, electronic equipment and a computer readable storage medium, wherein the method comprises the following steps: acquiring an image to be compressed, and performing blocking processing on the image to be compressed to obtain a plurality of image blocks; comparing each image block with the corresponding historical image block to obtain a comparison result; updating corresponding target historical image blocks for different target image blocks by using the comparison result, and coding the target image blocks to obtain target codes; generating compressed data corresponding to the image to be compressed by using the target code and the preset code; according to the method, each part in the data to be compressed is compared with the historical image blocks, and the changed target image blocks are compressed and encoded, so that the number of the image blocks needing to be compressed and encoded is reduced, the consumption of computing resources is reduced, the time required for generating the compressed data is reduced, and the time delay of the video displayed by the remote terminal is reduced.

Description

Image compression method and device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to an image compression method, an image compression apparatus, an electronic device, and a computer-readable storage medium.
Background
A Baseboard Management Controller (BMC) Management system may provide remote display and control functions, typically implemented by a KVM (Keyboard Video Mouse), which can provide real motherboard level access. The KVM over IP solution can convert analog information such as video and control signals of a connected managed object into digital signals, and compress them into one IP packet and transmit it through a network. The administrator can see the current information state of the managed object through the control screen of the remote terminal, and then send a series of control commands to control the managed object by using a local keyboard and a local mouse.
In order to achieve the above effect, in the related art, the BMC controller needs to compress each image in the acquired video stream, and send compressed data to the remote terminal after compression, so that the remote terminal can display the video. However, compressing the images consumes more computing resources, and the number of images in the video stream is larger, and the compression requires a certain time, so the time required for transmitting the images in the video stream to the remote terminal is longer, which causes the video displayed by the remote terminal to have longer time delay.
Therefore, the problems of the related art that the consumption of computing resources is large and the video delay of the terminal is large are technical problems to be solved by those skilled in the art.
Disclosure of Invention
In view of the above, an object of the present application is to provide an image compression method, an image compression apparatus, an electronic device, and a computer-readable storage medium, which compare various parts in data to be compressed with historical image blocks and compress and encode changed target image blocks, so as to reduce the number of image blocks that need to be compressed and encoded, thereby reducing the consumption of computing resources and reducing the time delay of videos displayed by remote terminals.
In order to solve the above technical problem, the present application provides an image compression method, including:
acquiring an image to be compressed, and carrying out blocking processing on the image to be compressed to obtain a plurality of image blocks;
comparing each image block with the corresponding historical image block to obtain a comparison result;
updating corresponding target historical image blocks for different target image blocks by using the comparison result, and coding the target image blocks to obtain target codes;
and generating compressed data corresponding to the image to be compressed by using the target code and a preset code.
Optionally, the method further comprises:
sending the compressed data and the comparison result to a remote terminal so that the remote terminal can analyze the compressed data to obtain the target image block, displaying the image to be compressed by using the historical image block, the target image block and the comparison result stored in the remote terminal, and updating the historical image block stored in the remote terminal by using the target image block.
Optionally, the updating, by using the comparison result, the corresponding target historical image block for the different target image blocks includes:
and covering the target historical image blocks in the cache by using the target image blocks.
Optionally, the encoding the target image block to obtain a target code includes:
if all the target historical image blocks are updated, reading the target image blocks from the cache according to the comparison result;
and carrying out frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
Optionally, the generating, by using the target code and a preset code, compressed data corresponding to the image to be compressed includes:
splicing the target code and the preset code according to the comparison result to obtain initial compressed data;
and adding a file header to the initial compressed data to obtain the compressed data.
Optionally, before the comparing the image blocks with the corresponding historical image blocks, the method further includes:
judging whether the image to be compressed is a first image or not;
if the image block is the first image, determining all the image blocks as target image blocks;
and if the image block is not the first image, comparing each image block with the corresponding historical image block.
Optionally, the comparing each image block with the corresponding historical image block to obtain a comparison result includes:
judging whether the corresponding pixel data of each pixel in the image block and the historical image block are the same or not;
if all the comparison results are the same, determining that the comparison results are the same;
and if the corresponding pixel data of at least one pixel in the image block and the historical image block are different, determining that the comparison result is different.
The present application also provides an image compression apparatus, including:
the device comprises a blocking module, a compression module and a compression module, wherein the blocking module is used for acquiring an image to be compressed and blocking the image to be compressed to obtain a plurality of image blocks;
the comparison module is used for comparing each image block with the corresponding historical image block to obtain a comparison result;
the coding module is used for updating corresponding target historical image blocks for different target image blocks by using the comparison result and coding the target image blocks to obtain target codes;
and the generating module is used for generating compressed data corresponding to the image to be compressed by utilizing the target code and a preset code.
The present application further provides an electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the image compression method.
The present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the image compression method described above.
The image compression method provided by the application obtains an image to be compressed, and blocks the image to be compressed to obtain a plurality of image blocks; comparing each image block with the corresponding historical image block to obtain a comparison result; updating corresponding target historical image blocks for different target image blocks by using the comparison result, and coding the target image blocks to obtain target codes; and generating compressed data corresponding to the image to be compressed by using the target code and the preset code.
Therefore, in the method, after the image to be compressed is obtained, the whole image is not directly compressed, but is partitioned to obtain a plurality of image blocks. In a KVM application scenario, adjacent images in a video stream generally do not change much, so after an image to be compressed is blocked, the image to be compressed and a corresponding historical image block can be compared to obtain a corresponding comparison result, and the image block with the different comparison result is determined as a target image block. When the comparison result is different, the situation recorded in the image block is changed compared with the historical image block, so that the corresponding target historical image block is updated by using the situation, and the judgment is carried out during the subsequent image transmission. And simultaneously, encoding the target image block to complete the compression of the target image block to obtain a corresponding target code so as to generate compressed data in the following process. After the target code is obtained, since the image block with the same comparison result is not different from the historical image block, in order to reduce the consumption of computing resources, the image block may not be encoded, but directly replaced by the preset code, so as to reduce the computing resources consumed in the encoding process, that is, the target code and the preset code are directly used to generate compressed data. By comparing each part in the data to be compressed with the historical image blocks and compressing and encoding the changed target image blocks, the number of the image blocks needing to be compressed and encoded is reduced, so that the consumption of computing resources is reduced, the time required for generating the compressed data is reduced, the time delay of the video displayed by the remote terminal is reduced, and the problems of high consumption of computing resources and high time delay of the video of the terminal in the related art are solved.
In addition, the application also provides an image compression device, an electronic device and a computer readable storage medium, which also have the beneficial effects.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or related technologies of the present application, the drawings needed to be used in the description of the embodiments or related technologies are briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of an image compression method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a related art image compression and forwarding process provided in an embodiment of the present application;
FIG. 3 is a flowchart of a specific image compression method according to an embodiment of the present disclosure;
fig. 4 is a schematic diagram of a specific image compression and forwarding process provided in an embodiment of the present application;
fig. 5 is a schematic structural diagram of an image compression apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of an image compression method according to an embodiment of the present disclosure. The method comprises the following steps:
s101: and acquiring an image to be compressed, and performing blocking processing on the image to be compressed to obtain a plurality of image blocks.
The image to be compressed refers to an image that needs to be compressed to obtain corresponding compressed data. The image to be compressed may be in any data format, for example, may be in jpeg (joint Photographic Experts group) format, or may be in png (portable network graphics) format, or may be in other data formats. The number of the images to be compressed is not limited, and may be one or more, and when the number of the images to be compressed is multiple, the sequence information between the images to be compressed is obtained simultaneously in the process of obtaining the images to be compressed. When the image block is processed, the image blocks need to be sequentially processed according to the sequence information so as to accurately determine the historical image block and the target image block in the subsequent process.
As for the obtaining manner of the image to be compressed, in an embodiment, the image to be compressed may be obtained from a specified storage path, where the specified storage path may be a local memory path, a hard disk path, or an external storage path. In another embodiment, an image to be compressed sent by other electronic devices or other components may be received. For example, an image to be compressed sent by a camera component, a CPU (i.e., a processor), and the like can be received.
It should be noted that, in this embodiment, the images to be compressed are all image frames in the video stream in the KVM scene. Because adjacent images in a video stream usually do not change greatly in a KVM application scenario, when an image is compressed, only a different portion of the image to be compressed and a historical image may be compressed, thereby reducing the computational resources and time required for compressing the image. It can be understood that, if the whole image to be compressed as a whole is divided from the historical image by whether a different part exists, the whole image to be compressed also needs to be compressed as a whole during compression, which cannot achieve the effect of reducing the calculation resources and time required by compressing the image, so that the image to be compressed needs to be subjected to blocking processing to obtain a plurality of image blocks, and each image block is used as an independent comparison unit to be compared with the corresponding historical image block.
In a feasible implementation manner, the length and width of the image to be compressed may be detected, and the length and width of the image to be compressed are equally divided according to the preset number of times of dividing the length and width to obtain the length and width of each image block, and a certain point on the image to be compressed is used as a coordinate origin to perform blocking. The origin of coordinates can be the center point, four corners, and the like of the image to be compressed. In another embodiment, the size of each image block may be preset, and after the image to be compressed is obtained, the image to be compressed is partitioned according to the preset size of the image block from the origin of coordinates, where the sizes of the image blocks may be the same or different. In addition, before or after the image is divided into blocks, a certain process, such as a pre-process of data format conversion before the image is divided into blocks or a post-process of data format conversion after the image is divided into blocks, may be performed. It should be noted that the blocking method should be fixed, that is, all the images to be compressed should be subjected to the blocking process in the same sampling blocking method.
S102: and comparing each image block with the corresponding historical image block to obtain a comparison result.
In order to determine whether the content of the image block record changes, reference data for comparison with the image block, namely historical image blocks, also needs to be present. The historical image blocks refer to image blocks used to compose the latest image. The latest image refers to the image to be compressed which is the latest before the current image to be compressed. It can be understood that, if none of the images to be compressed before the current image to be compressed has changed, the historical image block is actually an image block constituting a plurality of images to be compressed before the moment.
The corresponding relation between the image block and the historical image block refers to the corresponding position relation between the image block and the historical image block in the image to be compressed. Specifically, after the image to be compressed is subjected to the blocking processing, each image block may be marked, and the specific content of the mark is related to the specific position of the image block in the image to be compressed. By marking the image blocks, historical image blocks corresponding to the image blocks can be determined according to the marks during comparison, and whether the contents recorded by the image blocks and the historical image blocks are the same or not is further judged. For the specific form of the mark, a digital number form may be adopted, or a coordinate form and the like may be adopted, and the specific form of the mark may be set according to actual needs.
The comparison result is used for indicating whether the contents of the image block and the historical image block are the same, the form of the comparison result is not limited, for example, a digital form can be adopted, 1 is used for indicating the same, and 0 is used for indicating the different; or may take the form of text. In this embodiment, history image blocks with different comparison results may be referred to as target image blocks. In a specific embodiment, a register set block _ flag may be set, which is used to store the comparison result. And block _ flag [ i ] [ j ] represents a comparison result corresponding to the image block in the ith row and the jth column.
As to a specific comparison manner, in an embodiment, the image block and the historical image block may be encoded, whether the corresponding codes of the image block and the historical image block are the same or not is determined, and if the codes of the image block and the historical image block are the same, the comparison result is determined to be the same. In another embodiment, in order to determine the reliability and accuracy of the comparison, the pixel data of each corresponding pixel in the image block and the historical image block may be compared. Specifically, the process of comparing each image block with the corresponding historical image block to obtain the comparison result may include the following steps:
step 11: and judging whether the corresponding pixel data of each pixel in the image block and the historical image block are the same or not.
Step 12: if the two are the same, the comparison result is determined to be the same.
Step 13: and if the corresponding pixel data of at least one pixel in the image block and the historical image block are different, determining that the comparison result is different.
In this embodiment, since the image block and the history image block are obtained in the same blocking manner, both have the same number of pixels. Each pixel has corresponding pixel data for representing the state of the pixel, and the length, the actual meaning, the data format and the like of the pixel data can be different according to different specific formats of the images to be compressed. It can be determined that there are a plurality of pixels in the image block, and therefore, when performing the alignment, it is necessary to determine whether the pixel data between each pixel in the image block and the corresponding pixel in the history image block are the same one by one. If it is detected that corresponding pixel data of any one pixel in the image block and the historical image block are different, it can be determined that a difference exists between the image block and the historical image block, and comparison results are different. If the pixel data of all the pixels in the image block and the historical image block are the same, it can be determined that the comparison results are the same.
It should be noted that, in a special case, when the image to be compressed is the first frame image in the video stream, since it must be compressed, the comparison with the historical image block will result in a waste of computing resources. Therefore, before comparing each image block with the corresponding historical image block, the following steps may also be included:
step 21: and judging whether the image to be compressed is the first image.
Step 22: and if the image block is the first image, determining all the image blocks as target image blocks.
Step 23: and if the image is not the first image, comparing each image block with the corresponding historical image block.
The first picture is the first picture in the video stream. The embodiment does not limit the specific determination manner for determining whether the image to be compressed is the first image, and in one embodiment, the images in the video stream may have frame number numbers, and whether the image to be compressed is the first image may be determined by determining whether the frame number of the image to be compressed is the minimum number. In another embodiment, when the image to be compressed is the first image, the history image block corresponding to the image to be compressed does not exist, so that whether the image to be compressed is the first image can be determined by determining whether the history image block exists.
If the image to be compressed is not the first image, the image block can be compared with the historical image block. If the image to be compressed is the first image, it can be directly determined that all image blocks need to be compressed, and therefore, the image blocks are directly determined as target image blocks so as to be compressed in the subsequent steps.
S103: and updating corresponding target historical image blocks for different target image blocks by using the comparison result, and coding the target image blocks to obtain target codes.
And after the comparison result is determined, determining the image blocks with different comparison results as target image blocks, wherein the target historical image blocks refer to historical image blocks corresponding to the target image blocks. In order to continue to process a new image to be compressed subsequently, the target image block is required to be used for updating the corresponding target historical image block, so that when a new image to be processed is processed in the future, the historical image block can form a latest image, namely the current image to be compressed.
The updating of the target historical image block, that is, the replacing of the target historical image block, may be, in an embodiment, replacing of the content of the target historical image block, that is, directly covering the target historical image block with the target image block. In another embodiment, the identity of the target historical image block may be replaced, that is, the current content of the target historical image block is not processed, but the identity of the historical image block is deprived, and the identity of the historical image block is given to the target image block. The identity can be deprived and given by deleting and adding the mark, and it can be understood that no matter which embodiment is adopted to replace the target historical image block, the target image block needs to be stored so as to be compared in a subsequent call.
The encoding of the target image block refers to compression encoding, and the specific encoding mode is not limited, and the purpose is to save storage space, and the specific encoding mode may also be different according to different data types of the target image block, for example, huffman encoding may be adopted. For example, in an embodiment, in order to compress the target image block as much as possible, the target image block may be subjected to a certain pre-processing, and part of the data may be discarded. It should be noted that, in this embodiment, the execution order of the operation of encoding the target image block and the operation of updating the historical image block is not limited, and the execution order of the target image block and the historical image block may be determined according to needs. Because only the target image block is coded, the time length required by coding is greatly reduced compared with the time length for coding the whole image to be compressed, and the image compression speed is improved.
Specifically, in a possible embodiment, in order to reduce the occupation of the storage space and increase the speed of image compression, the history image blocks may be stored in the cache, in which case, the process of updating the corresponding target history image blocks for different target image blocks by using the comparison result may include the following steps:
step 31: and covering the target historical image blocks in the cache by using the target image blocks.
By covering the target image block with the target image block, the occupied storage space is not expanded due to updating of the historical image block. Meanwhile, the historical image blocks are stored in the cache, so that the reading and writing speeds of the historical image blocks can be increased, and the image compression speed is increased.
Based on the above embodiments, a failure, such as an encoding failure, may occur due to the process of encoding the image block. In the BMC controller, each step is usually executed serially, so to prevent possible failures such as image block loss due to an image block coding error, the historical image block may be updated first and then encoded. Specifically, the process of encoding the target image block to obtain the target code may include the following steps:
step 41: and if all the target historical image blocks are updated, reading the target image blocks from the cache according to the comparison result.
Step 42: and carrying out frequency domain transformation, quantization and coding processing on the target image block to obtain a target code.
In this embodiment, when all the target historical image blocks are updated, the target image block may be read from the cache according to the comparison result, and it can be understood that the target image block is the same as the target historical image block at this time.
Because human eyes are not sensitive to high-frequency information, when a target image block is coded, data in a high-frequency region can be abandoned through combined processing of frequency domain transformation and quantization, and the performance of compression operation is improved. Specifically, the frequency domain transform may also be referred to as a DCT transform, which is a processing method capable of converting image data from a time domain to a frequency domain. Quantization, which is a processing mode of filtering and discarding the high frequency region data of the frequency domain data, is used in combination with frequency domain transformation to jointly complete the deletion of the high frequency data in the target data block. The encoding specifically refers to a processing method of converting data according to the use frequency of the characters so as to maximally save the storage space of the characters, and the specific method is not limited, and for example, a huffman encoding method may be used.
S104: and generating compressed data corresponding to the image to be compressed by using the target code and the preset code.
The preset code is used for filling a part corresponding to a non-target image block in the compressed data. The compressed data needs to be analyzed by the remote terminal so as to be displayed, so that the compressed data needs to conform to the format of the normal image compressed data so that the remote terminal can correctly decompress the compressed data, and the normal image compressed data comprises codes corresponding to all image blocks in the whole image to be compressed. In order to reduce the time required by image compression, the non-target image block is not encoded in the present application, so that in order to enable the remote terminal to decompress normally, the portion corresponding to the non-target image block in the compressed data may be filled with the preset code, so that the compressed data composed of the target code and the preset code conforms to the format of the normal image compressed data. The specific content of the preset code is not limited, and for example, the preset code may be all-zero code or all-one code.
The embodiment does not limit the specific generation process of the compressed data, and the specific generation process of the compressed data may be different according to different formats of the image to be compressed. In one possible embodiment, when the image to be compressed is in JPEG format, the process of generating compressed data corresponding to the image to be compressed by using the target encoding and the preset encoding may include the following steps:
step 51: and splicing the target code and the preset code according to the comparison result to obtain initial compressed data.
Step 52: and adding a file header to the initial compressed data to obtain compressed data.
In this embodiment, the target code may be spliced with a preset code to obtain a coded sequence, and a position of the target code in the coded sequence corresponds to a position of the target image block in the image to be compressed. The comparison result may indicate which image block is the target image block, and the identification information (e.g., number) of the target image block is related to the position of the target image block in the image to be compressed, so that the position of the target image block in the image to be compressed may be determined according to the identification information. After the coding sequence is obtained, a file header can be added, wherein the file header comprises information such as an image start flag bit, a length, a quantization table and the like. And after the file header is added, obtaining compressed data.
Furthermore, since the obtained compressed data only includes valid data corresponding to the target image block, and valid data corresponding to non-target image blocks does not exist, the remote terminal should also store the historical image block so as to obtain the image to be compressed by splicing the historical image block with the target image block.
In one embodiment, in order to increase the reading speed of the remote terminal on the compressed data and enable the remote terminal to accurately determine that the portions of the compressed data are the portions corresponding to the target data block, the comparison result may be sent to the remote terminal while the compressed data is transmitted. Specifically, the present embodiment may further include the following steps:
step 61: and sending the compressed data and the comparison result to the remote terminal so that the remote terminal can analyze the compressed data to obtain a target image block, displaying the image to be compressed by using the historical image block, the target image block and the comparison result stored in the remote terminal, and updating the historical image block stored in the remote terminal by using the target image block.
By obtaining the comparison result, the target image block corresponding to the data in the compressed data can be determined according to the comparison result, and the target image block is restored to obtain the corresponding target image block. Meanwhile, the position of the target image block in the image to be compressed can be determined based on the comparison result, and the image to be compressed is displayed by utilizing the target image block and the historical image block and the target image block which are locally stored in the remote terminal. According to the embodiment, the remote terminal does not need to identify the preset codes in the compressed data, the display speed is improved, and meanwhile, the problem that the target codes of a certain target image block are exactly the same as the preset codes, such as all zero codes, and then the target codes are identified as the remote codes by mistake by the remote terminal, so that the display errors of the image to be compressed are caused is solved.
By applying the image compression method provided by the embodiment of the application, after the image to be compressed is obtained, the whole image is not directly compressed, but is partitioned to obtain a plurality of image blocks. In a KVM application scenario, adjacent images in a video stream generally do not change much, so after an image to be compressed is blocked, the image to be compressed and a corresponding historical image block can be compared to obtain a corresponding comparison result, and the image block with the different comparison result is determined as a target image block. When the comparison result is different, the situation recorded in the image block is changed compared with the historical image block, so that the corresponding target historical image block is updated by using the situation, and the judgment is carried out during the subsequent image transmission. And simultaneously, encoding the target image block to complete the compression of the target image block to obtain a corresponding target code so as to generate compressed data in the following process. After the target code is obtained, since the image block with the same comparison result is not different from the historical image block, in order to reduce the consumption of computing resources, the image block may not be encoded, but directly replaced by the preset code, so as to reduce the computing resources consumed in the encoding process, that is, the target code and the preset code are directly used to generate compressed data. By comparing each part in the data to be compressed with the historical image blocks and compressing and encoding the changed target image blocks, the number of the image blocks needing to be compressed and encoded is reduced, so that the consumption of computing resources is reduced, the time required for generating the compressed data is reduced, the time delay of the video displayed by the remote terminal is reduced, and the problems of high consumption of computing resources and high time delay of the video of the terminal in the related art are solved.
Referring to fig. 2, fig. 2 is a schematic diagram of an image compression and forwarding process according to the related art provided in the embodiment of the present application. The whole process of compressing and forwarding the image by the BMC controller in the related art is described. After obtaining image Data (in this embodiment, specifically, in JPEG format), a host (i.e., a CPU) transmits the image Data to a VGA (Video Graphics Array) controller (process 1), the VGA controller processes the Video Data, stores the processed Video Data in an external DDR (Double Data Rate, which is a unique memory space of the VGA controller), reads the stored image information from the external DDR and reads out the image information (process 3), and converts the image information into a DVI (Digital Visual Interface) signal according to a VSEA standard (Video Electronics Standards Association ), and outputs the DVI signal to an external display screen through a VGA Interface (process 2). The video compression controller captures image information from a DVI interface given by the VGA controller (process 4), then the compressed image data is stored in an external DDR of the BMC system through processes of YUV conversion, JPEG image compression and the like (steps 5 and 6, the DDR is a memory space used by the BMC system). Referring to fig. 3, fig. 3 is a flowchart illustrating an exemplary image compression method according to an embodiment of the present disclosure. Specifically, the image compression process in the JPEG format comprises the following steps:
(1) RGB2 YUV: the method is a process of converting an RGB format into a YUV format to obtain a YUV image, VGA video source data is in the RGB format, and each pixel point has three base colors of red, green and blue; the JPEG file is represented by YUV color space, Y represents brightness, and U and V represent chroma. Because human eyes are more sensitive to luminance differences than to color variations, some chrominance information can be properly removed when sampling.
(2) 8 by 8block conversion: JPEG compression is performed in units of 8 × 8 blocks, i.e., blocks an image.
(3) DCT transformation: and the conversion from time domain to frequency domain is beneficial to removing high-frequency information which has small influence on human eyes.
(4) And (3) quantification: the process of discarding the high frequency region data in conjunction with the DCT transform is called quantization.
(5) And (3) encoding: the main objective is to maximally save the storage space of characters (codes) according to the frequency of use. Usually with huffman coding.
(6) Adding a file header: including information such as the start flag, length, quantization table, etc.
An application program running on an ARM (Advanced RISC Machines, ARM processor) reads compressed image data from a DDR used by the BMC system by calling an ethernet controller, and decompresses the compressed data received by the remote terminal through ethernet transmission (processes 7 and 8), and displays the decompressed data on a screen.
Because the steps are required to be carried out on all the images, the time required by image compression is long, and further the image time delay on the remote terminal is large. Referring to fig. 4, fig. 4 is a schematic diagram illustrating a specific image compression and forwarding process according to an embodiment of the present application. The whole process comprises the following steps:
(1) the original image data obtained by the VGA controller is converted into DVI data and then transmitted to the Bolck conversion module, i.e., process 4.
(2) The Block conversion module is responsible for blocking and converting original image data into 8x8Block data. For the first frame of image data (i.e., the first image), the converted data is directly stored in the DDR (process 5). For the nth frame image (n > 1), the converted data is transmitted to the comparison module (process 6).
(3) The comparison module receives the nth frame image transmitted by the Block module, and fetches the historical image data from the DDR (process 7), and then compares each image Block of the nth frame image transmitted by the Block module with the historical image data fetched from the DDR, that is, compares in Block units. And meanwhile, a register group block _ flag is set for storing a comparison result, the size of the register is 32 bits, and the number of the registers is set according to the total number of pixels of the resolution divided by 64 pixels (the size of one block). And when the currently compared block blocks are the same, setting the corresponding block _ flag [ i ] [ j ] to be 0. If not, it is set to 1, and the block data is written to the corresponding position in the DDR, overwriting the history image data of the corresponding position (step 8).
(4) The video compression controller obtains a comparison result register group block _ flag of the nth frame image data and the historical image data generated by the comparison module, and data is taken from the DDR according to the comparison result, if the block _ flag [ i ] [ j ] is 1, the block data is taken from the corresponding DDR position, and if the block _ flag [ i ] [ j ] is 0, the block data does not need to be taken from the DDR.
(5) The compression process of the video compression controller is as follows: when the block _ flag [ i ] [ j ] is 1, compressing according to a normal process, when the block _ flag [ i ] [ j ] is 0, directly determining an encoding result as a damaged encoding without DCT (discrete cosine transformation), quantization and encoding, wherein the preset encoding is specifically a result obtained by encoding an 8x8block which is all 0. After the target image block is encoded, compressed data is generated and stored in the DDR (process 10).
(6) In the network transmission process, the block _ flag data of the comparison result register group needs to be transmitted first, and then the compressed data corresponding to the nth frame image needs to be transmitted.
(7) The remote terminal needs to store historical image data, decompresses the nth frame of compressed data after receiving the nth frame of compressed data, merges the decompressed nth frame of data and the historical data according to the received block _ flag information, uses the data of the nth frame of image for the current block when the block _ flag [ i ] [ j ] =1, and uses the data of the historical image for the current block when the block _ flag [ i ] [ j ] = 0. The combined results are then displayed.
The following describes an image compression apparatus provided in an embodiment of the present application, and the image compression apparatus described below and the image compression method described above may be referred to correspondingly.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an image compression apparatus according to an embodiment of the present disclosure, including:
the blocking module 110 is configured to obtain an image to be compressed, and perform blocking processing on the image to be compressed to obtain a plurality of image blocks;
the comparison module 120 is configured to compare each image block with a corresponding historical image block to obtain a comparison result;
the encoding module 130 is configured to update corresponding target historical image blocks for different target image blocks according to the comparison result, and encode the target image blocks to obtain target codes;
and a generating module 140, configured to generate compressed data corresponding to the image to be compressed by using the target code and the preset code.
Optionally, the method further comprises:
and the transmission module is used for sending the compressed data and the comparison result to the remote terminal so that the remote terminal can analyze the compressed data to obtain a target image block, displaying the image to be compressed by using the historical image block, the target image block and the comparison result stored in the remote terminal, and updating the historical image block stored in the remote terminal by using the target image block.
Optionally, the encoding module 130 includes:
and the covering and writing unit is used for covering the target historical image blocks in the cache by using the target image blocks.
Optionally, the encoding module 130 includes:
the reading unit is used for reading the target image blocks from the cache according to the comparison result if all the target historical image blocks are updated;
and the coding unit is used for carrying out frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
Optionally, the generating module 140 includes:
the splicing unit is used for splicing the target code and the preset code according to the comparison result to obtain initial compressed data;
and the file header adding unit is used for adding a file header to the initial compressed data to obtain the compressed data.
Optionally, the method further comprises:
the judging module is used for judging whether the image to be compressed is a first image;
the all-determining module is used for determining all image blocks as target image blocks if the image block is the first image;
correspondingly, the comparing module 120 is a module for comparing each image block with the corresponding historical image block if the image block is not the first image.
Optionally, the alignment module 120 includes:
the pixel data judging unit is used for judging whether the corresponding pixel data of each pixel in the image block is the same as the corresponding pixel data of the historical image block;
the identity determining unit is used for determining that the comparison results are the same if the identity is the same;
and the different determining unit is used for determining that the comparison result is different if at least one pixel has different corresponding pixel data in the image block and the historical image block.
The electronic device provided by the embodiment of the present application is introduced below, and the electronic device described below and the image compression method described above may be referred to correspondingly.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. Wherein the electronic device 100 may include a processor 101 and a memory 102, and may further include one or more of a multimedia component 103, an information input/information output (I/O) interface 104, and a communication component 105.
The processor 101 is configured to control the overall operation of the electronic device 100 to complete all or part of the steps in the image compression method; the memory 102 is used to store various types of data to support operation at the electronic device 100, such data may include, for example, instructions for any application or method operating on the electronic device 100, as well as application-related data. The Memory 102 may be implemented by any type or combination of volatile and non-volatile Memory devices, such as one or more of Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic or optical disk.
The multimedia component 103 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 102 or transmitted through the communication component 105. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 104 provides an interface between the processor 101 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 105 is used for wired or wireless communication between the electronic device 100 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 105 may include: Wi-Fi part, Bluetooth part, NFC part.
The electronic Device 100 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components, and is configured to perform the image compression method according to the above embodiments.
The following describes a computer-readable storage medium provided in an embodiment of the present application, and the computer-readable storage medium described below and the image compression method described above may be referred to correspondingly.
The present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the image compression method described above.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relationships such as first and second, etc., are intended only to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms include, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. An image compression method, comprising:
acquiring an image to be compressed, and carrying out blocking processing on the image to be compressed to obtain a plurality of image blocks;
comparing each image block with the corresponding historical image block to obtain a comparison result;
updating corresponding target historical image blocks for different target image blocks by using the comparison result, and coding the target image blocks to obtain target codes;
and generating compressed data corresponding to the image to be compressed by using the target code and a preset code.
2. The image compression method according to claim 1, further comprising:
sending the compressed data and the comparison result to a remote terminal so that the remote terminal can analyze the compressed data to obtain the target image block, displaying the image to be compressed by using the historical image block, the target image block and the comparison result stored in the remote terminal, and updating the historical image block stored in the remote terminal by using the target image block.
3. The image compression method according to claim 1, wherein the updating the corresponding target historical image block for a different target image block by using the comparison result includes:
and covering the target historical image blocks in the cache by using the target image blocks.
4. The image compression method of claim 3, wherein the encoding the target image block to obtain a target code comprises:
if all the target historical image blocks are updated, reading the target image blocks from the cache according to the comparison result;
and carrying out frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
5. The image compression method according to claim 1, wherein the generating of the compressed data corresponding to the image to be compressed by using the target encoding and a preset encoding comprises:
splicing the target code and the preset code according to the comparison result to obtain initial compressed data;
and adding a file header to the initial compressed data to obtain the compressed data.
6. The image compression method according to claim 1, further comprising, before the comparing each of the image blocks with the corresponding historical image block:
judging whether the image to be compressed is a first image or not;
if the image block is the first image, determining all the image blocks as target image blocks;
and if the image block is not the first image, comparing each image block with the corresponding historical image block.
7. The image compression method according to claim 1, wherein the comparing each image block with the corresponding historical image block to obtain a comparison result comprises:
judging whether the corresponding pixel data of each pixel in the image block and the historical image block are the same or not;
if all the comparison results are the same, determining that the comparison results are the same;
and if the corresponding pixel data of at least one pixel in the image block and the historical image block are different, determining that the comparison result is different.
8. An image compression apparatus, comprising:
the device comprises a blocking module, a compression module and a compression module, wherein the blocking module is used for acquiring an image to be compressed and blocking the image to be compressed to obtain a plurality of image blocks;
the comparison module is used for comparing each image block with the corresponding historical image block to obtain a comparison result;
the coding module is used for updating corresponding target historical image blocks for different target image blocks by using the comparison result and coding the target image blocks to obtain target codes;
and the generating module is used for generating compressed data corresponding to the image to be compressed by utilizing the target code and a preset code.
9. An electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor for executing the computer program to implement the image compression method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the image compression method according to any one of claims 1 to 7.
CN202110613360.9A 2021-06-02 2021-06-02 Image compression method and device, electronic equipment and readable storage medium Pending CN113068040A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110613360.9A CN113068040A (en) 2021-06-02 2021-06-02 Image compression method and device, electronic equipment and readable storage medium
PCT/CN2021/127411 WO2022252488A1 (en) 2021-06-02 2021-10-29 Image compression method and apparatus, electronic device, and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110613360.9A CN113068040A (en) 2021-06-02 2021-06-02 Image compression method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN113068040A true CN113068040A (en) 2021-07-02

Family

ID=76568529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110613360.9A Pending CN113068040A (en) 2021-06-02 2021-06-02 Image compression method and device, electronic equipment and readable storage medium

Country Status (2)

Country Link
CN (1) CN113068040A (en)
WO (1) WO2022252488A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113709490A (en) * 2021-07-30 2021-11-26 山东云海国创云计算装备产业创新中心有限公司 Video compression method, device, system and medium
CN114113106A (en) * 2021-11-12 2022-03-01 中冶赛迪技术研究中心有限公司 Method and system for automatically grading low-power structure quality of continuous casting billet
CN115171328A (en) * 2022-06-30 2022-10-11 国网北京市电力公司 Firework identification method, device, equipment and medium based on video compression coding
WO2022252488A1 (en) * 2021-06-02 2022-12-08 苏州浪潮智能科技有限公司 Image compression method and apparatus, electronic device, and readable storage medium
WO2023045168A1 (en) * 2021-09-22 2023-03-30 苏州浪潮智能科技有限公司 Image processing method and apparatus, and related assembly

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115883839B (en) * 2023-03-09 2023-06-06 湖北芯擎科技有限公司 Image verification method, device, equipment and computer readable storage medium
CN116346940B (en) * 2023-05-29 2023-08-22 德州禹工环保设备有限公司 Monitoring management system of smart sponge city

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103179402A (en) * 2013-03-19 2013-06-26 中国科学院半导体研究所 Video compression coding and decoding method and device
CN203416351U (en) * 2013-05-31 2014-01-29 江西省电力设计院 A power station workshop video monitoring system
CN105025269A (en) * 2015-07-26 2015-11-04 杜春辉 Low-flow image transmission method
CN105744281A (en) * 2016-03-28 2016-07-06 飞依诺科技(苏州)有限公司 Continuous image processing method and device
CN109862365A (en) * 2019-01-30 2019-06-07 西安万像电子科技有限公司 Image processing method and device
US20190179593A1 (en) * 2016-06-28 2019-06-13 Nexpoint Co., Ltd. Image compressing method, image reconstructing method, image compressing device, image reconstructing device, image compressing program product, and image reconstructing program product
CN110740335A (en) * 2019-09-02 2020-01-31 西安万像电子科技有限公司 Data transmission method, system and equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109842803B (en) * 2018-09-19 2021-06-29 华为技术有限公司 Image compression method and device
CN113068040A (en) * 2021-06-02 2021-07-02 苏州浪潮智能科技有限公司 Image compression method and device, electronic equipment and readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103179402A (en) * 2013-03-19 2013-06-26 中国科学院半导体研究所 Video compression coding and decoding method and device
CN203416351U (en) * 2013-05-31 2014-01-29 江西省电力设计院 A power station workshop video monitoring system
CN105025269A (en) * 2015-07-26 2015-11-04 杜春辉 Low-flow image transmission method
CN105744281A (en) * 2016-03-28 2016-07-06 飞依诺科技(苏州)有限公司 Continuous image processing method and device
US20190179593A1 (en) * 2016-06-28 2019-06-13 Nexpoint Co., Ltd. Image compressing method, image reconstructing method, image compressing device, image reconstructing device, image compressing program product, and image reconstructing program product
CN109862365A (en) * 2019-01-30 2019-06-07 西安万像电子科技有限公司 Image processing method and device
CN110740335A (en) * 2019-09-02 2020-01-31 西安万像电子科技有限公司 Data transmission method, system and equipment

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022252488A1 (en) * 2021-06-02 2022-12-08 苏州浪潮智能科技有限公司 Image compression method and apparatus, electronic device, and readable storage medium
CN113709490A (en) * 2021-07-30 2021-11-26 山东云海国创云计算装备产业创新中心有限公司 Video compression method, device, system and medium
WO2023045168A1 (en) * 2021-09-22 2023-03-30 苏州浪潮智能科技有限公司 Image processing method and apparatus, and related assembly
US11930198B2 (en) 2021-09-22 2024-03-12 Inspur Suzhou Intelligent Technology Co., Ltd. Image processing method and apparatus, and related assembly
CN114113106A (en) * 2021-11-12 2022-03-01 中冶赛迪技术研究中心有限公司 Method and system for automatically grading low-power structure quality of continuous casting billet
CN115171328A (en) * 2022-06-30 2022-10-11 国网北京市电力公司 Firework identification method, device, equipment and medium based on video compression coding
CN115171328B (en) * 2022-06-30 2023-11-10 国网北京市电力公司 Smoke and fire identification method, device, equipment and medium based on video compression coding

Also Published As

Publication number Publication date
WO2022252488A1 (en) 2022-12-08

Similar Documents

Publication Publication Date Title
CN113068040A (en) Image compression method and device, electronic equipment and readable storage medium
CN109040792B (en) Processing method for video redirection, cloud terminal and cloud desktop server
US9307244B2 (en) Data storage controlling device, data reading controlling device, and data storing method
CN113873252B (en) Image processing method and device, electronic equipment and storage medium
US20170359589A1 (en) Video data processing system
CN111510718B (en) Method and system for improving compression ratio through inter-block difference of image file
CN110166765B (en) Screen-patterned detection method, electronic device and readable storage medium
CN110555334B (en) Face feature determination method and device, storage medium and electronic equipment
CN111918065A (en) Information compression/decompression method and device
CN113469869B (en) Image management method and device
US20130251025A1 (en) Memory bandwidth reduction during video capture
CN105554375A (en) Method and device of video preview in digital video recorder
CN113554721A (en) Image data format conversion method and device
KR102185668B1 (en) Method and system for improving compression ratio through pixel conversion of image file
CN108668170B (en) Image information processing method and device, and storage medium
CN112911299B (en) Video code rate control method and device, electronic equipment and storage medium
CN113992951A (en) Screen projection method, projector and terminal equipment
CN114025172A (en) Video frame processing method and device and electronic system
CN107357906B (en) Data processing method and device and image acquisition equipment
CN112839227A (en) Image coding method, device, equipment and medium
CN115278264B (en) Image amplification and OSD superposition coding method and system
CN110830744B (en) Safety interaction system
CN114339226B (en) Method, device and medium for improving smoothness of picture
CN110830760B (en) Secure network data interaction system and method
JP2663922B2 (en) Video encoding device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210702