WO2022252488A1 - Image compression method and apparatus, electronic device, and readable storage medium - Google Patents

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

Info

Publication number
WO2022252488A1
WO2022252488A1 PCT/CN2021/127411 CN2021127411W WO2022252488A1 WO 2022252488 A1 WO2022252488 A1 WO 2022252488A1 CN 2021127411 W CN2021127411 W CN 2021127411W WO 2022252488 A1 WO2022252488 A1 WO 2022252488A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
target
compressed
image block
block
Prior art date
Application number
PCT/CN2021/127411
Other languages
French (fr)
Chinese (zh)
Inventor
魏红杨
张贞雷
于锦辉
袁秀阳
宋金凤
Original Assignee
苏州浪潮智能科技有限公司
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 苏州浪潮智能科技有限公司 filed Critical 苏州浪潮智能科技有限公司
Publication of WO2022252488A1 publication Critical patent/WO2022252488A1/en

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

Definitions

  • the present application relates to the technical field of image processing, and in particular to an image compression method, an image compression device, electronic equipment, and a computer-readable storage medium.
  • Baseboard Management Controller BMC, Baseboard Management Controller
  • BMC Baseboard Management Controller
  • KVM Keyboard Video Mouse, keyboard, video, mouse
  • the KVM over IP solution can convert analog information such as video and control signals of the connected managed objects into digital signals, and compress them into an IP packet and transmit it through the network.
  • the administrator can see the current information status of the managed object through the control screen of the remote terminal, and then use the local keyboard and mouse to issue a series of control commands to control the managed object.
  • the BMC controller in the related art needs to compress each image in the obtained video stream, and send the compressed data to the remote terminal after compression, so that the remote terminal can display the video.
  • image compression needs to consume more computing resources, and the number of images in the video stream is large, and the compression takes a certain amount of time. Therefore, it takes a long time for the images in the video stream to be transmitted to the remote terminal, which makes remote The video displayed by the terminal has a long delay.
  • the purpose of this application is to provide an image compression method, image compression device, electronic equipment and computer-readable storage medium, by comparing each part of the data to be compressed with the historical image blocks, and analyzing the occurred
  • the changed target image blocks are compressed and coded. Since the number of image blocks that need to be compressed and coded is reduced, the consumption of computing resources is reduced, and at the same time, the time delay of the video displayed by the remote terminal is reduced.
  • an image compression method including:
  • the compressed data corresponding to the image to be compressed is generated by using the target code and the preset code.
  • Sending the compressed data and the comparison result to a remote terminal so that the remote terminal parses the compressed data to obtain the target image block, and utilizes the historical image block and the target image block stored in the remote terminal
  • the image block and the comparison result display the image to be compressed, and use the target image block to update the historical image block stored in the remote terminal.
  • updating the corresponding target historical image blocks for different target image blocks by using the comparison results includes:
  • said encoding the target image block to obtain the target encoding includes:
  • the generating the compressed data corresponding to the image to be compressed by using the target encoding and the preset encoding includes:
  • the method before comparing each of the image blocks with corresponding historical image blocks, the method further includes:
  • comparing each of the image blocks with corresponding historical image blocks to obtain a comparison result includes:
  • the present application also provides an image compression device, including:
  • a block module configured to obtain an image to be compressed, and perform block processing on the image to be compressed to obtain a plurality of image blocks;
  • a comparison module configured to compare each of the image blocks with corresponding historical image blocks to obtain a comparison result
  • the encoding module is used to update the corresponding target historical image block for different target image blocks by using the comparison result, and encode the target image block to obtain the target code;
  • a generating module configured to generate compressed data corresponding to the image to be compressed by using the target code and the preset code.
  • the present application also provides an electronic device, including a memory and a processor, wherein:
  • the memory is used to store computer programs
  • the processor is configured to execute the computer program to implement the above image compression method.
  • the present application also provides a computer-readable storage medium for storing a computer program, wherein the above-mentioned image compression method is implemented when the computer program is executed by a processor.
  • the image compression method provided by this application obtains the image to be compressed, and performs block processing on the image to be compressed to obtain multiple image blocks; compare each image block with the corresponding historical image block to obtain the comparison result; use the comparison As a result, the corresponding target historical image blocks are updated for different target image blocks, and the target image blocks are coded to obtain target codes; the compressed data corresponding to the image to be compressed is generated by using the target codes and preset codes.
  • the entire image is not directly compressed, but is divided into blocks to obtain multiple image blocks.
  • the adjacent images in the video stream usually do not change greatly, so after the image to be compressed is divided into blocks, it can be compared with the corresponding historical image block to obtain the corresponding comparison result , and determine the image block whose comparison result is different as the target image block.
  • the comparison results are different, it means that the information recorded in the image block has changed compared with the historical image block, so it is used to update the corresponding target historical image block for judgment during subsequent image transmission.
  • the target image block is encoded to complete the compression of the target image block, and the corresponding target code is obtained, so as to generate compressed data subsequently.
  • the comparison result shows that there is no difference between the same image block and the historical image block, in order to reduce the consumption of computing resources, it is not necessary to encode it, but directly use the preset code to replace it, reducing the cost of the coding process. Consumed computing resources, that is, directly using the target encoding and preset encoding to generate compressed data.
  • the present application also provides an image compression device, an electronic device, and a computer-readable storage medium, which also have the above beneficial effects.
  • FIG. 1 is a flow chart of an image compression method provided in an embodiment of the present application
  • FIG. 2 is a schematic diagram of an image compression and forwarding process of a related technology provided by an embodiment of the present application
  • FIG. 3 is a specific image compression flowchart provided by the embodiment of the present application.
  • FIG. 4 is a schematic diagram of a specific image compression and forwarding process provided by the embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an image compression device provided in an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 1 is a flow chart of an image compression method provided by an embodiment of the present application.
  • the method includes:
  • S101 Acquire an image to be compressed, and perform block processing on the image to be compressed to obtain multiple 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 can be in any data format, such as JPEG (Joint Photographic Experts Group) format, PNG (Portable Network Graphics) format, or other data formats.
  • the number of images to be compressed is not limited, and may be one or more. When the number of images to be compressed is multiple, the sequence information among the images to be compressed will be acquired simultaneously during the process of obtaining the images to be compressed. When processing it, it needs to be processed sequentially according to the sequence information, so as to accurately determine the historical image block and the target image block subsequently.
  • the acquisition method of the image to be compressed in one embodiment, it may be acquired from a specified storage path, and the specified storage path may be a local memory path, a hard disk path, or an external storage path.
  • images to be compressed sent by other electronic devices or other components may be received.
  • an image to be compressed sent by a camera component, a CPU (that is, a processor) and the like may be received.
  • the images to be compressed in this embodiment are all image frames in the video stream in the KVM scenario.
  • the adjacent images in the video stream usually do not change greatly, so when compressing the image, only the difference between the image to be compressed and the historical image can be compressed, thereby reducing the need for compressing the image.
  • computing resources and time It can be understood that if the entire image to be compressed is taken as a whole and the historical image is divided into whether there is a difference or not, then the entire image to be compressed as a whole needs to be compressed during compression, which cannot achieve the required reduction of the compressed image.
  • the effect of computing resources and time length, so the image to be compressed needs to be divided into blocks to obtain multiple image blocks, and each image block is compared with the corresponding historical image block as a separate comparison unit.
  • the length and width of the image to be compressed can be detected, and the length and width of the image to be compressed can be divided according to the preset length and width. Perform equal division to obtain the length and width of each image block, and use a certain point on the image to be compressed as the origin of coordinates to divide into blocks.
  • the origin of the coordinates may be the center point of the image to be compressed, the vertices of the four corners, and the like.
  • the size of each image block can be preset. After the image to be compressed is obtained, the image to be compressed is divided into blocks according to the preset image block size from the coordinate origin, wherein the size of each image block Can be the same or different.
  • certain processing may be performed before or after the image is divided into blocks, such as preprocessing of data format conversion before the block, or postprocessing of data format conversion after the block.
  • the block method should be fixed, that is, all images to be compressed should be sampled in the same block method for block processing.
  • Historical image blocks refer to image blocks used to form the latest image.
  • the latest image refers to the latest image to be compressed before the current image to be compressed. It can be understood that, if none of the multiple images to be compressed before the current image to be compressed has changed, the historical image blocks are actually image blocks that constitute images to be compressed before multiple times.
  • the corresponding relationship between the image block and the historical image block refers to the corresponding positional relationship between the two in the image to be compressed.
  • 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.
  • the historical image block corresponding to the image block can be determined according to the mark during the comparison, and then it can be judged whether the recorded contents of the two are the same.
  • the specific form of the mark it may be in the form of a number, or in the form of coordinates, etc., and the specific form of the mark may be set according to actual needs.
  • the comparison result is used to indicate whether the content in the image block is the same as that in the historical image block.
  • the form of the comparison result is not limited. For example, it can be in digital form, using 1 to indicate the same and 0 to indicate different; or it can be in text form.
  • the historical image blocks whose comparison results are different may be called target image blocks.
  • a register group block_flag may be set, which is used to store the comparison result.
  • block_flag[i][j] indicates the comparison result corresponding to the image block in row i and column j.
  • the image block and the historical image block may be coded, and it is judged whether the codes corresponding to the two are the same, and if they are the same, the comparison result is determined to be the same.
  • the pixel data of each corresponding pixel in the image block and the historical image block may be compared.
  • 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 Determine whether each pixel in the image block is the same as the corresponding pixel data in the historical image block.
  • Step 12 If all are the same, determine that the comparison result is the same.
  • Step 13 If at least one pixel in the image block is different from the corresponding pixel data in the historical image block, determine that the comparison result is different.
  • the image block and the historical image block are obtained by using the same block division method, they have the same number of pixels.
  • Each pixel has corresponding pixel data, which is used to represent the state of the pixel.
  • the length, actual meaning, and data format of the pixel data can be different. It can be determined that there are multiple pixels in the image block, so when comparing, it is necessary to determine whether the pixel data between each pixel in the image block and the corresponding pixel in the historical image block are the same. If it is detected that any pixel in the image block is different from the corresponding pixel data in the historical image block, it can be determined that there is a difference between the two, and the comparison result is different. If all the pixels in the image block are the same as the corresponding pixel data in the historical image block, it can be determined that the comparison result is the same.
  • Step 21 Determine whether the image to be compressed is the first image.
  • Step 22 If it is the first image, determine all image blocks as target image blocks.
  • Step 23 If it is not the first image, perform a step of comparing each image block with the corresponding historical image block.
  • the first image is the first image in the video stream.
  • This embodiment does not limit the specific judgment method for judging whether the image to be compressed is the first image.
  • the image in the video stream may have a frame number. By judging whether the frame number of the image to be compressed is the minimum number In this way, it can be determined whether the image to be compressed is 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, so it is directly determined as the target image block for compression in subsequent steps.
  • an image block whose comparison result is different is determined as a target image block, and the target historical image block refers to a historical image block corresponding to the target image block.
  • the target image block In order to continue to process the new image to be compressed in the future, it is necessary to use the target image block to update the corresponding target historical image block, so that when the new image to be processed is processed in the future, the historical image block can form the latest image, that is, the current image to be compressed Compress images.
  • Updating the target historical image block is to replace the target historical image block.
  • the replacement referred to here may be the replacement of the content of the target historical image block, that is, directly use the target image block to cover the target history Image blocks.
  • the identity of the target historical image block can be replaced, that is, the content of the current target historical image block is not processed, but the identity of the historical image block is deprived, and the target image block is given a historical image block identity.
  • the deprivation and endowment of identity can be carried out by deleting the mark and adding the mark. It is understandable that no matter which of the above-mentioned implementation methods is used to replace the target historical image block, the target image block needs to be stored so that it can be compared in subsequent calls. right.
  • Encoding the target image block refers to compressing and encoding it.
  • the specific encoding method is not limited, and its purpose is to save storage space. Depending on the data type of the target image block, the specific encoding method can also be different. For example, Huffman coding.
  • the specific process of encoding is not limited. For example, in one embodiment, in order to compress the target image block as much as possible, certain preprocessing may be performed on the target image block, and part of the data may be discarded. It should be noted that this embodiment does not limit the execution order of the operation of encoding the target image block and the operation of updating the historical image block, and the execution order of the two operations can be determined according to needs. Since only the target image block is encoded, the time required for encoding is greatly reduced compared with the time for encoding the entire image to be compressed, which improves the speed of image compression.
  • the historical image blocks can be stored in the cache, in this case, the comparison results are different
  • the process of updating the corresponding target historical image block of the target image block may include the following steps:
  • Step 31 Overwrite the target historical image block in the cache with the target image block.
  • the update of the historical image block will not increase the occupied storage space.
  • the speed of reading and writing to them can be improved, thereby improving the speed of image compression.
  • faults may occur in the process of encoding image blocks, such as encoding failure.
  • each step is usually performed serially. Therefore, in order to prevent possible faults such as image block loss caused by image block encoding errors, historical image blocks can be updated first, and then encoded.
  • the process of encoding the target image block to obtain the target encoding may include the following steps:
  • Step 41 If all target historical image blocks have been updated, read the target image block from the cache according to the comparison result.
  • Step 42 Perform frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
  • the target image block when all target historical image blocks have been updated, the target image block can be read from the cache according to the comparison result. It can be understood that at this moment, the target image block and the target historical image block same.
  • frequency-domain transform may also be called DCT transform, and refers to a processing manner that can convert image data from time domain to frequency domain.
  • Quantization refers to the processing method of filtering and discarding the high-frequency data in the frequency domain data, which is used in combination with the frequency domain transformation to jointly complete the deletion of high-frequency data in the target data block.
  • Encoding specifically refers to a processing method that converts data according to the frequency of use of characters so as to save character storage space to the greatest extent. The specific method is not limited, for example, Huffman coding can be used.
  • S104 Generate compressed data corresponding to the image to be compressed by using the target encoding and the preset encoding.
  • the preset encoding is used to fill the part corresponding to the non-target image block in the compressed data. Since the remote terminal needs to analyze the compressed data in order to display it, the compressed data must conform to the format of the normal image compressed data, so that the remote terminal can decompress it correctly, and the normal image compressed data includes the entire image to be compressed Encoding corresponding to all image blocks. In order to reduce the time required for image compression, this application does not encode the non-target image blocks. Therefore, in order to enable the remote terminal to decompress normally, the part corresponding to the non-target image blocks in the compressed data can be filled with preset encoding.
  • the compressed data composed of target coding and preset coding conforms to the format of normal image compression data.
  • the specific content of the preset encoding is not limited, for example, it may be an encoding of all zeros, or an encoding of all ones.
  • This 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 the format of the image to be compressed.
  • the process of generating compressed data corresponding to the image to be compressed by using target encoding and preset encoding may include the following steps:
  • Step 51 According to the comparison result, splicing the target code and the preset code to obtain the initial compressed data.
  • Step 52 Add a file header to the initial compressed data to obtain compressed data.
  • the target code and the preset code can be spliced to obtain a code sequence, and the position of the target code in the code sequence corresponds to the position of the target image block in the image to be compressed.
  • the comparison result can indicate which image block is the target image block, and the identification information (such as number) of the target image block is related to the position of the target image block in the image to be compressed, so it can be used as a basis to determine the target image block in The position in the image to compress.
  • a file header can be added, and the file header includes information such as an image start flag, length, and quantization table. After the file header is added, the compressed data can be obtained.
  • the remote terminal since the obtained compressed data only includes the valid data corresponding to the target image block, and the valid data corresponding to the non-target image block does not exist, so the remote terminal should also store historical image blocks, so as to utilize its correlation with the target image block
  • the image to be compressed is obtained by splicing.
  • the remote terminal after receiving the target image block, the remote terminal also needs to use the target image block to update the target historical image block stored in the remote terminal to ensure that subsequent images can be displayed correctly.
  • this embodiment in order to improve the reading speed of the remote terminal to the compressed data, so that it can accurately determine which parts of the compressed data are the parts corresponding to the target data block, it can send the ratio to the result.
  • this embodiment may also include the following steps:
  • Step 61 Send the compressed data and the comparison result to the remote terminal, so that the remote terminal can analyze the compressed data to obtain the target image block, use the historical image block, target image block and comparison result stored in the remote terminal to display the image to be compressed, and use The target image block updates the historical image block stored in the remote terminal.
  • the comparison result By obtaining the comparison result, it can be determined according to the comparison result which data in the compressed data corresponds to the target image block, and restored to obtain the corresponding target image block. At the same time, based on the comparison result, the position of the target image block in the image to be compressed can be determined, and then the image to be compressed can be displayed by using it together with the historical image block and the target image block locally stored in the remote terminal.
  • This implementation mode does not require the remote terminal to identify the preset code in the compressed data by itself, which improves the display speed, and also avoids that the target code of a certain target image block is just the same as the preset code, for example, all zero codes, In turn, the remote terminal mistakenly recognizes the target code as the remote code, causing the problem that the image to be compressed is displayed incorrectly.
  • the image to be compressed After the image to be compressed is obtained, the entire image is not directly compressed, but is divided into blocks to obtain multiple image blocks.
  • the adjacent images in the video stream usually do not change greatly, so after the image to be compressed is divided into blocks, it can be compared with the corresponding historical image block to obtain the corresponding comparison result , and determine the image block whose comparison result is different as the target image block.
  • the comparison results When the comparison results are different, it means that the information recorded in the image block has changed compared with the historical image block, so it is used to update the corresponding target historical image block for judgment during subsequent image transmission.
  • the target image block is encoded to complete the compression of the target image block, and the corresponding target code is obtained, so as to generate compressed data subsequently.
  • the comparison result shows that there is no difference between the same image block and the historical image block, in order to reduce the consumption of computing resources, it is not necessary to encode it, but directly use the preset code to replace it, reducing the cost of the coding process. Consumed computing resources, that is, directly using the target encoding and preset encoding to generate compressed data.
  • FIG. 2 is a schematic diagram of an image compression and forwarding process of a related technology provided by an embodiment of the present application. It records the whole process of compressing and forwarding the image by the BMC controller in the related art.
  • Host computer being CPU
  • image data in this embodiment, specifically JPEG format
  • VGA controller Video Graphics Array, video graphics array controller
  • VGA controller sends video
  • the data is processed, it is stored in the external DDR (Double Data Rate, double-rate synchronous dynamic random access memory) (the external DDR is the unique memory space of the VGA controller), and then read from the external DDR
  • the stored image information is read out (process 3), and then converted into a DVI (Digital Visual Interface, Digital Video Interface) signal according to the VSEA standard (Video Electronics Standards Association), and converted into an analog signal by a digital-to-analog converter Output to an external display screen through the VGA interface (process 2).
  • DVI Digital Visual Interface, Digital Video Interface
  • VSEA Video Electronics Standards Association
  • the video compression controller captures image information from the DVI interface provided by the VGA controller (process 4), and then processes such as YUV conversion and JPEG image compression, and stores the compressed image data in the external DDR of the BMC system ( Steps 5 and 6, the DDR is the memory space used by the BMC system).
  • FIG. 3 is a specific image compression flowchart provided by the embodiment of the present application. Specifically, the image compression process in JPEG format is described, which includes the following steps:
  • RGB2YUV refers to the process of converting the RGB format to the YUV format to obtain the YUV image.
  • the VGA video source data is in the RGB format, and each pixel has three base colors of red, green, and blue; the JPEG file is composed of YUV
  • the color space to represent the color, Y represents the lightness, U and V represent the chroma. Because the human eye is more sensitive to brightness differences than to color changes, part of the chrominance information can be properly removed during sampling.
  • DCT transformation Time domain to frequency domain conversion, which is beneficial to remove high-frequency information that has little impact on the human eye.
  • Quantization Combined with DCT transformation, the process of discarding high-frequency data is called quantization.
  • Encoding The main purpose is to maximize the saving of character (encoding) storage space according to the frequency of use. Usually Huffman coding.
  • Add file header include information such as image start flag, length, quantization table, etc.
  • the application program running on the ARM reads the compressed image data from the DDR used by the BMC system by calling the Ethernet controller, and transmits the remote terminal through the Ethernet (process 7, 8 ), the remote terminal decompresses the compressed data after receiving it, and displays it on the screen.
  • ARM Advanced RISC Machines, ARM processor
  • FIG. 4 is a schematic diagram of a specific image compression and forwarding process provided by the embodiment of the present application. The whole process includes the following steps:
  • the Block conversion module is responsible for dividing the original image data into 8x8block data.
  • the converted data is directly stored in the DDR (process 5).
  • the transformed data is sent to the comparison module (process 6).
  • the comparison module receives the nth frame image sent by the Block module, and takes historical image data (process 7) from the DDR, and then compares each image block of the nth frame image sent by the Block module with the taken from the DDR Compare the historical image data, that is, compare in units of blocks.
  • the register group block_flag is set to store the comparison result.
  • the register size is 32 bits, and the number of registers is set according to the total number of resolution pixels divided by 64 pixels (the pixel size of a block).
  • set the corresponding block_flag[i][j] to 0. If not, set it as 1, and write the block data into the corresponding position in the DDR, covering the historical image data in the corresponding position (step 8).
  • the video compression controller obtains the comparison result register group block_flag of the nth frame image data and the historical image data generated by the comparison module, and takes data from the DDR according to the comparison result. If block_flag[i][j] is 1, then Take the block data from the corresponding DDR location, if block_flag[i][j] is 0, you don't need to take the block data from the DDR.
  • the compression process of the video compression controller is: when block_flag[i][j] is 1, then compress according to the normal process; when block_flag[i][j] is 0, DCT transformation and quantization are not required And encoding, directly determine the encoding result as a damaged encoding, and the preset encoding is specifically the result obtained by encoding an 8x8 block with all 0s. After the target image block is encoded, compressed data is generated and stored in the DDR (process 10).
  • the image compression device provided by the embodiment of the present application is introduced below, and the image compression device described below and the image compression method described above can be referred to in correspondence.
  • FIG. 5 is a schematic structural diagram of an image compression device provided in an embodiment of the present application, including:
  • a block module 110 configured to obtain an image to be compressed, and perform block processing on the image to be compressed to obtain a plurality of image blocks;
  • a comparison module 120 configured to compare each image block with a corresponding historical image block to obtain a comparison result
  • the encoding module 130 is used to update the corresponding target historical image block for different target image blocks by using the comparison result, and encode the target image block to obtain the target code;
  • the generating module 140 is configured to generate compressed data corresponding to the image to be compressed by using the target code and the preset code.
  • the transmission module is used to send the compressed data and the comparison result to the remote terminal, so that the remote terminal analyzes the compressed data to obtain the target image block, and uses the historical image block, target image block and comparison result stored in the remote terminal to display the image to be compressed, And use the target image block to update the historical image block stored in the remote terminal.
  • the coding module 130 includes:
  • the overwriting unit is used to overwrite the target historical image block in the cache with the target image block.
  • the coding module 130 includes:
  • the reading unit is used to read the target image block from the cache according to the comparison result if all target historical image blocks have been updated;
  • the coding unit is configured to perform frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
  • generating module 140 includes:
  • the splicing unit is used to splice the target code and the preset code according to the comparison result to obtain the initial compressed data
  • the file header adding unit is used for adding a file header to the initial compressed data to obtain compressed data.
  • Judging module used to judge whether the image to be compressed is the first image
  • All determination modules are used to determine that all image blocks are target image blocks if it is the first image
  • the comparison module 120 is a module for performing comparison between each image block and the corresponding historical image block if it is not the first image.
  • the comparison module 120 includes:
  • a pixel data judging unit for judging whether each pixel in the image block is the same as the corresponding pixel data in the historical image block;
  • the same determination unit is used to determine that the comparison result is the same if all are the same;
  • the difference determination unit is configured to determine that the comparison result is different if at least one pixel in the image block is different from the corresponding pixel data in 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 in correspondence.
  • 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 .
  • a multimedia component 103 may be included in the electronic device 100 .
  • I/O information input/information output
  • the processor 101 is used to control the overall operation of the electronic device 100, so as to complete all or part of the steps in the above image compression method;
  • the memory 102 is used to store various types of data to support the operation of the electronic device 100, these data For example, instructions for any application or method operating on the electronic device 100 may be included, as well as application-related data.
  • the memory 102 can be realized by any type of volatile or non-volatile storage device or their combination, such as Static Random Access Memory (Static Random Access Memory, SRAM), Electrically Erasable Programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (Read-Only Memory, One or more of Only Memory, ROM), magnetic memory, flash memory, magnetic disk or optical disk.
  • Static Random Access Memory Static Random Access Memory
  • SRAM Static Random Access Memory
  • EEPROM Electrically Erasable Programmable Read-Only Memory
  • EPROM Erasable Programmable Read-Only Memory
  • PROM Programmable Read-Only Memory
  • Read-Only Memory One or more of Only Memory, ROM
  • magnetic memory flash memory
  • flash memory magnetic disk or optical disk.
  • Multimedia components 103 may include screen and audio components.
  • the screen can be, for example, a touch screen, and the audio component is used for outputting and/or inputting audio signals.
  • an audio component may include a microphone for receiving external audio signals.
  • the received audio signal may be further stored in the memory 102 or sent via the communication component 105 .
  • the audio component 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, which may be a keyboard, a mouse, buttons, and the like. These buttons can 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 (Near Field Communication, NFC for short), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 105 may include: Wi-Fi parts, Bluetooth parts, NFC parts.
  • the electronic device 100 may be implemented by one or more Application Specific Integrated Circuit (ASIC for short), Digital Signal Processor (DSP for short), Digital Signal Processing Device (DSPD for short), Programmable Logic Device (Programmable Logic Device, PLD for short), Field Programmable Gate Array (Field Programmable Gate Array, FPGA for short), controller, microcontroller, microprocessor or other electronic components are implemented for implementing the above embodiments The image compression method given.
  • ASIC Application Specific Integrated Circuit
  • DSP Digital Signal Processor
  • DSPD Digital Signal Processing Device
  • PLD Programmable Logic Device
  • Field Programmable Gate Array Field Programmable Gate Array
  • FPGA Field Programmable Gate Array
  • the computer-readable storage medium provided by the embodiment of the present application is introduced below, and the computer-readable storage medium described below and the image compression method described above may be referred to in correspondence.
  • the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned image compression method are implemented.
  • the computer-readable storage medium may include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk, etc., which can store program codes. medium.
  • each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same or similar parts of each embodiment can be referred to each other.
  • the description is relatively simple, and for the related information, please refer to the description of the method part.
  • RAM random access memory
  • ROM read-only memory
  • EEPROM electrically programmable ROM
  • EEPROM electrically erasable programmable ROM
  • registers hard disk, removable disk, CD-ROM, or any other Any other known storage medium.

Landscapes

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

Abstract

The present application discloses an image compression method and apparatus, an electronic device, and a computer-readable storage medium. The method comprises: acquiring an image to be compressed and performing block processing on the image to be compressed, so as to obtain a plurality of image blocks; comparing the image blocks and corresponding historical image blocks to obtain comparison results; updating corresponding target historical image blocks for different target image blocks by using the comparison results, and encoding the target image blocks to obtain target code; and generating, by using the target code and a preset code, compressed data corresponding to the image to be compressed. In the method, each part of data to be compressed is compared with a historical image block and a changed target image block is compressed and encoded; and since the number of image blocks to be compressed and encoded is reduced, the consumption of computational resources is thus reduced; meanwhile, the time required for generating compressed data is reduced, thus reducing the delay of a video displayed on a remote terminal.

Description

一种图像压缩方法、装置、电子设备及可读存储介质Image compression method, device, electronic equipment and readable storage medium
本申请要求在2021年6月2日提交中国专利局、申请号为202110613360.9、发明名称为“一种图像压缩方法、装置、电子设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the China Patent Office on June 2, 2021, with the application number 202110613360.9, and the title of the invention is "An Image Compression Method, Device, Electronic Equipment, and Readable Storage Medium", all of which The contents are incorporated by reference in this application.
技术领域technical field
本申请涉及图像处理技术领域,特别涉及一种图像压缩方法、图像压缩装置、电子设备及计算机可读存储介质。The present application relates to the technical field of image processing, and in particular to an image compression method, an image compression device, electronic equipment, and a computer-readable storage medium.
背景技术Background technique
基板管理控制器(BMC,Baseboard Management Controller)管理系统可以提供远程显示、控制功能,通常通过KVM(Keyboard Video Mouse,键盘、视频、鼠标)实现,其能够提供真正的主板级别访问。KVM over IP解决方案能够将所连接的被管理对象的视频、控制信号等模拟信息转换为数字信号,并将其压缩成一个IP包后通过网络传送。管理员可以通过远程终端的控制屏幕看到被管理对象的当前信息状态,进而用本地的键盘和鼠标发出一系列的控制命令对被管理对象进行控制。Baseboard Management Controller (BMC, Baseboard Management Controller) management system can provide remote display and control functions, usually through KVM (Keyboard Video Mouse, 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 the connected managed objects into digital signals, and compress them into an IP packet and transmit it through the network. The administrator can see the current information status of the managed object through the control screen of the remote terminal, and then use the local keyboard and mouse to issue a series of control commands to control the managed object.
为了实现上述效果,相关技术中BMC控制器需要对获取到的视频流中的每个图像进行压缩,并在压缩后将压缩数据发送给远程终端,以便远程终端将视频进行展示。然而,对图像进行压缩需要消耗较多的计算资源,且视频流中图像的数量较多,压缩需要一定的时间,因此视频流中的图像传输至远程终端所需的时间较长,这使得远程终端展示的视频具有较长的时延。In order to achieve the above effects, the BMC controller in the related art needs to compress each image in the obtained video stream, and send the compressed data to the remote terminal after compression, so that the remote terminal can display the video. However, image compression needs to consume more computing resources, and the number of images in the video stream is large, and the compression takes a certain amount of time. Therefore, it takes a long time for the images in the video stream to be transmitted to the remote terminal, which makes remote The video displayed by the terminal has a long delay.
因此,相关技术存在的计算资源消耗较大,终端视频时延较大的问题,是本领域技术人员需要解决的技术问题。Therefore, the problems of relatively large consumption of computing resources and relatively large terminal video delays in related technologies are technical problems that need to be solved by those skilled in the art.
发明内容Contents of the invention
有鉴于此,本申请的目的在于提供一种图像压缩方法、图像压缩装置、电子设备及计算机可读存储介质,通过将待压缩数据中的各个部分与历史图像块进行比对,并对发生了变化的目标图像块进行压缩编码,由于减少了需要被压缩编码的图像块的数量,因此减少了计算资源的消耗,同时降低了远程终端展示的视频的时延。In view of this, the purpose of this application is to provide an image compression method, image compression device, electronic equipment and computer-readable storage medium, by comparing each part of the data to be compressed with the historical image blocks, and analyzing the occurred The changed target image blocks are compressed and coded. Since the number of image blocks that need to be compressed and coded is reduced, the consumption of computing resources is reduced, and at the same time, the time delay of the video displayed by the remote terminal is reduced.
为解决上述技术问题,本申请提供了一种图像压缩方法,包括:In order to solve the above technical problems, the application provides an image compression method, including:
获取待压缩图像,并对所述待压缩图像进行分块处理,得到多个图像块;Obtaining an image to be compressed, and performing block processing on the image to be compressed to obtain a plurality of image blocks;
利用各个所述图像块与对应的历史图像块进行比对,得到比对结果;comparing each of the image blocks with corresponding historical image blocks to obtain a comparison result;
利用比对结果为不同的目标图像块更新对应的目标历史图像块,并对所述目标图像块进行编码,得到目标编码;Utilizing the comparison result to update the corresponding target historical image block for different target image blocks, and encoding the target image block to obtain the target code;
利用所述目标编码与预设编码生成所述待压缩图像对应的压缩数据。The compressed data corresponding to the image to be compressed is generated by using the target code and the preset code.
可选地,还包括:Optionally, also include:
将所述压缩数据和所述比对结果发送至远程终端,以便所述远程终端解析所述压缩数据,得到所述目标图像块,利用所述远程终端存储的所述历史图像块、所述目标图像块和所述比对结果显示所述待压缩图像,并利用所述目标图像块更新所述远程终端存储的所述历史图像块。Sending the compressed data and the comparison result to a remote terminal, so that the remote terminal parses the compressed data to obtain the target image block, and utilizes the historical image block and the target image block stored in the remote terminal The image block and the comparison result display the image to be compressed, and use the target image block to update the historical image block stored in the remote terminal.
可选地,所述利用比对结果为不同的目标图像块更新对应的目标历史图像块,包括:Optionally, updating the corresponding target historical image blocks for different target image blocks by using the comparison results includes:
利用所述目标图像块覆盖缓存中的所述目标历史图像块。Overwriting the target historical image block in the cache with the target image block.
可选地,所述对所述目标图像块进行编码,得到目标编码,包括:Optionally, said encoding the target image block to obtain the target encoding includes:
若所有的目标历史图像块更新完毕,则按照所述比对结果从所述缓存中读取所述目标图像块;If all target historical image blocks are updated, read the target image block from the cache according to the comparison result;
对所述目标图像块进行频域变换、量化和编码处理,得到所述目标编码。Perform frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
可选地,所述利用所述目标编码与预设编码生成所述待压缩图像对应的压缩数据,包括:Optionally, the generating the compressed data corresponding to the image to be compressed by using the target encoding and the preset encoding includes:
按照所述比对结果,将所述目标编码和所述预设编码进行拼接,得到初始压缩数据;According to the comparison result, splicing the target code and the preset code to obtain initial compressed data;
对所述初始压缩数据添加文件头,得到所述压缩数据。Adding a file header to the initial compressed data to obtain the compressed data.
可选地,在所述利用各个所述图像块与对应的历史图像块进行比对之前,还包括:Optionally, before comparing each of the image blocks with corresponding historical image blocks, the method further includes:
判断所述待压缩图像是否为首张图像;judging whether the image to be compressed is the first image;
若是首张图像,则确定所有所述图像块为目标图像块;If it is the first image, then determine that all the image blocks are target image blocks;
若不是所述首张图像,则执行所述利用各个所述图像块与对应的历史图像块进行比对的步骤。If it is not the first image, perform the step of comparing each image block with a corresponding historical image block.
可选地,所述利用各个所述图像块与对应的历史图像块进行比对,得到比对结果,包括:Optionally, comparing each of the image blocks with corresponding historical image blocks to obtain a comparison result includes:
判断所述图像块中各个像素与所述历史图像块中对应的像素数据是否相同;judging whether each pixel in the image block is the same as the corresponding pixel data in the historical image block;
若全部相同,则确定比对结果为相同;If all are the same, it is determined that the comparison result is the same;
若所述图像块中存在至少一个像素与所述历史图像块中对应的像素数据不同,则确定比对结果为不同。If there is at least one pixel in the image block that is different from corresponding pixel data in the historical image block, it is determined that the comparison result is different.
本申请还提供了一种图像压缩装置,包括:The present application also provides an image compression device, including:
分块模块,用于获取待压缩图像,并对所述待压缩图像进行分块处理,得到多个图像块;A block module, configured to obtain an image to be compressed, and perform block processing on the image to be compressed to obtain a plurality of image blocks;
比对模块,用于利用各个所述图像块与对应的历史图像块进行比对,得到比对结果;A comparison module, configured to compare each of the image blocks with corresponding historical image blocks to obtain a comparison result;
编码模块,用于利用比对结果为不同的目标图像块更新对应的目标历史图像块,并对所述目标图像块进行编码,得到目标编码;The encoding module is used to update the corresponding target historical image block for different target image blocks by using the comparison result, and encode the target image block to obtain the target code;
生成模块,用于利用所述目标编码与预设编码生成所述待压缩图像对应的压缩数据。A generating module, configured to generate compressed data corresponding to the image to be compressed by using the target code and the preset code.
本申请还提供了一种电子设备,包括存储器和处理器,其中:The present application also provides an electronic device, including a memory and a processor, wherein:
所述存储器,用于保存计算机程序;The memory is used to store computer programs;
所述处理器,用于执行所述计算机程序,以实现上述的图像压缩方法。The processor is configured to execute the computer program to implement the above image compression method.
本申请还提供了一种计算机可读存储介质,用于保存计算机程序,其中,所述计算机程序被处理器执行时实现上述的图像压缩方法。The present application also provides a computer-readable storage medium for storing a computer program, wherein the above-mentioned image compression method is implemented when the computer program is executed by a processor.
本申请提供的图像压缩方法,获取待压缩图像,并对待压缩图像进行分块处理,得到多个图像块;利用各个图像块与对应的历史图像块进行比对,得到比对结果;利用比对结果为不同的目标图像块更新对应的目标历史图像 块,并对目标图像块进行编码,得到目标编码;利用目标编码与预设编码生成待压缩图像对应的压缩数据。The image compression method provided by this application obtains the image to be compressed, and performs block processing on the image to be compressed to obtain multiple image blocks; compare each image block with the corresponding historical image block to obtain the comparison result; use the comparison As a result, the corresponding target historical image blocks are updated for different target image blocks, and the target image blocks are coded to obtain target codes; the compressed data corresponding to the image to be compressed is generated by using the target codes and preset codes.
可见,该方法中在获取待压缩图像后,并不直接对整个图像进行压缩,而是将其进行分块,得到多个图像块。由于KVM应用场景下,视频流中相邻的图像通常不会有较大变化,因此在将待压缩图像分块后,可以将其与对应的历史图像块进行比对,得到对应的比对结果,并将比对结果为不同的图像块确定为目标图像块。当比对结果不同时,说明该图像块中记录的情况与历史图像块相比发生了变化,因此利用其更新对应的目标历史图像块,以便后续图像传输时进行判断。同时对目标图像块进行编码以完成对目标图像块的压缩,得到对应的目标编码,以便后续生成压缩数据。在得到目标编码后,由于比对结果为相同的图像块与历史图像块没有区别,因此为了减少计算资源的消耗,可以不对其进行编码,而是直接利用预设编码进行替代,减少编码过程所消耗的计算资源,即直接利用目标编码与预设编码生成压缩数据。通过将待压缩数据中的各个部分与历史图像块进行比对,并对发生了变化的目标图像块进行压缩编码,由于减少了需要被压缩编码的图像块的数量,因此减少了计算资源的消耗,同时减少了生成压缩数据所需的时间,降低了远程终端展示的视频的时延,解决了相关技术存在的计算资源消耗较大,终端视频时延较大的问题。It can be seen that in this method, after the image to be compressed is obtained, the entire image is not directly compressed, but is divided into blocks to obtain multiple image blocks. In the KVM application scenario, the adjacent images in the video stream usually do not change greatly, so after the image to be compressed is divided into blocks, it can be compared with the corresponding historical image block to obtain the corresponding comparison result , and determine the image block whose comparison result is different as the target image block. When the comparison results are different, it means that the information recorded in the image block has changed compared with the historical image block, so it is used to update the corresponding target historical image block for judgment during subsequent image transmission. At the same time, the target image block is encoded to complete the compression of the target image block, and the corresponding target code is obtained, so as to generate compressed data subsequently. After obtaining the target code, since the comparison result shows that there is no difference between the same image block and the historical image block, in order to reduce the consumption of computing resources, it is not necessary to encode it, but directly use the preset code to replace it, reducing the cost of the coding process. Consumed computing resources, that is, directly using the target encoding and preset encoding to generate compressed data. By comparing each part of the data to be compressed with the historical image blocks, and compressing and encoding the changed target image blocks, since the number of image blocks that need to be compressed and encoded is reduced, the consumption of computing resources is reduced At the same time, the time required for generating compressed data is reduced, the time delay of video displayed by the remote terminal is reduced, and the problems of large computing resource consumption and large terminal video time delay in related technologies are solved.
此外,本申请还提供了一种图像压缩装置、电子设备及计算机可读存储介质,同样具有上述有益效果。In addition, the present application also provides an image compression device, an electronic device, and a computer-readable storage medium, which also have the above beneficial effects.
附图说明Description of drawings
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the accompanying drawings that need to be used in the description of the embodiments or related technologies. Obviously, the accompanying drawings in the following description are only For the embodiments of the application, those skilled in the art can also obtain other drawings according to the provided drawings without creative work.
图1为本申请实施例提供的一种图像压缩方法流程图;FIG. 1 is a flow chart of an image compression method provided in an embodiment of the present application;
图2为本申请实施例提供的一种相关技术的图像压缩和转发过程示意图;FIG. 2 is a schematic diagram of an image compression and forwarding process of a related technology provided by an embodiment of the present application;
图3为本申请实施例提供的一种具体的图像压缩流程图;FIG. 3 is a specific image compression flowchart provided by the embodiment of the present application;
图4为本申请实施例提供的一种具体的图像压缩和转发过程示意图;FIG. 4 is a schematic diagram of a specific image compression and forwarding process provided by the embodiment of the present application;
图5为本申请实施例提供的一种图像压缩装置的结构示意图;FIG. 5 is a schematic structural diagram of an image compression device provided in an embodiment of the present application;
图6为本申请实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purposes, 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 in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments It is only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
请参考图1,图1为本申请实施例提供的一种图像压缩方法流程图。该方法包括:Please refer to FIG. 1 , which is a flow chart of an image compression method provided by an embodiment of the present application. The method includes:
S101:获取待压缩图像,并对待压缩图像进行分块处理,得到多个图像块。S101: Acquire an image to be compressed, and perform block processing on the image to be compressed to obtain multiple image blocks.
待压缩图像,是指需要被进行压缩处理以得到对应的压缩数据的图像。待压缩图像可以采用任意数据格式,例如可以为JPEG(Joint Photographic Experts Group)格式,或者可以为PNG(Portable Network Graphics)格式,或者可以采用其他数据格式。待压缩图像的数量不做限定,可以为一个或多个,当待压缩图像的数量为多个时,在获取待压缩图像的过程中会同时获取各个待压缩图像之间的先后顺序信息。在对其进行处理时,需要按照先后顺序信息依次进行处理,以便在后续准确地确定历史图像块和目标图像块。The image to be compressed refers to an image that needs to be compressed to obtain corresponding compressed data. The image to be compressed can be in any data format, such as JPEG (Joint Photographic Experts Group) format, PNG (Portable Network Graphics) format, or other data formats. The number of images to be compressed is not limited, and may be one or more. When the number of images to be compressed is multiple, the sequence information among the images to be compressed will be acquired simultaneously during the process of obtaining the images to be compressed. When processing it, it needs to be processed sequentially according to the sequence information, so as to accurately determine the historical image block and the target image block subsequently.
对于待压缩图像的获取方式,在一种实施方式中,可以从指定的存储路径下获取,该指定的存储路径可以为本地的内存路径、硬盘路径或者外部存储路径。在另一种实施方式中,可以接收其他电子设备或其他部件发送的待压缩图像。例如可以接收摄像头部件、CPU(即处理器)等部分发送的待压缩图像。As for the acquisition method of the image to be compressed, in one embodiment, it may be acquired from a specified storage path, and the specified storage path may be a local memory path, a hard disk path, or an external storage path. In another implementation manner, images 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 (that is, a processor) and the like may be received.
需要说明的是,本实施例中的待压缩图像均为KVM场景下的视频流中的图像帧。由于在KVM应用场景下,视频流中相邻的图像通常不会有较大变化,因此在对图像进行压缩时,可以仅对待压缩图像与历史图像的区别部分进行 压缩,进而减少压缩图像所需的计算资源和时长。可以理解的是,若将整个待压缩图像作为一个整体与历史图像进行是否存在区别部分的划分,则在压缩时也需要将整个待压缩图像作为整体进行压缩,无法起到减少压缩图像所需的计算资源和时长的效果,因此需要对待压缩图像进行分块处理,得到多个图像块,每个图像块作为一个单独的比对单元与对应的历史图像块进行比对。It should be noted that the images to be compressed in this embodiment are all image frames in the video stream in the KVM scenario. In the KVM application scenario, the adjacent images in the video stream usually do not change greatly, so when compressing the image, only the difference between the image to be compressed and the historical image can be compressed, thereby reducing the need for compressing the image. computing resources and time. It can be understood that if the entire image to be compressed is taken as a whole and the historical image is divided into whether there is a difference or not, then the entire image to be compressed as a whole needs to be compressed during compression, which cannot achieve the required reduction of the compressed image. The effect of computing resources and time length, so the image to be compressed needs to be divided into blocks to obtain multiple image blocks, and each image block is compared with the corresponding historical image block as a separate comparison unit.
本实施例并不限定分块处理的具体分块方式,在一种可行的实施方式中,可以检测待压缩图像的长和宽,并根据预设的长宽划分次数对待压缩图像的长和宽进行均分,得到每个图像块的长和宽,并以待压缩图像上的某一点作为坐标原点进行分块。坐标原点可以为待压缩图像的中心点、四角顶点等。在另一种实施方式中,可以预设每个图像块的大小,在得到待压缩图像后,从坐标原点开始按照预设的图像块大小对待压缩图像进行分块,其中,各个图像块的大小可以相同也可以不同。除此之外,在对图像进行分块之前或分块之后,还可以进行一定的处理,例如在分块之前进行数据格式转换的预处理,或者在分块之后进行数据格式转换的后处理。需要说明的是,分块方式应当固定不变,即对所有待压缩图像都应该采样相同的分块方式进行分块处理。This embodiment does not limit the specific block method of block processing. In a feasible implementation, the length and width of the image to be compressed can be detected, and the length and width of the image to be compressed can be divided according to the preset length and width. Perform equal division to obtain the length and width of each image block, and use a certain point on the image to be compressed as the origin of coordinates to divide into blocks. The origin of the coordinates may be the center point of the image to be compressed, the vertices of the four corners, and the like. In another embodiment, the size of each image block can be preset. After the image to be compressed is obtained, the image to be compressed is divided into blocks according to the preset image block size from the coordinate origin, wherein the size of each image block Can be the same or different. In addition, certain processing may be performed before or after the image is divided into blocks, such as preprocessing of data format conversion before the block, or postprocessing of data format conversion after the block. It should be noted that the block method should be fixed, that is, all images to be compressed should be sampled in the same block method for block processing.
S102:利用各个图像块与对应的历史图像块进行比对,得到比对结果。S102: Compare each image block with a corresponding historical image block to obtain a comparison result.
为了判断图像块记录的内容是否发生变化,还需要存在用于与图像块进行比对的基准数据,即历史图像块。历史图像块,是指用于组成最新图像的图像块。最新图像,是指当前的待压缩图像之前最新的待压缩图像。可以理解的是,若当前待压缩图像之前的多个待压缩图像均未发生变化,则历史图像块实际上为组成多个时刻之前的待压缩图像的图像块。In order to judge whether the content recorded in the image block has changed, there also needs to exist benchmark data for comparison with the image block, that is, the historical image block. Historical image blocks refer to image blocks used to form the latest image. The latest image refers to the latest image to be compressed before the current image to be compressed. It can be understood that, if none of the multiple images to be compressed before the current image to be compressed has changed, the historical image blocks are actually image blocks that constitute images to be compressed before multiple times.
图像块与历史图像块的对应关系,指的是二者在待压缩图像中的位置关系相对应。具体的,在对待压缩图像进行分块处理后,可以为各个图像块进行标记,标记的具体内容与图像块在待压缩图像中的具体位置相关。通过对图像块进行标记,可以在进行比对时根据该标记确定与图像块对应的历史图像块,进而判断二者记录的内容是否相同。对于标记的具体形式,可以采用数字编号形式,或者可以采用坐标形式等,标记的具体形式可以根据实际需要进行设置。The corresponding relationship between the image block and the historical image block refers to the corresponding positional relationship between the two in the image to be compressed. Specifically, after the image to be compressed is divided into blocks, 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 block, the historical image block corresponding to the image block can be determined according to the mark during the comparison, and then it can be judged whether the recorded contents of the two are the same. As for the specific form of the mark, it may be in the form of a number, or in the form of coordinates, etc., and the specific form of the mark may be set according to actual needs.
比对结果用于表示图像块与历史图像块中的内容是否相同,比对结果的形式不做限定,例如可以采用数字形式,利用1表示相同,0表示不同;或者可以采用文字形式。在本实施例中,比对结果为不同的历史图像块可以被称为目标图像块。在一种具体的实施方式中,可以设置寄存器组block_flag,其用于存储比较结果。block_flag[i][j]表示第i行第j列的图像块对应的比对结果。The comparison result is used to indicate whether the content in the image block is the same as that in the historical image block. The form of the comparison result is not limited. For example, it can be in digital form, using 1 to indicate the same and 0 to indicate different; or it can be in text form. In this embodiment, the historical image blocks whose comparison results are different may be called target image blocks. In a specific implementation manner, a register group block_flag may be set, which is used to store the comparison result. block_flag[i][j] indicates the comparison result corresponding to the image block in row i and column j.
对于比对的具体方式,在一种实施方式中,可以对图像块和历史图像块进行编码,判断二者对应的编码是否相同,若相同则确定比对结果为相同。在另一种实施方式中,为了确定比对的可靠性和准确性,可以对图像块和历史图像块中各个对应像素的像素数据进行比对。具体的,利用各个图像块与对应的历史图像块进行比对,得到比对结果的过程可以包括如下步骤:As for the specific manner of comparison, in one embodiment, the image block and the historical image block may be coded, and it is judged whether the codes corresponding to the two are the same, and if they are the same, the comparison result is determined to be the same. In another implementation manner, 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:
步骤11:判断图像块中各个像素与历史图像块中对应的像素数据是否相同。Step 11: Determine whether each pixel in the image block is the same as the corresponding pixel data in the historical image block.
步骤12:若全部相同,则确定比对结果为相同。Step 12: If all are the same, determine that the comparison result is the same.
步骤13:若图像块中存在至少一个像素与历史图像块中对应的像素数据不同,则确定比对结果为不同。Step 13: If at least one pixel in the image block is different from the corresponding pixel data in the historical image block, determine that the comparison result is different.
在这种实施方式中,由于图像块和历史图像块采用了相同的分块方式得到,二者具有相同数量的像素。每个像素均具有对应的像素数据,用于表示像素的状态,根据待压缩图像的具体格式的不同,像素数据的长度、实际意义、数据格式等都可以不同。可以确定的是,图像块中的像素为多个,因此在比对时,需要一一判断图像块中各个像素与历史图像块中对应像素二者之间的像素数据是否相同。若检测到图像块中任意一个像素与历史图像块中对应的像素数据不同,则可以确定二者之间存在差异,比对结果不同。若图像块中所有像素与历史图像块中的对应的像素数据均相同,则可以确定比对结果为相同。In this embodiment, since the image block and the historical image block are obtained by using the same block division method, they have the same number of pixels. Each pixel has corresponding pixel data, which is used to represent the state of the pixel. Depending on the specific format of the image to be compressed, the length, actual meaning, and data format of the pixel data can be different. It can be determined that there are multiple pixels in the image block, so when comparing, it is necessary to determine whether the pixel data between each pixel in the image block and the corresponding pixel in the historical image block are the same. If it is detected that any pixel in the image block is different from the corresponding pixel data in the historical image block, it can be determined that there is a difference between the two, and the comparison result is different. If all the pixels in the image block are the same as the corresponding pixel data in the historical image block, it can be determined that the comparison result is 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 way of comparing it with the historical image block will cause a large amount of computing resources. waste. Therefore, before using each image block to compare with the corresponding historical image block, the following steps may also be included:
步骤21:判断待压缩图像是否为首张图像。Step 21: Determine whether the image to be compressed is the first image.
步骤22:若是首张图像,则确定所有图像块为目标图像块。Step 22: If it is the first image, determine all image blocks as target image blocks.
步骤23:若不是首张图像,则执行利用各个图像块与对应的历史图像块进行比对的步骤。Step 23: If it is not the first image, perform a step of comparing each image block with the corresponding historical image block.
首张图像,即为视频流中的第一张图像。本实施例并不限定判断待压缩图像是否为首张图像的具体判断方式,在一种实施方式中,视频流中的图像可以具有帧数编号,通过判断待压缩图像的帧数编号是否为最小编号的方式,可以确定待压缩图像是否为首张图像。在另一种实施方式中,由于待压缩图像为首张图像时,并不存在与其对应的历史图像块,因此可以通过判断是否存在历史图像块的方式判断待压缩图像是否为首张图像。The first image is the first image in the video stream. This embodiment does not limit the specific judgment method for judging whether the image to be compressed is the first image. In one embodiment, the image in the video stream may have a frame number. By judging whether the frame number of the image to be compressed is the minimum number In this way, it can be determined whether the image to be compressed is the first image. In another embodiment, since there is no corresponding historical image block when the image to be compressed is the first image, it may be determined whether the image to be compressed is the first image by judging whether there is a historical image block.
若待压缩图像不是首张图像,则可以将图像块与历史图像块进行比对。若待压缩图像为首张图像,则可以直接确定所有的图像块均需要被压缩,因此直接将其确定为目标图像块,以便在后续步骤中进行压缩。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, so it is directly determined as the target image block for compression in subsequent steps.
S103:利用比对结果为不同的目标图像块更新对应的目标历史图像块,并对目标图像块进行编码,得到目标编码。S103: Utilize the comparison result to update the corresponding target historical image block for different target image blocks, and encode the target image block to obtain the target code.
在确定比对结果后,将比对结果为不同的图像块确定为目标图像块,目标历史图像块,是指与目标图像块相对应的历史图像块。为了在后续继续对新的待压缩图像进行处理,需要利用目标图像块更新对应的目标历史图像块,使得在未来对新的待处理图像进行处理时,历史图像块能够组成最新图像,即当前待压缩图像。After the comparison result is determined, an image block whose comparison result is different is determined as a target image block, and the target historical image block refers to a historical image block corresponding to the target image block. In order to continue to process the new image to be compressed in the future, it is necessary to use the target image block to update the corresponding target historical image block, so that when the new image to be processed is processed in the future, the historical image block can form the latest image, that is, the current image to be compressed Compress images.
对目标历史图像块进行更新,即为对目标历史图像块进行替换,这里所指的替换,在一种实施方式中,可以是目标历史图像块内容的替换,即直接利用目标图像块覆盖目标历史图像块。在另一种实施方式中,可以是目标历史图像块身份的替换,即并不对当前的目标历史图像块的内容进行处理,而是剥夺其历史图像块的身份,并为目标图像块赋予历史图像块的身份。身份的剥夺和赋予可以通过删除标记和增加标记的方式进行,可以理解的是,无论采用上述哪种实施方式对目标历史图像块进行替换,均需要将目标图像块进行存储,以便在后续调用比对。Updating the target historical image block is to replace the target historical image block. The replacement referred to here, in one embodiment, may be the replacement of the content of the target historical image block, that is, directly use the target image block to cover the target history Image blocks. In another embodiment, the identity of the target historical image block can be replaced, that is, the content of the current target historical image block is not processed, but the identity of the historical image block is deprived, and the target image block is given a historical image block identity. The deprivation and endowment of identity can be carried out by deleting the mark and adding the mark. It is understandable that no matter which of the above-mentioned implementation methods is used to replace the target historical image block, the target image block needs to be stored so that it can be compared in subsequent calls. right.
对目标图像块进行编码,是指对其进行压缩编码,编码的具体方式不做限定,其目的在于节省存储空间,根据目标图像块的数据类型不同,编码的具体方式也可以不同,例如可以采用霍夫曼编码。编码的具体过程也不做限定,例如在一种实施方式中,为了能够尽量对目标图像块进行压缩,可以对 目标图像块进行一定的预处理,舍弃部分数据。需要说明的是,本实施例并不限定对目标图像块进行编码这一操作和对历史图像块进行更新这一操作的执行顺序,可以根据需要决定二者的先后执行顺序。由于仅对目标图像块进行编码,因此编码所需的时长比对整个待压缩图像进行编码的时长大幅减少,提高了图像压缩的速度。Encoding the target image block refers to compressing and encoding it. The specific encoding method is not limited, and its purpose is to save storage space. Depending on the data type of the target image block, the specific encoding method can also be different. For example, Huffman coding. The specific process of encoding is not limited. For example, in one embodiment, in order to compress the target image block as much as possible, certain preprocessing may be performed on the target image block, and part of the data may be discarded. It should be noted that this embodiment does not limit the execution order of the operation of encoding the target image block and the operation of updating the historical image block, and the execution order of the two operations can be determined according to needs. Since only the target image block is encoded, the time required for encoding is greatly reduced compared with the time for encoding the entire image to be compressed, which improves the speed of image compression.
具体的,在一种可行的实施方式中,为了减少对存储空间的占用,同时为了提高图像压缩的速度,可以将历史图像块存储在缓存中,在这种情况下,利用比对结果为不同的目标图像块更新对应的目标历史图像块的过程可以包括如下步骤:Specifically, in a feasible implementation manner, in order to reduce the occupation of storage space and increase the speed of image compression, the historical image blocks can be stored in the cache, in this case, the comparison results are different The process of updating the corresponding target historical image block of the target image block may include the following steps:
步骤31:利用目标图像块覆盖缓存中的目标历史图像块。Step 31: Overwrite the target historical image block in the cache with the target image block.
通过利用目标图像块覆盖目标历史图像块,可以使得历史图像块的更新不会造成占用的存储空间扩大。同时,通过将历史图像块存储在缓存中,可以提高对其的读取和写入速度,进而提高图像压缩的速度。By covering the target historical image block with the target image block, the update of the historical image block will not increase the occupied storage space. At the same time, by storing historical image blocks in the cache, the speed of reading and writing to them can be improved, thereby improving the speed of image compression.
基于上述实施方式,由于对图像块进行编码的过程可能会出现故障,例如编码失败等。而在BMC控制器中,各个步骤通常为串行执行,因此为了防止因图像块编码错误造成的图像块丢失等可能出现的故障,可以先进行历史图像块的更新,再进行编码。具体的,对目标图像块进行编码,得到目标编码的过程可以包括如下步骤:Based on the above implementation manners, faults may occur in the process of encoding image blocks, such as encoding failure. In the BMC controller, each step is usually performed serially. Therefore, in order to prevent possible faults such as image block loss caused by image block encoding errors, historical image blocks can be updated first, and then encoded. Specifically, the process of encoding the target image block to obtain the target encoding may include the following steps:
步骤41:若所有的目标历史图像块更新完毕,则按照比对结果从缓存中读取目标图像块。Step 41: If all target historical image blocks have been updated, read the target image block from the cache according to the comparison result.
步骤42:对目标图像块进行频域变换、量化和编码处理,得到目标编码。Step 42: Perform frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
在本实施例中,当所有的目标历史图像块均被更新完毕,则可以按照比对结果,将目标图像块从缓存中读取出来,可以理解的是,此刻目标图像块与目标历史图像块相同。In this embodiment, when all target historical image blocks have been updated, the target image block can be read from the cache according to the comparison result. It can be understood that at this moment, the target image block and the target historical image block same.
由于人眼对高频信息不够敏感,因此在对目标图像块进行编码时,可以通过频域变换和量化的组合处理,舍弃高频区域内的数据,提高压缩操作的性能。具体的,频域变换也可以称为DCT变换,是指可以将图像数据从时域转换到频域的处理方式。量化,是指对频域数据的高频区数据进行过滤舍弃的处理方式,用于与频域变换相结合,共同完成目标数据块中高频数据的删除。编码,具体是指根据字符的使用频率对数据进行转换,以便最大化节省 字符存储空间的处理方式,其具体方式不做限定,例如可以采用霍夫曼编码方式。Since the human eye is not sensitive enough to high-frequency information, when encoding the target image block, the data in the high-frequency region can be discarded through a combination of frequency domain transformation and quantization to improve the performance of the compression operation. Specifically, frequency-domain transform may also be called DCT transform, and refers to a processing manner that can convert image data from time domain to frequency domain. Quantization refers to the processing method of filtering and discarding the high-frequency data in the frequency domain data, which is used in combination with the frequency domain transformation to jointly complete the deletion of high-frequency data in the target data block. Encoding specifically refers to a processing method that converts data according to the frequency of use of characters so as to save character storage space to the greatest extent. The specific method is not limited, for example, Huffman coding can be used.
S104:利用目标编码与预设编码生成待压缩图像对应的压缩数据。S104: Generate compressed data corresponding to the image to be compressed by using the target encoding and the preset encoding.
其中,预设编码用于对压缩数据中非目标图像块对应的部分进行填充。由于远程终端需要对压缩数据进行解析,以便对其进行展示,因此压缩数据需要符合正常的图像压缩数据的格式,以便远程终端能够正确的解压,而正常的图像压缩数据中包括整个待压缩图像中全部图像块对应的编码。为了能够减少图像压缩所需的时长,本申请并未对非目标图像块进行编码,因此为了能够使得远程终端正常解压,可以利用预设编码对压缩数据中非目标图像块对应的部分进行填充,使得利用目标编码和预设编码组成的压缩数据符合正常的图像压缩数据的格式。预设编码的具体内容不做限定,例如可以为全零编码,或者可以为全一编码。Wherein, the preset encoding is used to fill the part corresponding to the non-target image block in the compressed data. Since the remote terminal needs to analyze the compressed data in order to display it, the compressed data must conform to the format of the normal image compressed data, so that the remote terminal can decompress it correctly, and the normal image compressed data includes the entire image to be compressed Encoding corresponding to all image blocks. In order to reduce the time required for image compression, this application does not encode the non-target image blocks. Therefore, in order to enable the remote terminal to decompress normally, the part corresponding to the non-target image blocks in the compressed data can be filled with preset encoding. The compressed data composed of target coding and preset coding conforms to the format of normal image compression data. The specific content of the preset encoding is not limited, for example, it may be an encoding of all zeros, or an encoding of all ones.
本实施例并不限定压缩数据的具体生成过程,根据待压缩图像格式的不同,压缩数据的具体生成过程可以不同。在一种可行的实施方式中,当待压缩图像为JPEG格式时,利用目标编码与预设编码生成待压缩图像对应的压缩数据的过程可以包括如下步骤:This 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 the format of the image to be compressed. In a feasible implementation manner, 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 target encoding and preset encoding may include the following steps:
步骤51:按照比对结果,将目标编码和预设编码进行拼接,得到初始压缩数据。Step 51: According to the comparison result, splicing the target code and the preset code to obtain the initial compressed data.
步骤52:对初始压缩数据添加文件头,得到压缩数据。Step 52: Add a file header to the initial compressed data to obtain compressed data.
在本实施例中,可以将目标编码与预设编码进行拼接,得到编码序列,目标编码在编码序列中的位置与目标图像块在待压缩图像中的位置相对应。而比对结果可以表明哪一个图像块为目标图像块,而目标图像块的标识信息(例如编号)与目标图像块在待压缩图像中的位置相关,因此可以将其作为依据确定目标图像块在待压缩图像中的位置。在得到编码序列后,可以添加文件头,文件头中包括图像开始标志位、长度、量化表等信息。在文件头添加完毕后,即可得到压缩数据。In this embodiment, the target code and the preset code can be spliced to obtain a code sequence, and the position of the target code in the code sequence corresponds to the position of the target image block in the image to be compressed. The comparison result can indicate which image block is the target image block, and the identification information (such as number) of the target image block is related to the position of the target image block in the image to be compressed, so it can be used as a basis to determine the target image block in The position in the image to compress. After the encoding sequence is obtained, a file header can be added, and the file header includes information such as an image start flag, length, and quantization table. After the file header is added, the compressed data can be obtained.
进一步的,由于得到的压缩数据中仅包括目标图像块对应的有效数据,非目标图像块对应的有效数据并不存在,因此远程终端中也应当存储有历史图像块,以便利用其与目标图像块拼接得到待压缩图像,相应的,在收到目 标图像块后,远程终端同样需要利用目标图像块对远程终端内存储的目标历史图像块进行更新,保证后续图像能够正确显示。Further, since the obtained compressed data only includes the valid data corresponding to the target image block, and the valid data corresponding to the non-target image block does not exist, so the remote terminal should also store historical image blocks, so as to utilize its correlation with the target image block The image to be compressed is obtained by splicing. Correspondingly, after receiving the target image block, the remote terminal also needs to use the target image block to update the target historical image block stored in the remote terminal to ensure that subsequent images can be displayed correctly.
在一种实施方式中,为了提高远程终端对压缩数据的读取速度,使其能够准确地确定压缩数据中那些部分为目标数据块对应的部分,可以在传输压缩数据的同时,向其发送比对结果。具体的,本实施例还可以包括如下步骤:In one embodiment, in order to improve the reading speed of the remote terminal to the compressed data, so that it can accurately determine which parts of the compressed data are the parts corresponding to the target data block, it can send the ratio to the result. Specifically, this embodiment may also include the following steps:
步骤61:将压缩数据和比对结果发送至远程终端,以便远程终端解析压缩数据,得到目标图像块,利用远程终端存储的历史图像块、目标图像块和比对结果显示待压缩图像,并利用目标图像块更新远程终端存储的历史图像块。Step 61: Send the compressed data and the comparison result to the remote terminal, so that the remote terminal can analyze the compressed data to obtain the target image block, use the historical image block, target image block and comparison result stored in the remote terminal to display the image to be compressed, and use The target image block updates the historical image block stored in the remote terminal.
通过获取比对结果,可以根据比对结果确定压缩数据中的那些数据对应的于目标图像块,并对其进行复原,得到对应的目标图像块。同时,基于比对结果可以确定目标图像块在待压缩图像中的位置,进而利用其与远程终端本地存储的历史图像块和目标图像块显示待压缩图像。该实施方式不需要远程终端自行对压缩数据中的预设编码进行识别,提高了显示速度,同时也避免了某一目标图像块的目标编码刚好与预设编码相同,例如都为全零编码,进而导致远程终端误将目标编码识别为远程编码,造成待压缩图像显示错误的问题。By obtaining the comparison result, it can be determined according to the comparison result which data in the compressed data corresponds to the target image block, and restored to obtain the corresponding target image block. At the same time, based on the comparison result, the position of the target image block in the image to be compressed can be determined, and then the image to be compressed can be displayed by using it together with the historical image block and the target image block locally stored in the remote terminal. This implementation mode does not require the remote terminal to identify the preset code in the compressed data by itself, which improves the display speed, and also avoids that the target code of a certain target image block is just the same as the preset code, for example, all zero codes, In turn, the remote terminal mistakenly recognizes the target code as the remote code, causing the problem that the image to be compressed is displayed incorrectly.
应用本申请实施例提供的图像压缩方法,在获取待压缩图像后,并不直接对整个图像进行压缩,而是将其进行分块,得到多个图像块。由于KVM应用场景下,视频流中相邻的图像通常不会有较大变化,因此在将待压缩图像分块后,可以将其与对应的历史图像块进行比对,得到对应的比对结果,并将比对结果为不同的图像块确定为目标图像块。当比对结果不同时,说明该图像块中记录的情况与历史图像块相比发生了变化,因此利用其更新对应的目标历史图像块,以便后续图像传输时进行判断。同时对目标图像块进行编码以完成对目标图像块的压缩,得到对应的目标编码,以便后续生成压缩数据。在得到目标编码后,由于比对结果为相同的图像块与历史图像块没有区别,因此为了减少计算资源的消耗,可以不对其进行编码,而是直接利用预设编码进行替代,减少编码过程所消耗的计算资源,即直接利用目标编码与预设编码生成压缩数据。通过将待压缩数据中的各个部分与历史图像块进行比对,并对发生了变化的目标图像块进行压缩编码,由于减少了需要被压缩 编码的图像块的数量,因此减少了计算资源的消耗,同时减少了生成压缩数据所需的时间,降低了远程终端展示的视频的时延,解决了相关技术存在的计算资源消耗较大,终端视频时延较大的问题。By applying the image compression method provided by the embodiment of the present application, after the image to be compressed is obtained, the entire image is not directly compressed, but is divided into blocks to obtain multiple image blocks. In the KVM application scenario, the adjacent images in the video stream usually do not change greatly, so after the image to be compressed is divided into blocks, it can be compared with the corresponding historical image block to obtain the corresponding comparison result , and determine the image block whose comparison result is different as the target image block. When the comparison results are different, it means that the information recorded in the image block has changed compared with the historical image block, so it is used to update the corresponding target historical image block for judgment during subsequent image transmission. At the same time, the target image block is encoded to complete the compression of the target image block, and the corresponding target code is obtained, so as to generate compressed data subsequently. After obtaining the target code, since the comparison result shows that there is no difference between the same image block and the historical image block, in order to reduce the consumption of computing resources, it is not necessary to encode it, but directly use the preset code to replace it, reducing the cost of the coding process. Consumed computing resources, that is, directly using the target encoding and preset encoding to generate compressed data. By comparing each part of the data to be compressed with the historical image blocks, and compressing and encoding the changed target image blocks, since the number of image blocks that need to be compressed and encoded is reduced, the consumption of computing resources is reduced At the same time, the time required for generating compressed data is reduced, the time delay of video displayed by the remote terminal is reduced, and the problems of large computing resource consumption and large terminal video time delay in related technologies are solved.
请参考图2,图2为本申请实施例提供的一种相关技术的图像压缩和转发过程示意图。其中记载了相关技术中BMC控制器对图像进行压缩和转发的全过程。主机(即CPU)在获取图像数据(在本实施例中,具体为JPEG格式)后,将图像数据传送给VGA(Video Graphics Array,视频图形阵列)控制器(过程1),VGA控制器将视频数据进行处理后,存入到外置DDR(Double Data Rate,双倍速率同步动态随机存储器)中(该外置DDR为VGA控制器独有的内存空间),再从该外置DDR中读取存入的图像信息读出(过程3),然后按照VSEA标准(视频电子标准协会,Video Electronics Standards Association)转换成DVI(Digital Visual Interface,数字视频接口)信号,通过数模转换器转换成模拟信号通过VGA接口输出到外部的显示屏上(过程2)。视频压缩控制器从VGA控制器给出的DVI接口上捕获图像信息(过程4),然后经过YUV转换、JPEG图像压缩等处理,将压缩后的图像数据存入到BMC系统的外置DDR中(步骤5、6,该DDR为BMC系统使用的内存空间)。请参考图3,图3为本申请实施例提供的一种具体的图像压缩流程图。具体说了JPEG格式的图像压缩过程,其中包括如下几个步骤:Please refer to FIG. 2 . FIG. 2 is a schematic diagram of an image compression and forwarding process of a related technology provided by an embodiment of the present application. It records the whole process of compressing and forwarding the image by the BMC controller in the related art. Host computer (being CPU) after obtaining image data (in this embodiment, specifically JPEG format), image data is sent to VGA (Video Graphics Array, video graphics array) controller (process 1), and VGA controller sends video After the data is processed, it is stored in the external DDR (Double Data Rate, double-rate synchronous dynamic random access memory) (the external DDR is the unique memory space of the VGA controller), and then read from the external DDR The stored image information is read out (process 3), and then converted into a DVI (Digital Visual Interface, Digital Video Interface) signal according to the VSEA standard (Video Electronics Standards Association), and converted into an analog signal by a digital-to-analog converter Output to an external display screen through the VGA interface (process 2). The video compression controller captures image information from the DVI interface provided by the VGA controller (process 4), and then processes such as YUV conversion and JPEG image compression, and stores the compressed image data in the external DDR of the BMC system ( Steps 5 and 6, the DDR is the memory space used by the BMC system). Please refer to FIG. 3 . FIG. 3 is a specific image compression flowchart provided by the embodiment of the present application. Specifically, the image compression process in JPEG format is described, which includes the following steps:
(1)RGB2YUV:是指将RGB格式转换为YUV格式,得到YUV图像的过程,VGA视频源数据为RGB格式,每个像素点都有红、绿、蓝三个基底颜色;JPEG文件是由YUV的色彩空间来表示颜色的,Y表示明亮度,U和V表示色度。因为人眼对亮度的差异敏感度高于对色彩的变化,采样时可适当去掉部分色度信息。(1) RGB2YUV: refers to the process of converting the RGB format to the YUV format to obtain the YUV image. The VGA video source data is in the RGB format, and each pixel has three base colors of red, green, and blue; the JPEG file is composed of YUV The color space to represent the color, Y represents the lightness, U and V represent the chroma. Because the human eye is more sensitive to brightness differences than to color changes, part of the chrominance information can be properly removed during sampling.
(2)8*8block转换:JPEG压缩以8*8块为单位进行,即对图像进行分块。(2) 8*8block conversion: JPEG compression is performed in units of 8*8 blocks, that is, the image is divided into blocks.
(3)DCT变换:时域到频域转换,有利于去除对人眼影响较小的高频信息。(3) DCT transformation: Time domain to frequency domain conversion, which is beneficial to remove high-frequency information that has little impact on the human eye.
(4)量化:与DCT变换结合,舍弃高频区数据的过程称为量化。(4) Quantization: Combined with DCT transformation, the process of discarding high-frequency data is called quantization.
(5)编码:主要目的是根据使用频率来最大化节省字符(编码)的存储空间。通常用霍夫曼编码。(5) Encoding: The main purpose is to maximize the saving of character (encoding) storage space according to the frequency of use. Usually Huffman coding.
(6)添加文件头:包含图像开始标志位、长度、量化表等信息。(6) Add file header: include information such as image start flag, length, quantization table, etc.
运行在ARM(Advanced RISC Machines,ARM处理器)上的应用程序通过调用以太网控制器,从BMC系统使用的DDR中读取压缩后的图像数据,通过以太网传输的远程终端(过程7、8),远程终端接收到压缩数据后进行解压,并显示在屏幕上。The application program running on the ARM (Advanced RISC Machines, ARM processor) reads the compressed image data from the DDR used by the BMC system by calling the Ethernet controller, and transmits the remote terminal through the Ethernet (process 7, 8 ), the remote terminal decompresses the compressed data after receiving it, and displays it on the screen.
由于需要对全部图像进行上述步骤,因此图像压缩所需的时长较大,进而使得远程终端上的图像时延较大。请参考图4,图4为本申请实施例提供的一种具体的图像压缩和转发过程示意图。整个流程包括如下步骤:Since the above steps need to be performed on all the images, the time required for image compression is relatively long, which in turn makes the image delay on the remote terminal relatively large. Please refer to FIG. 4 , which is a schematic diagram of a specific image compression and forwarding process provided by the embodiment of the present application. The whole process includes the following steps:
(1)VGA控制器获取的原始图像数据转化为DVI数据之后,传送给Bolck转换模块,即过程4。(1) After the original image data obtained by the VGA controller is converted into DVI data, it is sent to the Bolck conversion module, that is, process 4.
(2)Block转换模块负责进行分块,将原始图像数据转换成8x8block的数据。对于第一帧图像数据(即首张图像),转换后的数据直接存入到DDR中(过程5)。对于第n帧图像(n>1),转换后的数据传送给对比模块(过程6)。(2) The Block conversion module is responsible for dividing the original image data into 8x8block data. For the first frame of image data (that is, the first image), the converted data is directly stored in the DDR (process 5). For the nth frame image (n>1), the transformed data is sent to the comparison module (process 6).
(3)对比模块接收Block模块传送的第n帧图像,并且从DDR中拿取历史图像数据(过程7),然后对收Block模块传送的第n帧图像的各个图像块与从DDR中拿取的历史图像数据进行比较,即以block为单位进行比较。同时设置寄存器组block_flag,用来存储比较结果,寄存器大小为32bit,寄存器个数根据分辨率的像素总数除以64个像素(一个block的像素大小)而设置。当当前比较的block块相同时,设置对应的block_flag[i][j]为0。如果不相同,则设置为1,并且将该block数据写入到DDR中的相应位置,覆盖相应位置的历史图像数据(步骤8)。(3) The comparison module receives the nth frame image sent by the Block module, and takes historical image data (process 7) from the DDR, and then compares each image block of the nth frame image sent by the Block module with the taken from the DDR Compare the historical image data, that is, compare in units of blocks. At the same time, the register group block_flag is set to store the comparison result. The register size is 32 bits, and the number of registers is set according to the total number of resolution pixels divided by 64 pixels (the pixel size of a block). When the currently compared blocks are the same, set the corresponding block_flag[i][j] to 0. If not, set it as 1, and write the block data into the corresponding position in the DDR, covering the historical image data in the corresponding position (step 8).
(4)视频压缩控制器获取对比模块生成的第n帧图像数据和历史图像数据的对比结果寄存器组block_flag,根据对比结果从DDR中拿取数据,如果block_flag[i][j]为1,则从相应的DDR位置中拿取block数据,如果block_flag[i][j]为0,则不需要从DDR中拿取block数据。(4) The video compression controller obtains the comparison result register group block_flag of the nth frame image data and the historical image data generated by the comparison module, and takes data from the DDR according to the comparison result. If block_flag[i][j] is 1, then Take the block data from the corresponding DDR location, if block_flag[i][j] is 0, you don't need to take the block data from the DDR.
(5)视频压缩控制器的压缩过程为:当block_flag[i][j]为1,则按照正常的过程进行压缩,当block_flag[i][j]为0时,则不需要DCT变换、量化和 编码,直接将编码结果确定为已损坏编码,预设编码具体为将一个全为0的8x8block进行编码得出的结果。在对目标图像块编码完毕后,生成压缩数据,并将压缩数据存入到DDR(过程10)。(5) The compression process of the video compression controller is: when block_flag[i][j] is 1, then compress according to the normal process; when block_flag[i][j] is 0, DCT transformation and quantization are not required And encoding, directly determine the encoding result as a damaged encoding, and the preset encoding is specifically the result obtained by encoding an 8x8 block with all 0s. After the target image block is encoded, compressed data is generated and stored in the DDR (process 10).
(6)在网络传输的过程中,需要先传输对比结果寄存器组block_flag数据,再传输第n帧图像对应的压缩数据。(6) In the process of network transmission, it is necessary to transmit the comparison result register group block_flag data first, and then transmit the compressed data corresponding to the nth frame image.
(7)远程终端需要存储历史图像数据,接收到第n帧的压缩数据后进行解压缩,并且根据接收到的block_flag信息,将解压后的第n帧数据和历史数据进行合并处理,当block_flag[i][j]=1时,当前block块使用第n帧图像的数据,当block_flag[i][j]=0时,当前block块使用历史图像的数据。然后将合并的结果显示出来。(7) The remote terminal needs to store historical image data, decompress it after receiving the compressed data of the nth frame, and merge the decompressed nth frame data and historical data according to the received block_flag information, when block_flag[ When i][j]=1, the current block uses the image data of the nth frame, and when block_flag[i][j]=0, the current block uses the data of the historical image. Then display the merged result.
下面对本申请实施例提供的图像压缩装置进行介绍,下文描述的图像压缩装置与上文描述的图像压缩方法可相互对应参照。The image compression device provided by the embodiment of the present application is introduced below, and the image compression device described below and the image compression method described above can be referred to in correspondence.
请参考图5,图5为本申请实施例提供的一种图像压缩装置的结构示意图,包括:Please refer to FIG. 5. FIG. 5 is a schematic structural diagram of an image compression device provided in an embodiment of the present application, including:
分块模块110,用于获取待压缩图像,并对待压缩图像进行分块处理,得到多个图像块;A block module 110, configured to obtain an image to be compressed, and perform block processing on the image to be compressed to obtain a plurality of image blocks;
比对模块120,用于利用各个图像块与对应的历史图像块进行比对,得到比对结果;A comparison module 120, configured to compare each image block with a corresponding historical image block to obtain a comparison result;
编码模块130,用于利用比对结果为不同的目标图像块更新对应的目标历史图像块,并对目标图像块进行编码,得到目标编码;The encoding module 130 is used to update the corresponding target historical image block for different target image blocks by using the comparison result, and encode the target image block to obtain the target code;
生成模块140,用于利用目标编码与预设编码生成待压缩图像对应的压缩数据。The generating module 140 is configured to generate compressed data corresponding to the image to be compressed by using the target code and the preset code.
可选地,还包括:Optionally, also include:
传输模块,用于将压缩数据和比对结果发送至远程终端,以便远程终端解析压缩数据,得到目标图像块,利用远程终端存储的历史图像块、目标图像块和比对结果显示待压缩图像,并利用目标图像块更新远程终端存储的历史图像块。The transmission module is used to send the compressed data and the comparison result to the remote terminal, so that the remote terminal analyzes the compressed data to obtain the target image block, and uses the historical image block, target image block and comparison result stored in the remote terminal to display the image to be compressed, And use the target image block to update the historical image block stored in the remote terminal.
可选地,编码模块130,包括:Optionally, the coding module 130 includes:
覆盖写单元,用于利用目标图像块覆盖缓存中的目标历史图像块。The overwriting unit is used to overwrite the target historical image block in the cache with the target image block.
可选地,编码模块130,包括:Optionally, the coding module 130 includes:
读取单元,用于若所有的目标历史图像块更新完毕,则按照比对结果从缓存中读取目标图像块;The reading unit is used to read the target image block from the cache according to the comparison result if all target historical image blocks have been updated;
编码单元,用于对目标图像块进行频域变换、量化和编码处理,得到目标编码。The coding unit is configured to perform frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
可选地,生成模块140,包括:Optionally, generating module 140 includes:
拼接单元,用于按照比对结果,将目标编码和预设编码进行拼接,得到初始压缩数据;The splicing unit is used to splice the target code and the preset code according to the comparison result to obtain the initial compressed data;
文件头添加单元,用于对初始压缩数据添加文件头,得到压缩数据。The file header adding unit is used for adding a file header to the initial compressed data to obtain compressed data.
可选地,还包括:Optionally, also include:
判断模块,用于判断待压缩图像是否为首张图像;Judging module, used to judge whether the image to be compressed is the first image;
全部确定模块,用于若是首张图像,则确定所有图像块为目标图像块;All determination modules are used to determine that all image blocks are target image blocks if it is the first image;
相应的,比对模块120为若不是首张图像,则执行利用各个图像块与对应的历史图像块进行比对的模块。Correspondingly, the comparison module 120 is a module for performing comparison between each image block and the corresponding historical image block if it is not the first image.
可选地,比对模块120,包括:Optionally, the comparison module 120 includes:
像素数据判断单元,用于判断图像块中各个像素与历史图像块中对应的像素数据是否相同;A pixel data judging unit for judging whether each pixel in the image block is the same as the corresponding pixel data in the historical image block;
相同确定单元,用于若全部相同,则确定比对结果为相同;The same determination unit is used to determine that the comparison result is the same if all are the same;
不同确定单元,用于若图像块中存在至少一个像素和历史图像块中对应的像素数据不同,则确定比对结果为不同。The difference determination unit is configured to determine that the comparison result is different if at least one pixel in the image block is different from the corresponding pixel data in 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 in correspondence.
请参考图6,图6为本申请实施例提供的一种电子设备的结构示意图。其中电子设备100可以包括处理器101和存储器102,还可以进一步包括多媒体组件103、信息输入/信息输出(I/O)接口104以及通信组件105中的一种或多种。Please refer to FIG. 6 , which is a schematic structural diagram of an electronic device provided in an embodiment of the present application. 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 .
其中,处理器101用于控制电子设备100的整体操作,以完成上述的图像压缩方法中的全部或部分步骤;存储器102用于存储各种类型的数据以支持在电子设备100的操作,这些数据例如可以包括用于在该电子设备100上操作的任何应用程序或方法的指令,以及应用程序相关的数据。该存储器102可以由 任何类型的易失性或非易失性存储设备或者它们的组合实现,例如静态随机存取存储器(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)、磁存储器、快闪存储器、磁盘或光盘中的一种或多种。Among them, the processor 101 is used to control the overall operation of the electronic device 100, so as to complete all or part of the steps in the above image compression method; the memory 102 is used to store various types of data to support the operation of the electronic device 100, these data For example, instructions for any application or method operating on the electronic device 100 may be included, as well as application-related data. The memory 102 can be realized by any type of volatile or non-volatile storage device or their combination, such as Static Random Access Memory (Static Random Access Memory, SRAM), Electrically Erasable Programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (Read-Only Memory, One or more of Only Memory, ROM), magnetic memory, flash memory, magnetic disk or optical disk.
多媒体组件103可以包括屏幕和音频组件。其中屏幕例如可以是触摸屏,音频组件用于输出和/或输入音频信号。例如,音频组件可以包括一个麦克风,麦克风用于接收外部音频信号。所接收的音频信号可以被进一步存储在存储器102或通过通信组件105发送。音频组件还包括至少一个扬声器,用于输出音频信号。I/O接口104为处理器101和其他接口模块之间提供接口,上述其他接口模块可以是键盘,鼠标,按钮等。这些按钮可以是虚拟按钮或者实体按钮。通信组件105用于电子设备100与其他设备之间进行有线或无线通信。无线通信,例如Wi-Fi,蓝牙,近场通信(Near Field Communication,简称NFC),2G、3G或4G,或它们中的一种或几种的组合,因此相应的该通信组件105可以包括:Wi-Fi部件,蓝牙部件,NFC部件。 Multimedia components 103 may include screen and audio components. The screen can be, for example, a touch screen, and the audio component is used for outputting and/or inputting audio signals. For example, an audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 102 or sent via the communication component 105 . The audio component 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, which may be a keyboard, a mouse, buttons, and the like. These buttons can 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 (Near Field Communication, NFC for short), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 105 may include: Wi-Fi parts, Bluetooth parts, NFC parts.
电子设备100可以被一个或多个应用专用集成电路(Application Specific Integrated Circuit,简称ASIC)、数字信号处理器(Digital Signal Processor,简称DSP)、数字信号处理设备(Digital Signal Processing Device,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称PLD)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述实施例给出的图像压缩方法。The electronic device 100 may be implemented by one or more Application Specific Integrated Circuit (ASIC for short), Digital Signal Processor (DSP for short), Digital Signal Processing Device (DSPD for short), Programmable Logic Device (Programmable Logic Device, PLD for short), Field Programmable Gate Array (Field Programmable Gate Array, FPGA for short), controller, microcontroller, microprocessor or other electronic components are implemented for implementing the above embodiments The image compression method given.
下面对本申请实施例提供的计算机可读存储介质进行介绍,下文描述的计算机可读存储介质与上文描述的图像压缩方法可相互对应参照。The computer-readable storage medium provided by the embodiment of the present application is introduced below, and the computer-readable storage medium described below and the image compression method described above may be referred to in correspondence.
本申请还提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述的图像压缩方法的步骤。The present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned image compression method are implemented.
该计算机可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The computer-readable storage medium may include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk, etc., which can store program codes. medium.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same or similar parts of each embodiment can be referred to each other. As for the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and for the related information, please refer to the description of the method part.
本领域技术人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应该认为超出本申请的范围。Those skilled in the art can further appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the hardware and software In the above description, the components and steps of each example have been generally described according to their functions. Whether these functions are executed by means of hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may implement the described functionality using different methods for each particular application, but such implementation should not be considered as exceeding the scope of the present application.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be directly implemented by hardware, software modules executed by a processor, or a combination of both. Software modules can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other Any other known storage medium.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系属于仅仅用来将一个实体或者操作与另一个实体或者操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语包括、包含或者其他任何变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。Finally, it should also be noted that in this article, relationships such as first and second etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that these entities or operations, any such actual relationship or order exists. Moreover, the term comprises, comprises, or any other variation is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements but also other elements not expressly listed, or Yes also includes elements inherent to such a process, method, article, or device.
本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领 域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。In this paper, specific examples are used to illustrate the principles and implementation methods of the application. The descriptions of the above embodiments are only used to help understand the method and core idea of the application; meanwhile, for those of ordinary skill in the art, according to the application There will be changes in the specific implementation and scope of application. In summary, the content of this specification should not be construed as limiting the application.

Claims (10)

  1. 一种图像压缩方法,其特征在于,包括:An image compression method, characterized in that, comprising:
    获取待压缩图像,并对所述待压缩图像进行分块处理,得到多个图像块;Obtaining an image to be compressed, and performing block processing on the image to be compressed to obtain a plurality of image blocks;
    利用各个所述图像块与对应的历史图像块进行比对,得到比对结果;comparing each of the image blocks with corresponding historical image blocks to obtain a comparison result;
    利用比对结果为不同的目标图像块更新对应的目标历史图像块,并对所述目标图像块进行编码,得到目标编码;Utilizing the comparison result to update the corresponding target historical image block for different target image blocks, and encoding the target image block to obtain the target code;
    利用所述目标编码与预设编码生成所述待压缩图像对应的压缩数据。The compressed data corresponding to the image to be compressed is generated by using the target code and the preset code.
  2. 根据权利要求1所述的图像压缩方法,其特征在于,还包括: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 parses the compressed data to obtain the target image block, and utilizes the historical image block and the target image block stored in the remote terminal The image block and the comparison result display the image to be compressed, and use the target image block to update the historical image block stored in the remote terminal.
  3. 根据权利要求1所述的图像压缩方法,其特征在于,所述利用比对结果为不同的目标图像块更新对应的目标历史图像块,包括:The image compression method according to claim 1, wherein the updating of corresponding target historical image blocks for different target image blocks using the comparison results comprises:
    利用所述目标图像块覆盖缓存中的所述目标历史图像块。Overwriting the target historical image block in the cache with the target image block.
  4. 根据权利要求3所述的图像压缩方法,其特征在于,所述对所述目标图像块进行编码,得到目标编码,包括:The image compression method according to claim 3, wherein said encoding the target image block to obtain the target encoding comprises:
    若所有的目标历史图像块更新完毕,则按照所述比对结果从所述缓存中读取所述目标图像块;If all target historical image blocks are updated, read the target image block from the cache according to the comparison result;
    对所述目标图像块进行频域变换、量化和编码处理,得到所述目标编码。Perform frequency domain transformation, quantization and coding processing on the target image block to obtain the target code.
  5. 根据权利要求1所述的图像压缩方法,其特征在于,所述利用所述目标编码与预设编码生成所述待压缩图像对应的压缩数据,包括:The image compression method according to claim 1, wherein said generating compressed data corresponding to said image to be compressed by using said target encoding and preset encoding comprises:
    按照所述比对结果,将所述目标编码和所述预设编码进行拼接,得到初始压缩数据;According to the comparison result, splicing the target code and the preset code to obtain initial compressed data;
    对所述初始压缩数据添加文件头,得到所述压缩数据。Adding a file header to the initial compressed data to obtain the compressed data.
  6. 根据权利要求1所述的图像压缩方法,其特征在于,在所述利用各个所述图像块与对应的历史图像块进行比对之前,还包括:The image compression method according to claim 1, wherein, before comparing each of the image blocks with corresponding historical image blocks, further comprising:
    判断所述待压缩图像是否为首张图像;judging whether the image to be compressed is the first image;
    若是首张图像,则确定所有所述图像块为目标图像块;If it is the first image, then determine that all the image blocks are target image blocks;
    若不是所述首张图像,则执行所述利用各个所述图像块与对应的历史图像块进行比对的步骤。If it is not the first image, perform the step of comparing each image block with a corresponding historical image block.
  7. 根据权利要求1所述的图像压缩方法,其特征在于,所述利用各个所述图像块与对应的历史图像块进行比对,得到比对结果,包括:The image compression method according to claim 1, wherein said comparing each said image block with a corresponding historical image block to obtain a comparison result includes:
    判断所述图像块中各个像素与所述历史图像块中对应的像素数据是否相同;judging whether each pixel in the image block is the same as the corresponding pixel data in the historical image block;
    若全部相同,则确定比对结果为相同;If all are the same, it is determined that the comparison result is the same;
    若所述图像块中存在至少一个像素与所述历史图像块中对应的像素数据不同,则确定比对结果为不同。If there is at least one pixel in the image block that is different from corresponding pixel data in the historical image block, it is determined that the comparison result is different.
  8. 一种图像压缩装置,其特征在于,包括:An image compression device, characterized in that it comprises:
    分块模块,用于获取待压缩图像,并对所述待压缩图像进行分块处理,得到多个图像块;A block module, configured to obtain an image to be compressed, and perform block processing on the image to be compressed to obtain a plurality of image blocks;
    比对模块,用于利用各个所述图像块与对应的历史图像块进行比对,得到比对结果;A comparison module, configured to compare each of the image blocks with corresponding historical image blocks to obtain a comparison result;
    编码模块,用于利用比对结果为不同的目标图像块更新对应的目标历史图像块,并对所述目标图像块进行编码,得到目标编码;The encoding module is used to update the corresponding target historical image block for different target image blocks by using the comparison result, and encode the target image block to obtain the target code;
    生成模块,用于利用所述目标编码与预设编码生成所述待压缩图像对应的压缩数据。A generating module, configured to generate compressed data corresponding to the image to be compressed by using the target code and the preset code.
  9. 一种电子设备,其特征在于,包括存储器和处理器,其中:An electronic device, comprising a memory and a processor, wherein:
    所述存储器,用于保存计算机程序;The memory is used to store computer programs;
    所述处理器,用于执行所述计算机程序,以实现如权利要求1至7任一项所述的图像压缩方法。The processor is configured to execute the computer program to realize the image compression method according to any one of claims 1-7.
  10. 一种计算机可读存储介质,其特征在于,用于保存计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述的图像压缩方法。A computer-readable storage medium, characterized by being used to store a computer program, wherein the computer program implements the image compression method according to any one of claims 1 to 7 when executed by a processor.
PCT/CN2021/127411 2021-06-02 2021-10-29 Image compression method and apparatus, electronic device, and readable storage medium WO2022252488A1 (en)

Applications Claiming Priority (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
CN202110613360.9 2021-06-02

Publications (1)

Publication Number Publication Date
WO2022252488A1 true WO2022252488A1 (en) 2022-12-08

Family

ID=76568529

Family Applications (1)

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

Country Status (2)

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

Cited By (2)

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

Families Citing this family (5)

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

Citations (5)

* 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
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
WO2020057182A1 (en) * 2018-09-19 2020-03-26 华为技术有限公司 Image compression method and apparatus
CN113068040A (en) * 2021-06-02 2021-07-02 苏州浪潮智能科技有限公司 Image compression method and device, electronic equipment and readable storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
JP6261020B2 (en) * 2016-06-28 2018-01-17 株式会社Nexpoint Screen image transfer method and screen image restoration method
CN110740335A (en) * 2019-09-02 2020-01-31 西安万像电子科技有限公司 Data transmission method, system and equipment

Patent Citations (5)

* 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
CN105744281A (en) * 2016-03-28 2016-07-06 飞依诺科技(苏州)有限公司 Continuous image processing method and device
WO2020057182A1 (en) * 2018-09-19 2020-03-26 华为技术有限公司 Image compression method and apparatus
CN109862365A (en) * 2019-01-30 2019-06-07 西安万像电子科技有限公司 Image processing method and device
CN113068040A (en) * 2021-06-02 2021-07-02 苏州浪潮智能科技有限公司 Image compression method and device, electronic equipment and readable storage medium

Cited By (4)

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

Also Published As

Publication number Publication date
CN113068040A (en) 2021-07-02

Similar Documents

Publication Publication Date Title
WO2022252488A1 (en) Image compression method and apparatus, electronic device, and readable storage medium
CA2973405C (en) Method and apparatus for image synchronous displaying
CN109040792B (en) Processing method for video redirection, cloud terminal and cloud desktop server
JP2016506139A (en) Method and apparatus for reducing digital video image data
WO2020224551A1 (en) Information compression/decompression methods and apparatuses, and storage medium
CN113873252B (en) Image processing method and device, electronic equipment and storage medium
US8760366B2 (en) Method and system for remote computing
KR20200094364A (en) Method and system for improving compression ratio by difference between blocks of image file
CN112948151A (en) Program interface image transmission method, substrate management controller and remote control equipment
CN112714357A (en) Video playing method, video playing device, electronic equipment and storage medium
CN114337678A (en) Data compression method, device, equipment and storage medium
WO2016016607A1 (en) Managing display data for display
CN112991412B (en) Liquid crystal instrument sequence frame animation performance optimization method and liquid crystal instrument
WO2021147463A1 (en) Video processing method and device, and electronic apparatus
CN105554375A (en) Method and device of video preview in digital video recorder
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
CN115550668A (en) Video image compression method, system, storage medium and equipment
WO2023024832A1 (en) Data processing method and apparatus, computer device and storage medium
CN108933945B (en) GIF picture compression method, device and storage medium
US20040213475A1 (en) Compression of images using object maps
CN115278264B (en) Image amplification and OSD superposition coding method and system
CN110830760B (en) Secure network data interaction system and method
CN114339226B (en) Method, device and medium for improving smoothness of picture
CN110830744B (en) Safety interaction system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21943840

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21943840

Country of ref document: EP

Kind code of ref document: A1