WO2024098843A1 - Method and system for improving compression quality of jpeg, chip and electronic device - Google Patents

Method and system for improving compression quality of jpeg, chip and electronic device Download PDF

Info

Publication number
WO2024098843A1
WO2024098843A1 PCT/CN2023/110315 CN2023110315W WO2024098843A1 WO 2024098843 A1 WO2024098843 A1 WO 2024098843A1 CN 2023110315 W CN2023110315 W CN 2023110315W WO 2024098843 A1 WO2024098843 A1 WO 2024098843A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
coefficient
standard deviation
brightness
pixel
Prior art date
Application number
PCT/CN2023/110315
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 WO2024098843A1 publication Critical patent/WO2024098843A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/70Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by syntax aspects related to video coding, e.g. related to compression standards
    • 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/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/12Selection from among a plurality of transforms or standards, e.g. selection between discrete cosine transform [DCT] and sub-band transform or selection between H.263 and H.264
    • H04N19/122Selection of transform size, e.g. 8x8 or 2x4x8 DCT; Selection of sub-band transforms of varying structure or type
    • 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/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • 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/182Methods 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 a pixel
    • 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/186Methods 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 a colour or a chrominance component

Definitions

  • the present application relates to the field of JPEG, and in particular to a method, system, chip and electronic device for improving JPEG compression quality.
  • JPEG Joint Photographic Experts Group, a compression standard for continuous tone still images
  • video image compression is a commonly used international standard for video image compression, which is used to compress continuous tone still images (including grayscale images and color images).
  • the classic JPEG image compression process mainly includes color mode conversion, DCT (Discrete Cosine Transform), quantization, Z-shaped arrangement, run length encoding, Huffman coding, and data packaging.
  • the goal is generally to control the JPEG compression bit rate, monitor the actual compressed data bit rate, compare it with the target value, and adjust the quantization coefficient of the entire image based on the difference.
  • the starting point of this method is to control the bit rate, and it does not pay attention to the image quality, and in most cases the image quality cannot be optimized.
  • this method can ensure the stability of the bit rate, that is, the output video image is not stuck, but the same set of quantization coefficients is used for the entire image, and the quality of the compressed image varies greatly for different image parts.
  • an embodiment of the present application proposes a method for improving the quality of Joint Photographic Experts Group JPEG compression, comprising the following steps:
  • the image is subjected to color mode conversion and discrete cosine DCT transformation to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
  • the coefficient matrix is quantized using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
  • counting the pixel values in the image to be compressed to obtain the largest number of pixel values further includes:
  • the data width of the dual-port RAM is log2Fream_S
  • the data depth is 2 pix_width
  • Fream_S is the total number of pixels of the image
  • pix_width is the pixel depth
  • all data in the dual-port RAM is set to 0, further comprising:
  • all data in the dual-port RAM is set to 0, further comprising:
  • All data in the dual-port RAM are set to 0 by writing zero to each address in turn.
  • port B In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
  • port B In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
  • the adjustment coefficient is generated according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth, further comprising:
  • peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
  • the value of a is 0.4.
  • generating the adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth includes:
  • the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel in each image block is added with the adjustment coefficient, further comprising:
  • the image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
  • calculating the brightness expectation corresponding to each image block after adjustment and calculating the standard deviation corresponding to each image block based on the brightness expectation further includes:
  • the pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the expected brightness corresponding to the image block, and the difference between the pixel value of each of the 64 pixels and the expected brightness is calculated respectively, and then the 64 differences are accumulated to obtain the standard deviation corresponding to the image block.
  • the pixel values of 64 pixels of the adjusted image block are added and averaged to obtain the brightness expectation corresponding to the image block, further comprising:
  • comparing the standard deviation with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block further includes:
  • the standard deviation coefficient is a maximum value among the 64 difference values
  • the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation
  • the standard deviation coefficient is a minimum value among the 64 difference values.
  • comparing the brightness expectation with the preset first brightness expectation threshold and the second brightness expectation threshold to determine the brightness expectation coefficient of each image block further includes:
  • the brightness expectation coefficient is 1;
  • the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold
  • the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
  • updating the standard quantization parameter table using the expected brightness coefficient and the standard deviation coefficient corresponding to each image block further includes:
  • the standard quantization parameter table is multiplied by the conversion coefficient and then divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
  • the conversion coefficient is determined according to the image specification.
  • an embodiment of the present application further provides a system for improving JPEG compression quality, including:
  • a statistical module is configured to count pixel values in the image to be compressed to obtain the largest number of pixel values, and generate an adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth;
  • a conversion module configured to perform color mode conversion and DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
  • a first calculation module is configured to calculate the brightness expectation corresponding to each adjusted image block and calculate the standard deviation corresponding to each image block based on the brightness expectation;
  • a comparison module is configured to compare the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine a standard deviation coefficient of each image block, and compare the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine a brightness expectation coefficient of each image block;
  • the second calculation module is configured to obtain a standard quantization parameter table specified in the JPEG protocol and update the standard quantization parameter table using a brightness expectation coefficient and a standard deviation coefficient corresponding to each image block;
  • the quantization module is configured to quantize the coefficient matrix using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
  • an embodiment of the present application further provides a chip, including a digital logic circuit, which implements the steps of the task scheduling method of any of the above embodiments when working.
  • an embodiment of the present application further provides an electronic device, comprising the above-mentioned chip.
  • the method for improving JPEG compression quality proposed in the present application can optimize the encoding process image block by image block according to the characteristics of different video images, so that the part of the original image with rich information retains more detail information after encoding, while the part of the original image with less information and smoothly changing occupies fewer resources after encoding.
  • FIG1 is a flowchart of an image compression process based on the JPEG protocol in the prior art
  • FIG2 is a flow chart of a method for improving JPEG compression quality provided by an embodiment of the present application.
  • FIG3 is a flowchart of an image compression process based on the JPEG protocol provided by an embodiment of the present application
  • FIG4 is a schematic diagram of the structure of a system for improving JPEG compression quality provided by an embodiment of the present application.
  • FIG5 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application.
  • FIG6 is a schematic diagram of the structure of a computer non-volatile readable storage medium provided in an embodiment of the present application.
  • an embodiment of the present application proposes a method for improving JPEG compression quality, as shown in FIG2 , which may include the steps of:
  • the method for improving JPEG compression quality proposed in this application can optimize the encoding process image block by image block according to the characteristics of different video images, so that the information-rich parts of the original image retain more detail information after encoding, while the parts of the original image with less information and smooth changes occupy fewer resources after encoding.
  • counting the pixel values in the image to be compressed to obtain the largest number of pixel values further includes:
  • the received pixel value pixel_data is assigned to the address of the B port of the dual-port RAM, and the enable of the B port is set to 1, the read and write control position is set to 0, and a read operation is performed.
  • the result determines the number of pixels whose pixel value is pixel_data;
  • port B In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
  • a dual-port RAM is instantiated or called as the hardware carrier of the histogram information.
  • the data width of the RAM is log2Fream_S, and the data depth is 2 pix_width , where Fream_S is the number of pixels of the image, such as the commonly used 1920*1080 resolution, the number of pixels is 2073600, then the data width of the RAM is 21 bits, and pix_width is the pixel depth, such as the commonly used 8bit (bit), then the data depth is 256.
  • the data value is recorded as pixel_data.
  • pixel_data is assigned to the address ram_b_addr of the B port of the dual-port RAM, and the enable (or chip select) of the B port is set to 1, and the read-write control position is set to 0.
  • the pixel value of the received data is used as the address, and the number of the pixel value is used as the data written in the address.
  • the adjustment coefficient is generated according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth, further comprising:
  • peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
  • the value of a is 0.4.
  • the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel in each image block is added with the adjustment coefficient, further comprising:
  • the image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
  • a Block image block
  • This part includes the 8x8 image block in FIG3, the write DDR (double rate synchronous dynamic random access memory) and the read DDR part.
  • the image is stored in the DDR as 8x8 blocks, and is subsequently read out from the DDR as blocks.
  • This part is not a key part of this proposal and will not be introduced in detail. It should be noted that the size of each image block is 8*8, and the number of image blocks that can be obtained from the original image is determined by the size of the original image.
  • the pixel value of each pixel in each image block is added with the adjustment coefficient, and then the DCT transformation is performed.
  • calculating the brightness expectation corresponding to each image block after adjustment and calculating the standard deviation corresponding to each image block based on the brightness expectation further includes:
  • the pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the expected brightness corresponding to the image block, and the difference between the pixel value of each of the 64 pixels and the expected brightness is calculated respectively, and then the 64 differences are accumulated to obtain the standard deviation corresponding to the image block.
  • the pixel values of the 64 pixels of each image block after adjustment are added and averaged to obtain the brightness expectation corresponding to the image block, further comprising:
  • the input data of DCT_din is transmitted to the quantization unit at the same time.
  • the average value (that is, expectation) of the 8x8 block pixels is calculated.
  • 64 data are accumulated, and the accumulated result sum_block is shifted right by the corresponding bit, which is the brightness expectation value block_ave.
  • comparing the standard deviation with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block further includes:
  • the standard deviation coefficient is a maximum value among the 64 difference values
  • the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation
  • the standard deviation coefficient is a minimum value among the 64 difference values.
  • the standard deviation can reflect the degree of dispersion of a set of data relative to the mean value.
  • it reflects the information richness contained in the image, and subjectively it is expressed as contrast. Images with large standard deviations often have high information richness, bright colors, obvious textures, and high contrast. On the contrary, the amount of information is insufficient. Therefore, the standard deviation can be used to calculate the factors of quantitative calculations.
  • the upper and lower truncation methods can be used to set a relatively large quantization coefficient for the part with too small standard deviation, because the partition itself does not have enough information. For the part with a lower level but greater than the lower limit, since it has enough information, it can be optimized. When the standard deviation is at a higher level, since the information itself is large enough, a smaller quantization coefficient is used to retain the detail information. Therefore, the standard deviation can be compared with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block:
  • the standard deviation coefficient is the maximum value among the 64 differences; if the standard deviation is not less than the first standard deviation threshold and less than the second standard deviation threshold, the standard deviation coefficient is the maximum value among the 64 differences divided by the standard deviation; if the standard deviation is not less than the second standard deviation threshold, the standard deviation coefficient is the minimum value among the 64 differences.
  • comparing the brightness expectation with the preset first brightness expectation threshold and the second brightness expectation threshold to determine the brightness expectation coefficient of each image block further includes:
  • the brightness expectation coefficient is 1;
  • the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold
  • the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
  • two threshold parameters are first set.
  • the standard brightness expectation coefficient 1 is used; when the value exceeds the threshold Ymax, as the brightness increases, the modulation coefficient becomes smaller, thereby suppressing the enhancement of the high brightness area while ensuring the normal enhancement of the lower brightness. Therefore, the brightness expectation and the preset first brightness expectation threshold and second brightness expectation threshold can be compared to determine the brightness expectation coefficient of each image block:
  • the brightness expectation is less than the first brightness expectation threshold, and the brightness expectation coefficient is 1; the brightness expectation is not less than the first brightness expectation threshold and less than the second brightness expectation threshold, and the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold; the brightness expectation is not less than the second brightness expectation threshold, and the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
  • updating the standard quantization parameter table using the expected brightness coefficient and the standard deviation coefficient corresponding to each image block further includes:
  • the standard quantization parameter table is multiplied by the conversion coefficient and then divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
  • the jpeg protocol specifies a standard brightness and color quantization parameter table [Q_s] (essentially an 8*8 matrix).
  • c is the conversion coefficient, which is a fixed value when the image specifications are determined.
  • the calculated quantization parameter table is updated to the quantization calculation process of image coding, and the corresponding division operation is performed to complete the quantization calculation.
  • the solution proposed in this application realizes global "peak clipping" processing and quantization coefficient calculation by calculating the global brightness histogram of the entire image, the standard deviation of each block, and the brightness expectation and other parameters, and then optimizes the quantization coefficient table block by block to achieve the best image encoding effect. Therefore, the method for improving JPEG compression quality proposed in this application can optimize the encoding process block by block according to the characteristics of different video images, so that the part of the original image with rich information retains more detailed information after encoding, and the part of the original image with less information and smooth changes occupies less resources after encoding.
  • an embodiment of the present application further provides a system 400 for improving JPEG compression quality, as shown in FIG4 , comprising:
  • the statistics module 401 is configured to count the pixel values in the image to be compressed to obtain the largest number of pixel values, and The number and pixel value corresponding to the pixel value with the largest number, the total number of pixels of the image, and the pixel depth generate an adjustment coefficient;
  • the conversion module 402 is configured to perform color mode conversion and DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
  • a first calculation module 403 is configured to calculate the brightness expectation corresponding to each image block after adjustment and calculate the standard deviation corresponding to each image block based on the brightness expectation;
  • the comparison module 404 is configured to compare the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine the standard deviation coefficient of each image block, and compare the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine the brightness expectation coefficient of each image block;
  • the second calculation module 405 is configured to obtain a standard quantization parameter table specified in the JPEG protocol and update the standard quantization parameter table using the brightness expectation coefficient and the standard deviation coefficient corresponding to each image block;
  • the quantization module 406 is configured to quantize the coefficient matrix using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
  • the statistics module 401 is further configured to:
  • the data width of the dual-port RAM is log2Fream_S
  • the data depth is 2 pix_width
  • Fream_S is the total number of pixels of the image
  • pix_width is the pixel depth
  • the statistics module 401 is further configured to:
  • port B In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
  • the conversion module 402 is further configured to:
  • the conversion module 402 is further configured to:
  • peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
  • the value of a is 0.4.
  • the conversion module 402 is further configured to:
  • the image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
  • the first calculation module 403 is further configured to:
  • the pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the brightness period corresponding to the image block.
  • the standard deviation of the image block is obtained by accumulating the 64 differences and calculating the difference between the pixel value of each pixel and the expected brightness.
  • the first calculation module 403 is further configured to:
  • the comparison module 404 is further configured to:
  • the standard deviation coefficient is a maximum value among the 64 difference values
  • the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation
  • the standard deviation coefficient is a minimum value among the 64 difference values.
  • the comparison module 404 is further configured to:
  • the brightness expectation coefficient is 1;
  • the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold
  • the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
  • the second calculation module 405 is further configured to:
  • the standard quantization parameter table is multiplied by the conversion coefficient and then divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
  • the solution proposed in this application calculates the global brightness histogram of the entire image, the standard deviation of each block, the brightness expectation and other parameters, to achieve global "peak clipping" processing and quantization coefficient calculation, and then optimizes the quantization coefficient table block by block to achieve the best image encoding effect. Therefore, the method for improving JPEG compression quality proposed in this application can optimize the encoding process block by block according to the characteristics of different video images, so that the part of the original image with rich information retains more detailed information after encoding, and the part of the original image with less information and smooth changes occupies less resources after encoding.
  • an embodiment of the present application further provides a chip 501, including:
  • the digital logic circuit 510 is included, and when the digital logic circuit 510 is working, the steps of the task scheduling method in any of the above embodiments are implemented.
  • an embodiment of the present application further provides an electronic device 601 , comprising the above-mentioned chip 610 .
  • the computer non-volatile readable storage medium eg, memory
  • the computer non-volatile readable storage medium may be either volatile memory or non-volatile memory, or may include both volatile memory and non-volatile memory.
  • a person of ordinary skill in the art can understand that all or part of the steps of implementing the embodiments of the present application can be completed by hardware, or can be completed by instructing related hardware through a program, and the program can be stored in a computer non-volatile readable storage medium.
  • the non-volatile readable storage medium mentioned above can be a read-only memory, a disk or an optical disk, etc.

Landscapes

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

Abstract

The present application relates to the field of image processing. Disclosed is a method for improving the compression quality of joint photographic experts group (JPEG), comprising: counting the pixel values in an image to be compressed so as to obtain the pixel value having the largest number, and, according to the pixel value having the largest number, and the total number of pixels and the pixel depth of said image, generating an adjustment coefficient; performing color mode conversion and discrete cosine transform (DCT) on said image so as to obtain a coefficient matrix, wherein before DCT is performed, said image is divided into a plurality of image blocks and adjustment is carried out according to the adjustment coefficient; calculating the brightness expectation corresponding to each adjusted image block, and, on the basis of the brightness expectation, calculating a standard deviation corresponding to each image block; calculating a standard deviation coefficient and a brightness expectation coefficient for each image block; acquiring a standard quantization parameter table specified by the JPEG protocol, and updating the standard quantization parameter table by using the brightness expectation coefficient and the standard deviation coefficient corresponding to each image block; and quantizing said coefficient matrix by using the updated quantization parameter table. Also disclosed in the present application are a system, a chip and an electronic device.

Description

一种提高JPEG压缩质量的方法、系统、芯片以及电子设备A method, system, chip and electronic device for improving JPEG compression quality
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求于2022年11月10日提交中国专利局,申请号为202211408785.7,申请名称为“一种提高JPEG压缩质量的方法、系统、芯片以及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to a Chinese patent application filed with the China Patent Office on November 10, 2022, with application number 202211408785.7 and application name “A method, system, chip and electronic device for improving JPEG compression quality”, the entire contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请涉及JPEG领域,特别涉及一种提高JPEG压缩质量的方法、系统、芯片以及电子设备。The present application relates to the field of JPEG, and in particular to a method, system, chip and electronic device for improving JPEG compression quality.
背景技术Background technique
JPEG(Joint Photographic Experts Group,面向连续色调静止图像的一种压缩标准)视频图像压缩是一种常用的视频图像压缩的国际标准,用于对连续色调静态图像进行压缩(包括灰度图像和彩色图像)。如图1所示,经典的JPEG图像压缩流程,主要包括色彩模式转换,DCT(Discrete Cosine Transform,离散余弦变换)、量化、Z字(Zigzag,Z字型)编排、行程编码、霍夫曼编码、数据打包。JPEG (Joint Photographic Experts Group, a compression standard for continuous tone still images) video image compression is a commonly used international standard for video image compression, which is used to compress continuous tone still images (including grayscale images and color images). As shown in Figure 1, the classic JPEG image compression process mainly includes color mode conversion, DCT (Discrete Cosine Transform), quantization, Z-shaped arrangement, run length encoding, Huffman coding, and data packaging.
在现有的技术中,一般以控制JEPG压缩码率为目标,通过监测实际的压缩后的数据码率,与目标值进行比较,通过比较的差值进而调整整幅图像的量化系数。但是此方法的出发点是为了控制码率,并未关注图像质量,且大多数情况下图像质量并不能得到优化。其次此方法虽然可以保证码率稳定,即输出的视频图像不卡顿,但对于整幅图像采用同一组量化系数,对于不同的图像部分,其压缩后的图像质量差异较大。In the existing technology, the goal is generally to control the JPEG compression bit rate, monitor the actual compressed data bit rate, compare it with the target value, and adjust the quantization coefficient of the entire image based on the difference. However, the starting point of this method is to control the bit rate, and it does not pay attention to the image quality, and in most cases the image quality cannot be optimized. Secondly, although this method can ensure the stability of the bit rate, that is, the output video image is not stuck, but the same set of quantization coefficients is used for the entire image, and the quality of the compressed image varies greatly for different image parts.
发明内容Summary of the invention
有鉴于此,根据第一方面,本申请实施例提出一种提高联合图像专家组JPEG压缩质量的方法,包括以下步骤:In view of this, according to a first aspect, an embodiment of the present application proposes a method for improving the quality of Joint Photographic Experts Group JPEG compression, comprising the following steps:
统计待压缩的图像中像素值以得到数量最多的像素值,并根据数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数;Counting pixel values in the image to be compressed to obtain the largest number of pixel values, and generating an adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth;
将图像进行色彩模式转换和离散余弦DCT变换以得到系数矩阵,其中,在进行DCT变换前将图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上调整系数以进行调整;The image is subjected to color mode conversion and discrete cosine DCT transformation to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
计算调整后的每一个图像块对应的亮度期望并基于亮度期望计算每一个图像块对应的标准差;Calculate the brightness expectation corresponding to each image block after adjustment and calculate the standard deviation corresponding to each image block based on the brightness expectation;
比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,并比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数;Compare the standard deviation with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block, and compare the brightness expectation with the preset first brightness expectation threshold and the second brightness expectation threshold to determine the brightness expectation coefficient of each image block;
获取JPEG协议规定的标准量化参数表并利用每一个图像块对应亮度期望系数和标准差系数对标准量化参数表进行更新;Obtain a standard quantization parameter table specified in the JPEG protocol and update the standard quantization parameter table using the brightness expectation coefficient and standard deviation coefficient corresponding to each image block;
利用更新后的量化参数表对系数矩阵进行量化以得到每一个图像块对应的量化后的系数矩阵。The coefficient matrix is quantized using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
在本申请实施例中,统计待压缩的图像中像素值以得到数量最多的像素值,进一步包括:In the embodiment of the present application, counting the pixel values in the image to be compressed to obtain the largest number of pixel values further includes:
调用预设的双端口随机存取存储器RAM,其中,双端口RAM的数据位宽为log2Fream_S,数据深度为2pix_width,Fream_S为图像的总像素数,pix_width为像素深度;Call the preset dual-port random access memory RAM, where the data width of the dual-port RAM is log2Fream_S, the data depth is 2 pix_width , Fream_S is the total number of pixels of the image, and pix_width is the pixel depth;
响应于检测到图像帧首,将双端口RAM内的所有数据置为0。 In response to detecting the beginning of the image frame, all data in the dual-port RAM are set to 0.
在本申请实施例中,将双端口RAM内的所有数据置为0,进一步包括:In an embodiment of the present application, all data in the dual-port RAM is set to 0, further comprising:
使用复位的方式将双端口RAM内的所有数据置为0。Use reset to set all data in the dual-port RAM to 0.
在本申请实施例中,将双端口RAM内的所有数据置为0,进一步包括:In an embodiment of the present application, all data in the dual-port RAM is set to 0, further comprising:
使用每个地址依次写零的方式将双端口RAM内的所有数据置为0。All data in the dual-port RAM are set to 0 by writing zero to each address in turn.
在本申请实施例中,还包括:In the embodiment of the present application, it also includes:
响应于开始接收图像的像素值数据,将接收到的像素值pixel_data赋给双端口RAM的B端口的地址,同时将B端口的使能置为1,读写控制位置为0,进行读操作,根据读取到结果确定像素值为pixel_data的像素点的个数;In response to starting to receive pixel value data of an image, assigning the received pixel value pixel_data to the address of port B of the dual-port RAM, and at the same time setting the enable of port B to 1, the read-write control position to 0, performing a read operation, and determining the number of pixel points whose pixel value is pixel_data according to the read result;
将双端口RAM的A端口的使能置为1,读写控制位置为1,进行写操作,其中写入的数据为个数加1,写入的地址为pixel_data;Set the enable of port A of the dual-port RAM to 1, the read/write control bit to 1, and perform a write operation, where the data written is the number plus 1, and the address written is pixel_data;
响应于检测到图像帧尾,由B端口进行读操作,并从初始地址开始依次读取对应的数据,并进行比较,将其中的最大值data_max和地址addr_max记录下来,其中,data_max为数量最多的像素值对应的数量,addr_max为数量最多的像素值对应的像素值。In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
在本申请实施例中,还包括:In the embodiment of the present application, it also includes:
响应于开始接收图像的像素值数据,将接收到的像素值pixel_data赋给双端口RAM的B端口的地址,同时将B端口的片选置为1,读写控制位置为0,进行读操作,根据读取到结果确定像素值为pixel_data的像素点的个数;In response to starting to receive pixel value data of an image, assigning the received pixel value pixel_data to the address of port B of the dual-port RAM, and at the same time setting the chip select of port B to 1, the read/write control position to 0, performing a read operation, and determining the number of pixel points whose pixel value is pixel_data according to the read result;
将双端口RAM的A端口的片选置为1,读写控制位置为1,进行写操作,其中写入的数据为个数加1,写入的地址为pixel_data;Set the chip select of port A of the dual-port RAM to 1, the read/write control bit to 1, and perform a write operation, where the data written is the number plus 1, and the address written is pixel_data;
响应于检测到图像帧尾,由B端口进行读操作,并从初始地址开始依次读取对应的数据,并进行比较,将其中的最大值data_max和地址addr_max记录下来,其中,data_max为数量最多的像素值对应的数量,addr_max为数量最多的像素值对应的像素值。In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
在本申请实施例中,根据数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数,进一步包括:In the embodiment of the present application, the adjustment coefficient is generated according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth, further comprising:
响应于数量最多的像素值对应的数量小于预设比例的图像的总像素数,不进行削峰,调整系数为0。In response to the fact that the number of pixel values with the largest number corresponds to a total number of pixels of the image that is less than a preset ratio, no peak clipping is performed and the adjustment coefficient is 0.
在本申请实施例中,还包括:In the embodiment of the present application, it also includes:
响应于数量最多的像素值对应的数量不小于预设比例的图像的总像素数,进行削峰,根据公式(data_max-a*Fream_S)*addr_max/2pix_width确定调整系数,其中a为预设比例。In response to the total number of pixels of the image corresponding to the largest number of pixel values being not less than a preset ratio, peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
在本申请实施例中,a取值为0.4。In the embodiment of the present application, the value of a is 0.4.
在本申请实施例中,根据数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数包括:In the embodiment of the present application, generating the adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth includes:
在data_max小于0.4*Fream_S的情况下,则不进行削峰计算,调整系数Adjust为0;When data_max is less than 0.4*Fream_S, no peak clipping calculation is performed and the adjustment coefficient Adjust is 0;
在data_max不小于0.4*Fream_S的情况下,则调整系数Adjust=(data_max-0.4*Fream_S)*addr_max/2pix_widthWhen data_max is not less than 0.4*Fream_S, the adjustment coefficient Adjust=(data_max-0.4*Fream_S)*addr_max/2 pix_width .
在本申请实施例中,在进行DCT变换前将图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上调整系数,进一步包括:In the embodiment of the present application, the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel in each image block is added with the adjustment coefficient, further comprising:
将图像分成多个8*8的图像块,其中每一个图像块包括64个像素点,每一个像素点的像素值均与调整系数相加以得到调整后的每一个图像块。The image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
在本申请实施例中,计算调整后的每一个图像块对应的亮度期望并基于亮度期望计算每一个图像块对应的标准差,进一步包括:In the embodiment of the present application, calculating the brightness expectation corresponding to each image block after adjustment and calculating the standard deviation corresponding to each image block based on the brightness expectation further includes:
将调整后的图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期望,并分别求取64个像素点中每一个像素点的像素值与亮度期望的差值,然后将64个差值累加后得到该图像块对应的标准差。 The pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the expected brightness corresponding to the image block, and the difference between the pixel value of each of the 64 pixels and the expected brightness is calculated respectively, and then the 64 differences are accumulated to obtain the standard deviation corresponding to the image block.
在本申请实施例中,将调整后的图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期望,进一步包括:In the embodiment of the present application, the pixel values of 64 pixels of the adjusted image block are added and averaged to obtain the brightness expectation corresponding to the image block, further comprising:
将得到的累加值向右移位对应的比特bit得到亮度期望。Shift the accumulated value to the right by the corresponding bit to obtain the expected brightness.
在本申请实施例中,比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,进一步包括:In the embodiment of the present application, comparing the standard deviation with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block further includes:
响应于标准差小于第一标准差阈值,标准差系数为64个差值中的最大值;In response to the standard deviation being less than a first standard deviation threshold, the standard deviation coefficient is a maximum value among the 64 difference values;
响应于标准差不小于第一标准差阈值且小于第二标准差阈值,标准差系数为64个差值中的最大值除以标准差;In response to the standard deviation being not less than the first standard deviation threshold and less than the second standard deviation threshold, the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation;
响应于标准差不小于第二标准差阈值,标准差系数为64个差值中的最小值。In response to the standard deviation being not less than a second standard deviation threshold, the standard deviation coefficient is a minimum value among the 64 difference values.
在本申请实施例中,比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数,进一步包括:In the embodiment of the present application, comparing the brightness expectation with the preset first brightness expectation threshold and the second brightness expectation threshold to determine the brightness expectation coefficient of each image block further includes:
响应于亮度期望小于第一亮度期望阈值,亮度期望系数为1;In response to the brightness expectation being less than the first brightness expectation threshold, the brightness expectation coefficient is 1;
响应于亮度期望不小于第一亮度期望阈值且小于第二亮度期望阈值,亮度期望系数为亮度期望除以第一亮度期望阈值;In response to the brightness expectation being not less than the first brightness expectation threshold and less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold;
响应于亮度期望不小于第二亮度期望阈值,亮度期望系数为亮度期望除以第二亮度期望阈值。In response to the brightness expectation being not less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
在本申请实施例中,利用每一个图像块对应亮度期望系数和标准差系数对标准量化参数表进行更新,进一步包括:In the embodiment of the present application, updating the standard quantization parameter table using the expected brightness coefficient and the standard deviation coefficient corresponding to each image block further includes:
利用标准量化参数表乘以转换系数后除以亮度期望系数和标准差系数的乘积。The standard quantization parameter table is multiplied by the conversion coefficient and then divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
在本申请实施例中,转换系数是根据图像规格确定的。In the embodiment of the present application, the conversion coefficient is determined according to the image specification.
基于同一构思,根据第二方面,本申请的实施例还提供了一种提高JPEG压缩质量的系统,包括:Based on the same concept, according to the second aspect, an embodiment of the present application further provides a system for improving JPEG compression quality, including:
统计模块,被设置为统计待压缩的图像中像素值以得到数量最多的像素值,并根据数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数;A statistical module is configured to count pixel values in the image to be compressed to obtain the largest number of pixel values, and generate an adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth;
转换模块,被设置为将图像进行色彩模式转换和DCT变换以得到系数矩阵,其中,在进行DCT变换前将图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上调整系数以进行调整;a conversion module, configured to perform color mode conversion and DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
第一计算模块,被设置为计算调整后的每一个图像块对应的亮度期望并基于亮度期望计算每一个图像块对应的标准差;A first calculation module is configured to calculate the brightness expectation corresponding to each adjusted image block and calculate the standard deviation corresponding to each image block based on the brightness expectation;
比较模块,被设置为比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,并比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数;A comparison module is configured to compare the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine a standard deviation coefficient of each image block, and compare the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine a brightness expectation coefficient of each image block;
第二计算模块,被设置为获取JPEG协议规定的标准量化参数表并利用每一个图像块对应亮度期望系数和标准差系数对标准量化参数表进行更新;The second calculation module is configured to obtain a standard quantization parameter table specified in the JPEG protocol and update the standard quantization parameter table using a brightness expectation coefficient and a standard deviation coefficient corresponding to each image block;
量化模块,被设置为利用更新后的量化参数表对系数矩阵进行量化以得到每一个图像块对应的量化后的系数矩阵。The quantization module is configured to quantize the coefficient matrix using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
基于同一构思,根据第三方面,本申请的实施例还提供了一种芯片,包括数字逻辑电路,数字逻辑电路工作时实现如上述任一项实施例的任务调度方法的步骤。Based on the same concept, according to the third aspect, an embodiment of the present application further provides a chip, including a digital logic circuit, which implements the steps of the task scheduling method of any of the above embodiments when working.
基于同一构思,根据第四方面,本申请的实施例还提供了一种电子设备,包括上述的芯片。Based on the same concept, according to a fourth aspect, an embodiment of the present application further provides an electronic device, comprising the above-mentioned chip.
本申请具有以下有益技术效果之一:本申请提出的提高JPEG压缩质量的方法,可以针对不同的视频图像的特征,逐图像块的优化编码过程,使原始图像信息丰富的部分编码后保留更多的细节信息,而原始图像信息较少、变化平缓的部分编码后占用更少的资源。The present application has one of the following beneficial technical effects: the method for improving JPEG compression quality proposed in the present application can optimize the encoding process image block by image block according to the characteristics of different video images, so that the part of the original image with rich information retains more detail information after encoding, while the part of the original image with less information and smoothly changing occupies fewer resources after encoding.
附图说明 BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的实施例。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying any creative work.
图1为现有技术中基于JPEG协议的图像压缩流程框图;FIG1 is a flowchart of an image compression process based on the JPEG protocol in the prior art;
图2为本申请的实施例提供的提高JPEG压缩质量的方法的流程示意图;FIG2 is a flow chart of a method for improving JPEG compression quality provided by an embodiment of the present application;
图3为本申请的实施例提供的基于JPEG协议的图像压缩流程框图;FIG3 is a flowchart of an image compression process based on the JPEG protocol provided by an embodiment of the present application;
图4为本申请的实施例提供的提高JPEG压缩质量的系统的结构示意图;FIG4 is a schematic diagram of the structure of a system for improving JPEG compression quality provided by an embodiment of the present application;
图5为本申请的实施例提供的计算机设备的结构示意图;FIG5 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application;
图6为本申请的实施例提供的计算机非易失性可读存储介质的结构示意图。FIG6 is a schematic diagram of the structure of a computer non-volatile readable storage medium provided in an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚明白,以下结合可选实施例,并参照附图,对本申请实施例进一步详细说明。In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the embodiments of the present application are further described in detail below in combination with optional embodiments and with reference to the accompanying drawings.
需要说明的是,本申请实施例中所有使用“第一”和“第二”的表述均是为了区分两个相同名称非相同的实体或者非相同的参量,可见“第一”“第二”仅为了表述的方便,不应理解为对本申请实施例的限定,后续实施例对此不再一一说明。It should be noted that all expressions using "first" and "second" in the embodiments of the present application are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present application. The subsequent embodiments will not explain this one by one.
根据本申请的一个方面,本申请的实施例提出一种提高JPEG压缩质量的方法,如图2所示,其可以包括步骤:According to one aspect of the present application, an embodiment of the present application proposes a method for improving JPEG compression quality, as shown in FIG2 , which may include the steps of:
S1,统计待压缩的图像中像素值以得到数量最多的像素值,并根据数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数;S1, counting pixel values in the image to be compressed to obtain the largest number of pixel values, and generating an adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth;
S2,将图像进行色彩模式转换和DCT变换以得到系数矩阵,其中,在进行DCT变换前将图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上调整系数以进行调整;S2, performing color mode conversion and DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
S3,计算调整后的每一个图像块对应的亮度期望并基于亮度期望计算每一个图像块对应的标准差;S3, calculating the brightness expectation corresponding to each image block after adjustment and calculating the standard deviation corresponding to each image block based on the brightness expectation;
S4,比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,并比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数;S4, comparing the standard deviation with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block, and comparing the brightness expectation with the preset first brightness expectation threshold and the second brightness expectation threshold to determine the brightness expectation coefficient of each image block;
S5,获取JPEG协议规定的标准量化参数表并利用每一个图像块对应亮度期望系数和标准差系数对标准量化参数表进行更新;S5, obtaining a standard quantization parameter table specified in the JPEG protocol and updating the standard quantization parameter table using the brightness expectation coefficient and standard deviation coefficient corresponding to each image block;
S6,利用更新后的量化参数表对系数矩阵进行量化以得到每一个图像块对应的量化后的系数矩阵。S6, quantizing the coefficient matrix using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
本申请提出的提高JPEG压缩质量的方法,可以针对不同的视频图像的特征,逐图像块的优化编码过程,使原始图像信息丰富的部分编码后保留更多的细节信息,而原始图像信息较少、变化平缓的部分编码后占用更少的资源。The method for improving JPEG compression quality proposed in this application can optimize the encoding process image block by image block according to the characteristics of different video images, so that the information-rich parts of the original image retain more detail information after encoding, while the parts of the original image with less information and smooth changes occupy fewer resources after encoding.
在本申请实施例中,统计待压缩的图像中像素值以得到数量最多的像素值,进一步包括:In the embodiment of the present application, counting the pixel values in the image to be compressed to obtain the largest number of pixel values further includes:
调用预设的双端口RAM(Random Access Memory,随机存取存储器,其中,双端口RAM的数据位宽为log2Fream_S,数据深度为2pix_width,Fream_S为图像的总像素数,pix_width为像素深度;Call the preset dual-port RAM (Random Access Memory, where the data width of the dual-port RAM is log2Fream_S, the data depth is 2 pix_width , Fream_S is the total number of pixels of the image, and pix_width is the pixel depth;
响应于检测到图像帧首,将双端口RAM内的所有数据置为0。In response to detecting the beginning of the image frame, all data in the dual-port RAM are set to 0.
在本申请实施例中,还包括:In the embodiment of the present application, it also includes:
响应于开始接收图像的像素值数据,将接收到的像素值pixel_data赋给双端口RAM的B端口的地址,同时将B端口的使能置为1,读写控制位置为0,进行读操作,根据读取到 结果确定像素值为pixel_data的像素点的个数;In response to starting to receive the pixel value data of the image, the received pixel value pixel_data is assigned to the address of the B port of the dual-port RAM, and the enable of the B port is set to 1, the read and write control position is set to 0, and a read operation is performed. The result determines the number of pixels whose pixel value is pixel_data;
将双端口RAM的A端口的使能置为1,读写控制位置为1,进行写操作,其中写入的数据为个数加1,写入的地址为pixel_data;Set the enable of port A of the dual-port RAM to 1, the read/write control bit to 1, and perform a write operation, where the data written is the number plus 1, and the address written is pixel_data;
响应于检测到图像帧尾,由B端口进行读操作,并从初始地址开始依次读取对应的数据,并进行比较,将其中的最大值data_max和地址addr_max记录下来,其中,data_max为数量最多的像素值对应的数量,addr_max为数量最多的像素值对应的像素值。In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
可选的,如图3所示,在统计像素值直方图时,可以利用硬件实现。图像输入时的格式一般是按照每行像素从左到右,逐行由上到下的顺序输入。首先例化或调用一个双端口RAM作为直方图信息的硬件载体,RAM的数据位宽为log2Fream_S,数据深度为2pix_width,其中Fream_S为图像的像素数,比如常用的1920*1080分辨率,其像素数就是2073600,则RAM的数据位宽为21位,pix_width为像素深度,比如常用的8bit(比特),则数据深度为256。Optionally, as shown in FIG3 , when counting pixel value histograms, hardware can be used for implementation. The format of image input is generally input in the order of each row of pixels from left to right and from top to bottom. First, a dual-port RAM is instantiated or called as the hardware carrier of the histogram information. The data width of the RAM is log2Fream_S, and the data depth is 2 pix_width , where Fream_S is the number of pixels of the image, such as the commonly used 1920*1080 resolution, the number of pixels is 2073600, then the data width of the RAM is 21 bits, and pix_width is the pixel depth, such as the commonly used 8bit (bit), then the data depth is 256.
硬件实现统计像素值直方图流程如下:The process of hardware implementing pixel value histogram statistics is as follows:
当检测到图像帧首时,将双端口RAM内的所有数据置为0,在硬件上可以使用复位或者每个地址依次写零的方式完成。When the beginning of the image frame is detected, all data in the dual-port RAM are set to 0, which can be accomplished in hardware by using a reset or writing zeros to each address in turn.
当开始接收有效数据时,数据值记为pixel_data,首先将pixel_data赋给双端口RAM的B端口的地址ram_b_addr,同时将B端口的使能(或片选)置为1,读写控制位置为0,进行读操作,读出的结果ram_b_dout,其代表了在本数据之前数据值为pixel_data的个数,将其加1后赋给A端口,进行写操作,ram_a_din=ram_b_dout+1,ram_a_addr=pixel_data,A端口的使能(或片选)置为1,读写控制位置为1。即将接收到的数据的像素值作为地址,该像素值的数量作为该地址中写入的数据。When starting to receive valid data, the data value is recorded as pixel_data. First, pixel_data is assigned to the address ram_b_addr of the B port of the dual-port RAM, and the enable (or chip select) of the B port is set to 1, and the read-write control position is set to 0. The read operation is performed, and the result ram_b_dout, which represents the number of data values before the data is pixel_data, is added by 1 and assigned to the A port for a write operation, ram_a_din = ram_b_dout + 1, ram_a_addr = pixel_data, the enable (or chip select) of the A port is set to 1, and the read-write control position is set to 1. The pixel value of the received data is used as the address, and the number of the pixel value is used as the data written in the address.
在检测到帧尾时,所有的图像数据信息已经写入到了双端口RAM中,此时由B端口进行读操作,可以为从初始地址开始至最大地址依次读取对应的数据,并且进行依次进行比较,将最大的值的地址和数据记录下来,记为data_max(数量最多的像素值对应的数量),addr_max(数量最多的像素值对应的像素值)。When the end of the frame is detected, all image data information has been written into the dual-port RAM. At this time, the read operation is performed by port B, and the corresponding data can be read in sequence from the initial address to the maximum address, and compared in sequence, and the address and data of the largest value are recorded, recorded as data_max (the number corresponding to the largest number of pixel values) and addr_max (the pixel value corresponding to the largest number of pixel values).
在本申请实施例中,根据数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数,进一步包括:In the embodiment of the present application, the adjustment coefficient is generated according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth, further comprising:
响应于数量最多的像素值对应的数量小于预设比例的图像的总像素数,不进行削峰,调整系数为0。In response to the fact that the number of pixel values with the largest number corresponds to a total number of pixels of the image that is less than a preset ratio, no peak clipping is performed and the adjustment coefficient is 0.
在本申请实施例中,还包括:In the embodiment of the present application, it also includes:
响应于数量最多的像素值对应的数量不小于预设比例的图像的总像素数,进行削峰,根据公式(data_max-a*Fream_S)*addr_max/2pix_width确定调整系数,其中a为预设比例。In response to the total number of pixels of the image corresponding to the largest number of pixel values being not less than a preset ratio, peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
在本申请实施例中,a取值为0.4。In the embodiment of the present application, the value of a is 0.4.
可选的,在data_max<0.4*Fream_S的情况下,则不进行削峰计算,调整系数adjust为0;Optionally, when data_max<0.4*Fream_S, no peak clipping calculation is performed, and the adjustment coefficient adjust is 0;
其次,在data_max≥0.4*Fream_S的情况下,则Adjust=(data_max-0.4*Fream_S)*addr_max/2pix_widthNext, when data_max≥0.4*Fream_S, Adjust=(data_max-0.4*Fream_S)*addr_max/2 pix_width .
在本申请实施例中,在进行DCT变换前将图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上调整系数,进一步包括:In the embodiment of the present application, the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel in each image block is added with the adjustment coefficient, further comprising:
将图像分成多个8*8的图像块,其中每一个图像块包括64个像素点,每一个像素点的像素值均与调整系数相加以得到调整后的每一个图像块。 The image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
可选的,如图3所示,当原始图像经过色彩模式转换后,进行Block块(图像块)的生成及存储,后续流程则逐block块进行。该部分包括图3中的8x8图像块,写ddr(双倍速率同步动态随机存储器)和读ddr部分,通过在ddr时的地址计算,将图像按照8x8的块存储在ddr中,后续由ddr读出时也按照block块读取。此部分并非本提案的关键部分,不做更多介绍。需要说明的是,每一个图像块的大小为8*8,原始图像能够得到的图像块的数量由原始图像的大小决定。Optionally, as shown in FIG3, after the original image is converted into a color mode, a Block (image block) is generated and stored, and the subsequent process is performed block by block. This part includes the 8x8 image block in FIG3, the write DDR (double rate synchronous dynamic random access memory) and the read DDR part. By calculating the address at the DDR, the image is stored in the DDR as 8x8 blocks, and is subsequently read out from the DDR as blocks. This part is not a key part of this proposal and will not be introduced in detail. It should be noted that the size of each image block is 8*8, and the number of image blocks that can be obtained from the original image is determined by the size of the original image.
而在进行DCT变换前,则将每一个图像块中的每一个像素点的像素值均加上调整系数,然后在进行DCT变换。Before performing the DCT transformation, the pixel value of each pixel in each image block is added with the adjustment coefficient, and then the DCT transformation is performed.
这样在DCT计算时,将由DDR读出的原始数据加上调整系数adjust作为DCT计算的输入数据,即DCT_din=ddr_out+adjust。In this way, when DCT is calculated, the original data read out from DDR is added with the adjustment coefficient adjust as the input data of DCT calculation, that is, DCT_din=ddr_out+adjust.
在本申请实施例中,计算调整后的每一个图像块对应的亮度期望并基于亮度期望计算每一个图像块对应的标准差,进一步包括:In the embodiment of the present application, calculating the brightness expectation corresponding to each image block after adjustment and calculating the standard deviation corresponding to each image block based on the brightness expectation further includes:
将调整后的图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期望,并分别求取64个像素点中每一个像素点的像素值与亮度期望的差值,然后将64个差值累加后得到该图像块对应的标准差。The pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the expected brightness corresponding to the image block, and the difference between the pixel value of each of the 64 pixels and the expected brightness is calculated respectively, and then the 64 differences are accumulated to obtain the standard deviation corresponding to the image block.
在本申请实施例中,将调整后的每一个图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期望,进一步包括:In the embodiment of the present application, the pixel values of the 64 pixels of each image block after adjustment are added and averaged to obtain the brightness expectation corresponding to the image block, further comprising:
将得到的累加值向右移位对应的bit得到亮度期望。Shift the accumulated value to the right by the corresponding bit to obtain the expected brightness.
可选的,将DCT_din的输入数据同时传输至量化单元,首先计算8x8块像素的平均值(也就是期望),在硬件实现时将64个数据累加,累加的结果sum_block向右移位相应bit,即为亮度期望值block_ave。Optionally, the input data of DCT_din is transmitted to the quantization unit at the same time. First, the average value (that is, expectation) of the 8x8 block pixels is calculated. When implemented in hardware, 64 data are accumulated, and the accumulated result sum_block is shifted right by the corresponding bit, which is the brightness expectation value block_ave.
然后利用依次计算输入数据与期望的差值,dif=DCT_din-block_ave,并将64个差值进行累加记为标准差dif_sum。Then, the difference between the input data and the expected value is calculated in sequence, dif=DCT_din-block_ave, and the 64 differences are accumulated and recorded as the standard deviation dif_sum.
在本申请实施例中,比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,进一步包括:In the embodiment of the present application, comparing the standard deviation with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block further includes:
响应于标准差小于第一标准差阈值,标准差系数为64个差值中的最大值;In response to the standard deviation being less than a first standard deviation threshold, the standard deviation coefficient is a maximum value among the 64 difference values;
响应于标准差不小于第一标准差阈值且小于第二标准差阈值,标准差系数为64个差值中的最大值除以标准差;In response to the standard deviation being not less than the first standard deviation threshold and less than the second standard deviation threshold, the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation;
响应于标准差不小于第二标准差阈值,标准差系数为64个差值中的最小值。In response to the standard deviation being not less than a second standard deviation threshold, the standard deviation coefficient is a minimum value among the 64 difference values.
可选的,标准差可以反映一组数据相对于平均值的分散程度,在图像上,表现为反映图像所包含的信息丰富度,主观上表现为对比度。在标准差大的图像中往往信息丰富度高,色彩鲜明纹路明显,对比度高,反之则信息量不够。因此,可以用标准差来计算量化计算的因子。Optionally, the standard deviation can reflect the degree of dispersion of a set of data relative to the mean value. In images, it reflects the information richness contained in the image, and subjectively it is expressed as contrast. Images with large standard deviations often have high information richness, bright colors, obvious textures, and high contrast. On the contrary, the amount of information is insufficient. Therefore, the standard deviation can be used to calculate the factors of quantitative calculations.
可以进行上下截断的方式,将标准差过小的部分设置相对大的量化系数,因为该分区本身没有足够的信息量。而对于较低水平但大于下限值的部分,因为具有足够的信息量,可以进行优化,当标准差在较高水平,由于本身信息量己经够大,进行适当较小的量化系数,保留细节信息。因此,可以比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数:The upper and lower truncation methods can be used to set a relatively large quantization coefficient for the part with too small standard deviation, because the partition itself does not have enough information. For the part with a lower level but greater than the lower limit, since it has enough information, it can be optimized. When the standard deviation is at a higher level, since the information itself is large enough, a smaller quantization coefficient is used to retain the detail information. Therefore, the standard deviation can be compared with the preset first standard deviation threshold and the second standard deviation threshold to determine the standard deviation coefficient of each image block:
dif_sum<dif_min时,Y_dif_factor=Y_dif_max;When dif_sum<dif_min, Y_dif_factor=Y_dif_max;
dif_min<dif_sum<dif_max时,Y_dif_factor=Y_dif_max/dif_sum; When dif_min<dif_sum<dif_max, Y_dif_factor=Y_dif_max/dif_sum;
dif_sum>dif_max时,Y_dif_factor=Y_dif_min。When dif_sum>dif_max, Y_dif_factor=Y_dif_min.
即标准差小于第一标准差阈值,标准差系数为64个差值中的最大值;标准差不小于第一标准差阈值且小于第二标准差阈值,标准差系数为64个差值中的最大值除以标准差;标准差不小于第二标准差阈值,标准差系数为64个差值中的最小值。That is, if the standard deviation is less than the first standard deviation threshold, the standard deviation coefficient is the maximum value among the 64 differences; if the standard deviation is not less than the first standard deviation threshold and less than the second standard deviation threshold, the standard deviation coefficient is the maximum value among the 64 differences divided by the standard deviation; if the standard deviation is not less than the second standard deviation threshold, the standard deviation coefficient is the minimum value among the 64 differences.
在本申请实施例中,比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数,进一步包括:In the embodiment of the present application, comparing the brightness expectation with the preset first brightness expectation threshold and the second brightness expectation threshold to determine the brightness expectation coefficient of each image block further includes:
响应于亮度期望小于第一亮度期望阈值,亮度期望系数为1;In response to the brightness expectation being less than the first brightness expectation threshold, the brightness expectation coefficient is 1;
响应于亮度期望不小于第一亮度期望阈值且小于第二亮度期望阈值,亮度期望系数为亮度期望除以第一亮度期望阈值;In response to the brightness expectation being not less than the first brightness expectation threshold and less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold;
响应于亮度期望不小于第二亮度期望阈值,亮度期望系数为亮度期望除以第二亮度期望阈值。In response to the brightness expectation being not less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
可选的,类似标准差系数的计算方式,首先设置两个阈值参数,在阈值Ymin之下时,使用标准亮度期望系数1;而在超过阈值Ymax的时候,随着亮度提高,调制系数会变小,从而在保证较低亮度正常增强的同时抑制高亮度区域的增强。因此,可以比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数:Optionally, similar to the calculation method of the standard deviation coefficient, two threshold parameters are first set. When the value is below the threshold Ymin, the standard brightness expectation coefficient 1 is used; when the value exceeds the threshold Ymax, as the brightness increases, the modulation coefficient becomes smaller, thereby suppressing the enhancement of the high brightness area while ensuring the normal enhancement of the lower brightness. Therefore, the brightness expectation and the preset first brightness expectation threshold and second brightness expectation threshold can be compared to determine the brightness expectation coefficient of each image block:
block_ave<Ymin时,Y_ave_factor=1;When block_ave<Ymin, Y_ave_factor=1;
Ymin<block_ave<Ymax时,Y_ave_factor=block_ave/Ymin;When Ymin<block_ave<Ymax, Y_ave_factor=block_ave/Ymin;
block_ave>Ymax时,Y_ave_factor=block_ave/Ymax;When block_ave>Ymax, Y_ave_factor=block_ave/Ymax;
即亮度期望小于第一亮度期望阈值,亮度期望系数为1;亮度期望不小于第一亮度期望阈值且小于第二亮度期望阈值,亮度期望系数为亮度期望除以第一亮度期望阈值;亮度期望不小于第二亮度期望阈值,亮度期望系数为亮度期望除以第二亮度期望阈值。That is, the brightness expectation is less than the first brightness expectation threshold, and the brightness expectation coefficient is 1; the brightness expectation is not less than the first brightness expectation threshold and less than the second brightness expectation threshold, and the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold; the brightness expectation is not less than the second brightness expectation threshold, and the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
在本申请实施例中,利用每一个图像块对应亮度期望系数和标准差系数对标准量化参数表进行更新,进一步包括:In the embodiment of the present application, updating the standard quantization parameter table using the expected brightness coefficient and the standard deviation coefficient corresponding to each image block further includes:
利用标准量化参数表乘以转换系数后除以亮度期望系数和标准差系数的乘积。The standard quantization parameter table is multiplied by the conversion coefficient and then divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
可选的,jpeg协议规定了标准的亮度和色度量化参数表[Q_s](本质上是8*8的矩阵)。然后根据计算得到的亮度期望系数和标准差系数对标准量化参数表进行调整,即[Q]=[Q_s]*c/(Y_dif_factor*Y_ave_factor),也即利用标准量化参数表乘以转换系数后除以亮度期望系数和标准差系数的乘积。Optionally, the jpeg protocol specifies a standard brightness and color quantization parameter table [Q_s] (essentially an 8*8 matrix). The standard quantization parameter table is then adjusted according to the calculated brightness expectation coefficient and standard deviation coefficient, that is, [Q] = [Q_s]*c/(Y_dif_factor*Y_ave_factor), that is, the standard quantization parameter table is multiplied by the conversion coefficient and divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
其中,c为转换系数,在图像规格确定时为固定值。Wherein, c is the conversion coefficient, which is a fixed value when the image specifications are determined.
最后将计算好的量化参数表更新到图像编码的量化计算过程中,并进行相应的除法运算,完成量化计算。Finally, the calculated quantization parameter table is updated to the quantization calculation process of image coding, and the corresponding division operation is performed to complete the quantization calculation.
本申请提出的方案通过计算整幅图像的全局亮度直方图、每个block块的标准差和亮度期望等参数,实现全局的“削峰”处理及量化系数的计算,进而逐block块优化量化系数表,实现最优的图像编码效果。因此本申请提出的提高JPEG压缩质量的方法,可以针对不同的视频图像的特征,逐图像块的优化编码过程,使原始图像信息丰富的部分编码后保留更多的细节信息,而原始图像信息较少、变化平缓的部分编码后占用更少的资源。The solution proposed in this application realizes global "peak clipping" processing and quantization coefficient calculation by calculating the global brightness histogram of the entire image, the standard deviation of each block, and the brightness expectation and other parameters, and then optimizes the quantization coefficient table block by block to achieve the best image encoding effect. Therefore, the method for improving JPEG compression quality proposed in this application can optimize the encoding process block by block according to the characteristics of different video images, so that the part of the original image with rich information retains more detailed information after encoding, and the part of the original image with less information and smooth changes occupies less resources after encoding.
基于同一构思,根据本申请的另一个方面,本申请的实施例还提供了一种提高JPEG压缩质量的系统400,如图4所示,包括:Based on the same concept, according to another aspect of the present application, an embodiment of the present application further provides a system 400 for improving JPEG compression quality, as shown in FIG4 , comprising:
统计模块401,被设置为统计待压缩的图像中像素值以得到数量最多的像素值,并根据 数量最多的像素值对应的数量和像素值、图像的总像素数和像素深度生成调整系数;The statistics module 401 is configured to count the pixel values in the image to be compressed to obtain the largest number of pixel values, and The number and pixel value corresponding to the pixel value with the largest number, the total number of pixels of the image, and the pixel depth generate an adjustment coefficient;
转换模块402,被设置为将图像进行色彩模式转换和DCT变换以得到系数矩阵,其中,在进行DCT变换前将图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上调整系数以进行调整;The conversion module 402 is configured to perform color mode conversion and DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is adjusted by adding the adjustment coefficient;
第一计算模块403,被设置为计算调整后的每一个图像块对应的亮度期望并基于亮度期望计算每一个图像块对应的标准差;A first calculation module 403 is configured to calculate the brightness expectation corresponding to each image block after adjustment and calculate the standard deviation corresponding to each image block based on the brightness expectation;
比较模块404,被设置为比较标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,并比较亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数;The comparison module 404 is configured to compare the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine the standard deviation coefficient of each image block, and compare the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine the brightness expectation coefficient of each image block;
第二计算模块405,被设置为获取JPEG协议规定的标准量化参数表并利用每一个图像块对应亮度期望系数和标准差系数对标准量化参数表进行更新;The second calculation module 405 is configured to obtain a standard quantization parameter table specified in the JPEG protocol and update the standard quantization parameter table using the brightness expectation coefficient and the standard deviation coefficient corresponding to each image block;
量化模块406,被设置为利用更新后的量化参数表对系数矩阵进行量化以得到每一个图像块对应的量化后的系数矩阵。The quantization module 406 is configured to quantize the coefficient matrix using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
在本申请实施例中,统计模块401还被设置为:In the embodiment of the present application, the statistics module 401 is further configured to:
调用预设的双端口RAM,其中,双端口RAM的数据位宽为log2Fream_S,数据深度为2pix_width,Fream_S为图像的总像素数,pix_width为像素深度;Call the preset dual-port RAM, where the data width of the dual-port RAM is log2Fream_S, the data depth is 2 pix_width , Fream_S is the total number of pixels of the image, and pix_width is the pixel depth;
响应于检测到图像帧首,将双端口RAM内的所有数据置为0。In response to detecting the beginning of the image frame, all data in the dual-port RAM are set to 0.
在本申请实施例中,统计模块401还被设置为:In the embodiment of the present application, the statistics module 401 is further configured to:
响应于开始接收图像的像素值数据,将接收到的像素值pixel_data赋给双端口RAM的B端口的地址,同时将B端口的使能置为1,读写控制位置为0,进行读操作,根据读取到结果确定像素值为pixel_data的像素点的个数;In response to starting to receive pixel value data of an image, assigning the received pixel value pixel_data to the address of port B of the dual-port RAM, and at the same time setting the enable of port B to 1, the read-write control position to 0, performing a read operation, and determining the number of pixel points whose pixel value is pixel_data according to the read result;
将双端口RAM的A端口的使能置为1,读写控制位置为1,进行写操作,其中写入的数据为个数加1,写入的地址为pixel_data。Set the enable of port A of the dual-port RAM to 1, the read-write control position to 1, and perform a write operation, where the data written is the number plus 1, and the written address is pixel_data.
响应于检测到图像帧尾,由B端口进行读操作,并从初始地址开始依次读取对应的数据,并进行比较,将其中的最大值data_max和地址addr_max记录下来,其中,data_max为数量最多的像素值对应的数量,addr_max为数量最多的像素值对应的像素值。In response to detecting the end of the image frame, port B performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
在本申请实施例中,转换模块402还被设置为:In the embodiment of the present application, the conversion module 402 is further configured to:
响应于数量最多的像素值对应的数量小于预设比例的图像的总像素数,不进行削峰,调整系数为0。In response to the fact that the number of pixel values with the largest number corresponds to a total number of pixels of the image that is less than a preset ratio, no peak clipping is performed and the adjustment coefficient is 0.
在本申请实施例中,转换模块402还被设置为:In the embodiment of the present application, the conversion module 402 is further configured to:
响应于数量最多的像素值对应的数量不小于预设比例的图像的总像素数,进行削峰,根据公式(data_max-a*Fream_S)*addr_max/2pix_width确定调整系数,其中a为预设比例。In response to the total number of pixels of the image corresponding to the largest number of pixel values being not less than a preset ratio, peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
在本申请实施例中,a取值为0.4。In the embodiment of the present application, the value of a is 0.4.
在本申请实施例中,转换模块402还被设置为:In the embodiment of the present application, the conversion module 402 is further configured to:
将图像分成多个8*8的图像块,其中每一个图像块包括64个像素点,每一个像素点的像素值均与调整系数相加以得到调整后的每一个图像块。The image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
在本申请实施例中,第一计算模块403还被设置为:In the embodiment of the present application, the first calculation module 403 is further configured to:
将调整后的图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期 望,并分别求取64个像素点中每一个像素点的像素值与亮度期望的差值,然后将64个差值累加后得到该图像块对应的标准差。The pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the brightness period corresponding to the image block. The standard deviation of the image block is obtained by accumulating the 64 differences and calculating the difference between the pixel value of each pixel and the expected brightness.
在本申请实施例中,第一计算模块403还被设置为:In the embodiment of the present application, the first calculation module 403 is further configured to:
将得到的累加值向右移位对应的bit得到亮度期望。Shift the accumulated value to the right by the corresponding bit to obtain the expected brightness.
在本申请实施例中,比较模块404还被设置为:In the embodiment of the present application, the comparison module 404 is further configured to:
响应于标准差小于第一标准差阈值,标准差系数为64个差值中的最大值;In response to the standard deviation being less than a first standard deviation threshold, the standard deviation coefficient is a maximum value among the 64 difference values;
响应于标准差不小于第一标准差阈值且小于第二标准差阈值,标准差系数为64个差值中的最大值除以标准差;In response to the standard deviation being not less than the first standard deviation threshold and less than the second standard deviation threshold, the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation;
响应于标准差不小于第二标准差阈值,标准差系数为64个差值中的最小值。In response to the standard deviation being not less than a second standard deviation threshold, the standard deviation coefficient is a minimum value among the 64 difference values.
在本申请实施例中,比较模块404还被设置为:In the embodiment of the present application, the comparison module 404 is further configured to:
响应于亮度期望小于第一亮度期望阈值,亮度期望系数为1;In response to the brightness expectation being less than the first brightness expectation threshold, the brightness expectation coefficient is 1;
响应于亮度期望不小于第一亮度期望阈值且小于第二亮度期望阈值,亮度期望系数为亮度期望除以第一亮度期望阈值;In response to the brightness expectation being not less than the first brightness expectation threshold and less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold;
响应于亮度期望不小于第二亮度期望阈值,亮度期望系数为亮度期望除以第二亮度期望阈值。In response to the brightness expectation being not less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the second brightness expectation threshold.
在本申请实施例中,第二计算模块405还被设置为:In the embodiment of the present application, the second calculation module 405 is further configured to:
利用标准量化参数表乘以转换系数后除以亮度期望系数和标准差系数的乘积。The standard quantization parameter table is multiplied by the conversion coefficient and then divided by the product of the brightness expectation coefficient and the standard deviation coefficient.
本申请提出的方案通过计算整幅图像的全局亮度直方图、每个block块的标准差和亮度期望等参数,实现全局的“削峰”处理及量化系数的计算,进而逐block块优化量化系数表,实现最优的图像编码效果。因此本申请提出的提高JPEG压缩质量的方法,可以针对不同的视频图像的特征,逐图像块的优化编码过程,使原始图像信息丰富的部分编码后保留更多的细节信息,而原始图像信息较少、变化平缓的部分编码后占用更少的资源。The solution proposed in this application calculates the global brightness histogram of the entire image, the standard deviation of each block, the brightness expectation and other parameters, to achieve global "peak clipping" processing and quantization coefficient calculation, and then optimizes the quantization coefficient table block by block to achieve the best image encoding effect. Therefore, the method for improving JPEG compression quality proposed in this application can optimize the encoding process block by block according to the characteristics of different video images, so that the part of the original image with rich information retains more detailed information after encoding, and the part of the original image with less information and smooth changes occupies less resources after encoding.
基于同一构思,根据本申请的另一个方面,如图5所示,本申请的实施例还提供了一种芯片501,包括:Based on the same concept, according to another aspect of the present application, as shown in FIG5 , an embodiment of the present application further provides a chip 501, including:
包括数字逻辑电路510,数字逻辑电路510工作时实现如上述任一项实施例的任务调度方法的步骤。The digital logic circuit 510 is included, and when the digital logic circuit 510 is working, the steps of the task scheduling method in any of the above embodiments are implemented.
基于同一构思,根据本申请的另一个方面,如图6所示,本申请的实施例还提供了电子设备601,包括上述的芯片610。Based on the same concept, according to another aspect of the present application, as shown in FIG. 6 , an embodiment of the present application further provides an electronic device 601 , comprising the above-mentioned chip 610 .
最后需要说明的是,本领域普通技术人员可以理解实现本申请实施例方法中的全部或部分流程,可以通过计算机程序来指令相关硬件来完成,程序可存储于一计算机非易失性可读存储介质中,该程序在执行时,可包括如本申请各方法的实施例的流程。Finally, it should be noted that a person skilled in the art can understand that all or part of the processes in the method of the embodiment of the present application can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer non-volatile readable storage medium. When the program is executed, it may include the processes of the embodiments of the methods of the present application.
此外,应该明白的是,本文的计算机非易失性可读存储介质(例如,存储器)可以是易失性存储器或非易失性存储器,或者可以包括易失性存储器和非易失性存储器两者。Furthermore, it should be appreciated that the computer non-volatile readable storage medium (eg, memory) herein may be either volatile memory or non-volatile memory, or may include both volatile memory and non-volatile memory.
本领域技术人员还将明白的是,结合这里的公开所描述的各种示例性逻辑块、模块、电路和算法步骤可以被实现为电子硬件、计算机软件或两者的组合。为了清楚地说明硬件和软件的这种可互换性,已经就各种示意性组件、方块、模块、电路和步骤的功能对其进行了一般性的描述。这种功能是被实现为软件还是被实现为硬件取决于应用以及施加给整个系统的设计约束。本领域技术人员可以针对每种应用以各种方式来实现的功能,但是这种实现决定不应被解释为导致脱离本申请实施例公开的范围。 Those skilled in the art will also appreciate that various exemplary logic blocks, modules, circuits and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or implemented as hardware depends on application and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the present application embodiment.
以上是本申请公开的示例性实施例,但是应当注意,在不背离权利要求限定的本申请实施例公开的范围的前提下,可以进行多种改变和修改。根据这里描述的公开实施例的方法权利要求的功能、步骤和/或动作不需以任何特定顺序执行。此外,尽管本申请实施例公开的元素可以以个体形式描述或要求,但除非明确限制为单数,也可以理解为多个。The above are exemplary embodiments disclosed in the present application, but it should be noted that various changes and modifications may be made without departing from the scope disclosed in the embodiments of the present application as defined in the claims. The functions, steps and/or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present application may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.
应当理解的是,在本文中使用的,除非上下文清楚地支持例外情况,单数形式“一个”旨在也包括复数形式。还应当理解的是,在本文中使用的“和/或”是指包括一个或者一个以上相关联地列出的项目的任意和所有可能组合。It should be understood that, as used herein, the singular forms "a", "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and/or" refers to any and all possible combinations including one or more of the associated listed items.
上述本申请实施例公开实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments disclosed in the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
本领域普通技术人员可以理解实现本申请实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,程序可以存储于一种计算机非易失性可读存储介质中,上述提到的非易失性可读存储介质可以是只读存储器,磁盘或光盘等。A person of ordinary skill in the art can understand that all or part of the steps of implementing the embodiments of the present application can be completed by hardware, or can be completed by instructing related hardware through a program, and the program can be stored in a computer non-volatile readable storage medium. The non-volatile readable storage medium mentioned above can be a read-only memory, a disk or an optical disk, etc.
所属领域的普通技术人员应当理解:本申请任何实施例的讨论仅为示例性的,并非旨在暗示本申请实施例公开的范围(包括权利要求)被限于这些例子;在本申请实施例的思路下,本申请实施例或者不同实施例中的技术特征之间也可以进行组合,并存在如上的本申请实施例的不同方面的许多其它变化,为了简明它们没有在细节中提供。因此,凡在本申请实施例的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本申请实施例的保护范围之内。 A person of ordinary skill in the art should understand that the discussion of any embodiment of the present application is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present application (including the claims) is limited to these examples; under the idea of the embodiments of the present application, the technical features in the embodiments of the present application or in different embodiments can also be combined, and there are many other changes in different aspects of the embodiments of the present application as above, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims (20)

  1. 一种提高联合图像专家组JPEG压缩质量的方法,其特征在于,包括以下步骤:A method for improving the quality of Joint Photographic Experts Group JPEG compression, characterized by comprising the following steps:
    统计待压缩的图像中像素值以得到数量最多的像素值,并根据所述数量最多的像素值对应的数量和像素值、所述图像的总像素数和像素深度生成调整系数;Counting pixel values in the image to be compressed to obtain the largest number of pixel values, and generating an adjustment coefficient according to the number and pixel values corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth;
    将所述图像进行色彩模式转换和离散余弦DCT变换以得到系数矩阵,其中,在进行DCT变换前将所述图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上所述调整系数以进行调整;Performing color mode conversion and discrete cosine DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is added with the adjustment coefficient to perform adjustment;
    计算调整后的所述每一个图像块对应的亮度期望并基于所述亮度期望计算每一个图像块对应的标准差;Calculating the adjusted brightness expectation corresponding to each image block and calculating the standard deviation corresponding to each image block based on the brightness expectation;
    比较所述标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,并比较所述亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数;Comparing the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine a standard deviation coefficient of each image block, and comparing the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine a brightness expectation coefficient of each image block;
    获取JPEG协议规定的标准量化参数表并利用每一个图像块对应所述亮度期望系数和所述标准差系数对所述标准量化参数表进行更新;Obtaining a standard quantization parameter table specified in the JPEG protocol and updating the standard quantization parameter table using the brightness expectation coefficient and the standard deviation coefficient corresponding to each image block;
    利用更新后的量化参数表对所述系数矩阵进行量化以得到每一个图像块对应的量化后的系数矩阵。The coefficient matrix is quantized using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
  2. 如权利要求1所述的方法,其特征在于,统计待压缩的图像中像素值以得到数量最多的像素值,进一步包括:The method according to claim 1, wherein counting the pixel values in the image to be compressed to obtain the largest number of pixel values further comprises:
    调用预设的双端口随机存取存储器RAM,其中,所述双端口RAM的数据位宽为log2Fream_S,数据深度为2pix_width,Fream_S为图像的总像素数,pix_width为像素深度;Calling a preset dual-port random access memory RAM, wherein the data bit width of the dual-port RAM is log 2 Fream_S, the data depth is 2 pix_width , Fream_S is the total number of pixels of the image, and pix_width is the pixel depth;
    响应于检测到图像帧首,将所述双端口RAM内的所有数据置为0。In response to detecting the beginning of an image frame, all data in the dual-port RAM are set to 0.
  3. 如权利要求2所述的方法,其特征在于,将所述双端口RAM内的所有数据置为0,进一步包括:The method according to claim 2, characterized in that setting all data in the dual-port RAM to 0 further comprises:
    使用复位的方式将所述双端口RAM内的所有数据置为0。All data in the dual-port RAM are set to 0 by resetting.
  4. 如权利要求2所述的方法,其特征在于,将所述双端口RAM内的所有数据置为0,进一步包括:The method according to claim 2, characterized in that setting all data in the dual-port RAM to 0 further comprises:
    使用每个地址依次写零的方式将所述双端口RAM内的所有数据置为0。All data in the dual-port RAM are set to 0 by writing zero to each address in sequence.
  5. 如权利要求2所述的方法,其特征在于,还包括:The method according to claim 2, further comprising:
    响应于开始接收图像的像素值数据,将接收到的像素值pixel_data赋给所述双端口RAM的B端口的地址,同时将B端口的使能置为1,读写控制位置为0,进行读操作,根据读取到结果确定像素值为pixel_data的像素点的个数;In response to starting to receive pixel value data of an image, assigning the received pixel value pixel_data to the address of the B port of the dual-port RAM, and setting the enable of the B port to 1, the read-write control position to 0, performing a read operation, and determining the number of pixel points whose pixel value is pixel_data according to the read result;
    将所述双端口RAM的A端口的使能置为1,读写控制位置为1,进行写操作,其中写入的数据为所述个数加1,写入的地址为pixel_data;The enable of the A port of the dual-port RAM is set to 1, the read-write control bit is set to 1, and a write operation is performed, wherein the data written is the number plus 1, and the address written is pixel_data;
    响应于检测到图像帧尾,由所述B端口进行读操作,并从初始地址开始依次读取对应的数据,并进行比较,将其中的最大值data_max和地址addr_max记录下来,其中,data_max为数量最多的像素值对应的数量,addr_max为数量最多的像素值对应的像素值。In response to detecting the end of the image frame, the B port performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and the address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
  6. 如权利要求2所述的方法,其特征在于,还包括:The method according to claim 2, further comprising:
    响应于开始接收图像的像素值数据,将接收到的像素值pixel_data赋给所述双端口 In response to starting to receive pixel value data of an image, assigning the received pixel value pixel_data to the dual port
    RAM的B端口的地址,同时将B端口的片选置为1,读写控制位置为0,进行读操作,根据读取到结果确定像素值为pixel_data的像素点的个数;The address of port B of RAM, and at the same time set the chip select of port B to 1, the read and write control position to 0, perform a read operation, and determine the number of pixels whose pixel value is pixel_data according to the read result;
    将所述双端口RAM的A端口的片选置为1,读写控制位置为1,进行写操作,其中写入的数据为所述个数加1,写入的地址为pixel_data;The chip select of the A port of the dual-port RAM is set to 1, the read-write control bit is set to 1, and a write operation is performed, wherein the data written is the number plus 1, and the address written is pixel_data;
    响应于检测到图像帧尾,由所述B端口进行读操作,并从初始地址开始依次读取对应的数据,并进行比较,将其中的最大值data_max和地址addr_max记录下来,其中,data_max为数量最多的像素值对应的数量,addr_max为数量最多的像素值对应的像素值。In response to detecting the end of the image frame, the B port performs a read operation and reads the corresponding data in sequence starting from the initial address, and compares them, recording the maximum value data_max and the address addr_max, where data_max is the number corresponding to the largest number of pixel values, and addr_max is the pixel value corresponding to the largest number of pixel values.
  7. 如权利要求5所述的方法,其特征在于,根据所述数量最多的像素值对应的数量和像素值、所述图像的总像素数和像素深度生成调整系数,进一步包括:The method of claim 5, wherein generating the adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth further comprises:
    响应于所述数量最多的像素值对应的数量小于预设比例的所述图像的总像素数,不进行削峰,调整系数为0。In response to the fact that the number corresponding to the largest number of pixel values is smaller than a preset ratio of the total number of pixels of the image, no peak clipping is performed and the adjustment coefficient is 0.
  8. 如权利要求7所述的方法,其特征在于,还包括:The method according to claim 7, further comprising:
    响应于所述数量最多的像素值对应的数量不小于预设比例的所述图像的总像素数,进行削峰,根据公式(data_max-a*Fream_S)*addr_max/2pix_width确定调整系数,其中a为预设比例。In response to the number of pixel values with the largest number corresponding to not less than a preset ratio of the total number of pixels of the image, peak clipping is performed, and an adjustment coefficient is determined according to a formula (data_max-a*Fream_S)*addr_max/2 pix_width , where a is a preset ratio.
  9. 如权利要求8所述的方法,其特征在于,所述a取值为0.4。The method according to claim 8, characterized in that the value of a is 0.4.
  10. 如权利要求2所述的方法,其特征在于,根据所述数量最多的像素值对应的数量和像素值、所述图像的总像素数和像素深度生成调整系数包括:The method of claim 2, wherein generating the adjustment coefficient according to the number and pixel value corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth comprises:
    在data_max小于0.4*Fream_S的情况下,则不进行削峰计算,调整系数Adjust为0:When data_max is less than 0.4*Fream_S, no peak clipping calculation is performed and the adjustment coefficient Adjust is 0:
    在data_max不小于0.4*Fream_S的情况下,则所述调整系数Adiust=(data_max-0.4*Fream_S)*addr_max/2pix_widthWhen data_max is not less than 0.4*Fream_S, the adjustment coefficient Adiust=(data_max-0.4*Fream_S)*addr_max/2 pix_width .
  11. 如权利要求1所述的方法,其特征在于,在进行DCT变换前将所述图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上所述调整系数,进一步包括:The method according to claim 1, characterized in that the image is divided into a plurality of image blocks before performing DCT transformation, and the pixel value of each pixel in each image block is added with the adjustment coefficient, further comprising:
    将所述图像分成多个8*8的图像块,其中每一个图像块包括64个像素点,每一个像素点的像素值均与所述调整系数相加以得到调整后的每一个图像块。The image is divided into a plurality of 8*8 image blocks, wherein each image block includes 64 pixels, and the pixel value of each pixel is added to the adjustment coefficient to obtain each adjusted image block.
  12. 如权利要求11所述的方法,其特征在于,计算调整后的所述每一个图像块对应的亮度期望并基于所述亮度期望计算每一个图像块对应的标准差,进一步包括:The method according to claim 11, characterized in that calculating the adjusted brightness expectation corresponding to each image block and calculating the standard deviation corresponding to each image block based on the brightness expectation further comprises:
    将调整后的图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期望,并分别求取所述64个像素点中每一个像素点的像素值与所述亮度期望的差值,然后将64个差值累加后得到该图像块对应的标准差。The pixel values of the 64 pixels of the adjusted image block are added and averaged to obtain the expected brightness corresponding to the image block, and the difference between the pixel value of each pixel in the 64 pixels and the expected brightness is calculated respectively, and then the 64 differences are accumulated to obtain the standard deviation corresponding to the image block.
  13. 如权利要求12所述的方法,其特征在于,将调整后的图像块的64个像素点的像素值相加后求平均得到该图像块对应的亮度期望,进一步包括:The method of claim 12, wherein the pixel values of 64 pixels of the adjusted image block are added and then averaged to obtain the expected brightness corresponding to the image block, further comprising:
    将得到的累加值向右移位对应的比特bit得到亮度期望。Shift the accumulated value to the right by the corresponding bit to obtain the expected brightness.
  14. 如权利要求12所述的方法,其特征在于,比较所述标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,进一步包括:The method of claim 12, wherein comparing the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine a standard deviation coefficient of each image block further comprises:
    响应于所述标准差小于第一标准差阈值,所述标准差系数为所述64个差值中的最大值; In response to the standard deviation being less than a first standard deviation threshold, the standard deviation coefficient is a maximum value among the 64 difference values;
    响应于所述标准差不小于第一标准差阈值且小于所述第二标准差阈值,所述标准差系数为所述64个差值中的最大值除以所述标准差;In response to the standard deviation being not less than a first standard deviation threshold and less than the second standard deviation threshold, the standard deviation coefficient is a maximum value of the 64 difference values divided by the standard deviation;
    响应于所述标准差不小于所述第二标准差阈值,所述标准差系数为所述64个差值中的最小值。In response to the standard deviation being not less than the second standard deviation threshold, the standard deviation coefficient is a minimum value among the 64 difference values.
  15. 如权利要求1所述的方法,其特征在于,比较所述亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数,进一步包括:The method according to claim 1, characterized in that comparing the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine a brightness expectation coefficient for each image block further comprises:
    响应于所述亮度期望小于第一亮度期望阈值,所述亮度期望系数为1;In response to the brightness expectation being less than a first brightness expectation threshold, the brightness expectation coefficient is 1;
    响应于所述亮度期望不小于第一亮度期望阈值且小于所述第二亮度期望阈值,所述亮度期望系数为所述亮度期望除以所述第一亮度期望阈值;In response to the brightness expectation being not less than a first brightness expectation threshold and less than the second brightness expectation threshold, the brightness expectation coefficient is the brightness expectation divided by the first brightness expectation threshold;
    响应于所述亮度期望不小于所述第二亮度期望阈值,所述亮度期望系数为所述亮度期望除以所述第二亮度期望阈值。In response to the desired brightness being not less than the second desired brightness threshold, the desired brightness coefficient is the desired brightness divided by the second desired brightness threshold.
  16. 如权利要求1所述的方法,其特征在于,利用每一个图像块对应所述亮度期望系数和所述标准差系数对所述标准量化参数表进行更新,进一步包括:The method according to claim 1, characterized in that the standard quantization parameter table is updated using the brightness expectation coefficient and the standard deviation coefficient corresponding to each image block, further comprising:
    利用所述标准量化参数表乘以转换系数后除以所述亮度期望系数和所述标准差系数的乘积。The standard quantization parameter table is multiplied by a conversion coefficient and then divided by a product of the brightness expectation coefficient and the standard deviation coefficient.
  17. 如权利要求1所述的方法,其特征在于,所述转换系数是根据图像规格确定的。The method according to claim 1, characterized in that the conversion coefficient is determined according to image specifications.
  18. 一种提高JPEG压缩质量的系统,其特征在于,包括:A system for improving JPEG compression quality, comprising:
    统计模块,被设置为统计待压缩的图像中像素值以得到数量最多的像素值,并根据所述数量最多的像素值对应的数量和像素值、所述图像的总像素数和像素深度生成调整系数;a statistical module configured to count pixel values in the image to be compressed to obtain the largest number of pixel values, and generate an adjustment coefficient according to the number and pixel values corresponding to the largest number of pixel values, the total number of pixels of the image, and the pixel depth;
    转换模块,被设置为将所述图像进行色彩模式转换和DCT变换以得到系数矩阵,其中,在进行DCT变换前将所述图像分成多个图像块,并将每一个图像块中的每一个像素点的像素值加上所述调整系数以进行调整;a conversion module, configured to perform color mode conversion and DCT transformation on the image to obtain a coefficient matrix, wherein the image is divided into a plurality of image blocks before the DCT transformation, and the pixel value of each pixel point in each image block is added with the adjustment coefficient for adjustment;
    第一计算模块,被设置为计算调整后的所述每一个图像块对应的亮度期望并基于所述亮度期望计算每一个图像块对应的标准差;A first calculation module is configured to calculate the adjusted brightness expectation corresponding to each image block and calculate the standard deviation corresponding to each image block based on the brightness expectation;
    比较模块,被设置为比较所述标准差与和预设的第一标准差阈值、第二标准差阈值的大小以确定每一个图像块的标准差系数,并比较所述亮度期望和预设的第一亮度期望阈值、第二亮度期望阈值的大小以确定每一个图像块的亮度期望系数;A comparison module is configured to compare the standard deviation with a preset first standard deviation threshold and a second standard deviation threshold to determine a standard deviation coefficient of each image block, and compare the brightness expectation with a preset first brightness expectation threshold and a second brightness expectation threshold to determine a brightness expectation coefficient of each image block;
    第二计算模块,被设置为获取JPEG协议规定的标准量化参数表并利用每一个图像块对应所述亮度期望系数和所述标准差系数对所述标准量化参数表进行更新;A second calculation module is configured to obtain a standard quantization parameter table specified in the JPEG protocol and update the standard quantization parameter table using the brightness expectation coefficient and the standard deviation coefficient corresponding to each image block;
    量化模块,被设置为利用更新后的量化参数表对所述系数矩阵进行量化以得到每一个图像块对应的量化后的系数矩阵。The quantization module is configured to quantize the coefficient matrix using the updated quantization parameter table to obtain a quantized coefficient matrix corresponding to each image block.
  19. 一种芯片,其特征在于,包括数字逻辑电路,所述数字逻辑电路工作时实现如权利要求1-17任一项所述的方法的步骤。A chip, characterized in that it includes a digital logic circuit, and when the digital logic circuit is in operation, the steps of the method described in any one of claims 1 to 17 are implemented.
  20. 一种电子设备,其特征在于,包括如权利要求19所述的芯片。 An electronic device, characterized by comprising the chip as claimed in claim 19.
PCT/CN2023/110315 2022-11-10 2023-07-31 Method and system for improving compression quality of jpeg, chip and electronic device WO2024098843A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211408785.7 2022-11-10
CN202211408785.7A CN115474062B (en) 2022-11-10 2022-11-10 Method, system, chip and electronic equipment for improving JPEG compression quality

Publications (1)

Publication Number Publication Date
WO2024098843A1 true WO2024098843A1 (en) 2024-05-16

Family

ID=84338166

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/110315 WO2024098843A1 (en) 2022-11-10 2023-07-31 Method and system for improving compression quality of jpeg, chip and electronic device

Country Status (2)

Country Link
CN (1) CN115474062B (en)
WO (1) WO2024098843A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118250407A (en) * 2024-05-28 2024-06-25 浙江华视智检科技有限公司 FPGA-based table look-up scanning type image superposition system and method

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115474062B (en) * 2022-11-10 2023-04-28 苏州浪潮智能科技有限公司 Method, system, chip and electronic equipment for improving JPEG compression quality

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006304198A (en) * 2005-04-25 2006-11-02 Nec Network & Sensor Systems Ltd Image compressing device
CN114786011A (en) * 2022-06-22 2022-07-22 苏州浪潮智能科技有限公司 JPEG image compression method, system, equipment and storage medium
CN114898003A (en) * 2022-05-09 2022-08-12 安徽大学 Multi-objective optimization JPEG quantization table optimization method based on decomposition
CN115086683A (en) * 2021-09-23 2022-09-20 芯原微电子(成都)有限公司 Image compression method and device, electronic equipment and computer readable storage medium
CN115474062A (en) * 2022-11-10 2022-12-13 苏州浪潮智能科技有限公司 Method, system, chip and electronic device for improving JPEG compression quality

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7139437B2 (en) * 2002-11-12 2006-11-21 Eastman Kodak Company Method and system for removing artifacts in compressed images
CN101931805B (en) * 2009-06-19 2013-10-23 香港科技大学 Scalar quantization using bit-stealing for video processing and its application in video coding
CN109756733B (en) * 2017-11-06 2022-04-12 华为技术有限公司 Video data decoding method and device
CN112637593B (en) * 2020-12-18 2022-08-02 郑州师范学院 Video coding optimization method based on artificial intelligence and video analysis

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006304198A (en) * 2005-04-25 2006-11-02 Nec Network & Sensor Systems Ltd Image compressing device
CN115086683A (en) * 2021-09-23 2022-09-20 芯原微电子(成都)有限公司 Image compression method and device, electronic equipment and computer readable storage medium
CN114898003A (en) * 2022-05-09 2022-08-12 安徽大学 Multi-objective optimization JPEG quantization table optimization method based on decomposition
CN114786011A (en) * 2022-06-22 2022-07-22 苏州浪潮智能科技有限公司 JPEG image compression method, system, equipment and storage medium
CN115474062A (en) * 2022-11-10 2022-12-13 苏州浪潮智能科技有限公司 Method, system, chip and electronic device for improving JPEG compression quality

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118250407A (en) * 2024-05-28 2024-06-25 浙江华视智检科技有限公司 FPGA-based table look-up scanning type image superposition system and method

Also Published As

Publication number Publication date
CN115474062B (en) 2023-04-28
CN115474062A (en) 2022-12-13

Similar Documents

Publication Publication Date Title
WO2024098843A1 (en) Method and system for improving compression quality of jpeg, chip and electronic device
US8090207B2 (en) Adaptive compression quality
CN101107862B (en) Encoding device and dynamic image recording system having the encoding device
JP4440308B2 (en) Rate control method and system in image compression
JP2006303690A (en) Image signal processing apparatus, camera system, and image signal processing method
JP2006303689A (en) Image signal processing apparatus, camera system, and image signal processing method
JP3448462B2 (en) Image data compression device
WO2023246047A1 (en) Jpeg image compression method and system, device, and storage medium
CN106993190A (en) Software-hardware synergism coding method and system
JP3067628B2 (en) Image coding device
WO2024198887A1 (en) Image compression method and system, electronic device, and non-volatile readable storage medium
WO2024212823A1 (en) Sample adaptive offset method, apparatus and device, storage medium, and product
CN112887725B (en) Reference frame buffer data compression method, computer device and computer readable storage medium
JP2018088652A (en) Imaging apparatus, image processing method, and program
US10497093B2 (en) Image processing apparatus for minimizing deterioration of image quality of a raw image
US20040247185A1 (en) Image processing apparatus and image processing method
US8428381B2 (en) Image compression method with variable quantization parameter
JPH01309464A (en) Picture transmitter
JP3795932B2 (en) Image data compression encoding method and apparatus
KR960014313B1 (en) Image signal processing apparatus
JP3858528B2 (en) Electronic camera and recording medium on which image processing program is recorded
JP2004040300A (en) Image processing apparatus
JP3227181B2 (en) Image processing device
JP4064279B2 (en) Image compression device
TW200941406A (en) Image compression method

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: 23887539

Country of ref document: EP

Kind code of ref document: A1