WO2023230933A1 - 图像压缩方法、装置、电子设备、芯片及储存介质 - Google Patents
图像压缩方法、装置、电子设备、芯片及储存介质 Download PDFInfo
- Publication number
- WO2023230933A1 WO2023230933A1 PCT/CN2022/096492 CN2022096492W WO2023230933A1 WO 2023230933 A1 WO2023230933 A1 WO 2023230933A1 CN 2022096492 W CN2022096492 W CN 2022096492W WO 2023230933 A1 WO2023230933 A1 WO 2023230933A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- code rate
- scan line
- current
- line
- compression parameters
- Prior art date
Links
- 238000007906 compression Methods 0.000 title claims abstract description 297
- 230000006835 compression Effects 0.000 title claims abstract description 277
- 238000000034 method Methods 0.000 title claims abstract description 83
- 230000008569 process Effects 0.000 claims abstract description 26
- 230000002829 reductive effect Effects 0.000 claims abstract description 13
- 230000007423 decrease Effects 0.000 claims description 28
- 230000004044 response Effects 0.000 claims description 25
- 230000009467 reduction Effects 0.000 claims description 6
- 230000000670 limiting effect Effects 0.000 claims description 5
- 238000004590 computer program Methods 0.000 claims description 2
- 238000012545 processing Methods 0.000 abstract description 14
- 230000010355 oscillation Effects 0.000 abstract description 6
- 238000004364 calculation method Methods 0.000 abstract description 3
- 230000000875 corresponding effect Effects 0.000 description 33
- 238000004891 communication Methods 0.000 description 10
- 230000008859 change Effects 0.000 description 8
- 238000005516 engineering process Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000009471 action Effects 0.000 description 5
- 230000003247 decreasing effect Effects 0.000 description 5
- 230000000694 effects Effects 0.000 description 5
- 238000013139 quantization Methods 0.000 description 5
- 238000013473 artificial intelligence Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 230000005236 sound signal Effects 0.000 description 4
- 230000001133 acceleration Effects 0.000 description 3
- 230000003044 adaptive effect Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000013459 approach Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000002596 correlated effect Effects 0.000 description 1
- 230000001186 cumulative effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000036961 partial effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000005070 sampling Methods 0.000 description 1
- 230000007704 transition Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/146—Data rate or code amount at the encoder output
Definitions
- the present disclosure relates to the field of image compression technology, and in particular, to an image compression method, device, electronic equipment, chip and storage medium.
- image compression methods based on the JPEG-LS standard require residual prediction of pixels to be compressed in adjacent scan lines based on the compression state of the current scan line, and residual prediction of the pixels to be compressed. The difference is quantized to encode and compress the quantized residual.
- the present disclosure provides an image compression method, device, electronic equipment, chip and storage medium to at least solve the technical problems existing in the related technology.
- an image compression method includes:
- the predicted code rate represents the compression parameters for the next scan based on the compression parameters corresponding to the current scan line. After the last scan line of the image is compressed, the final code rate of the image;
- the pixel data of the next scanning line is compressed.
- determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line includes:
- the compression parameter of the current scan line is reduced to obtain the compression parameter of the next scan line.
- determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line includes:
- the compression parameters of the next scan line are determined based on the predicted code rate, the code rate range, and the compression parameters of the current scan line.
- the method before determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line, the method further includes:
- Determining the compression parameters of the next scan line based on the predicted code rate, code rate range and compression parameters of the current scan line includes:
- the compression parameters of the next scan line are determined.
- the upper limit of the current code rate range is adjusted based on the predicted code rate of at least two scan lines before the current scan line and the predicted code rate of the current scan line, include:
- the method further includes:
- the method before determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line, the method further includes:
- the upper limit of the current code rate range is adjusted according to the attenuation factor corresponding to the current scan line.
- the attenuation factor is used to control the upper limit of the code rate to converge to the set target.
- Determining the compression parameters of the next scan line based on the predicted code rate, code rate range and compression parameters of the current scan line includes:
- the compression parameters of the next scan line are determined.
- the method further includes:
- the second line number threshold is obtained based on the total number of lines and the first proportional coefficient
- the second preset line value is determined as the second line number threshold.
- the method further includes:
- the attenuation factor is determined according to the current scan line number and the second line number threshold.
- determining the attenuation factor based on the current number of scanning lines and the second set threshold includes:
- the attenuation factor is obtained according to the current scanning line number and the corresponding relationship.
- the method further includes:
- the code rate range is determined according to the set target code rate and the set range coefficient.
- an image compression device includes:
- Parameter acquisition module used to obtain the compression parameters and code stream length of the current scan line, as well as the total length of the code stream from the first line to the current scan line;
- Code rate prediction module used to determine the predicted code rate of the current scan line based on the code stream length of the current scan line and the total length of the code stream from the first line to the current scan line.
- the predicted code rate representation is based on the current scan line correspondence.
- Parameter determination module used to determine the compression parameters of the next scan line based on the predicted code rate, code rate range and compression parameters of the current scan line;
- Compression module used to compress the pixel data of the next scanning line according to the compression parameters of the next scanning line.
- the parameter determination module is specifically used in the process of determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line:
- the compression parameter of the current scan line is reduced to obtain the compression parameter of the next scan line.
- the parameter determination module is specifically used in the process of determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line:
- the compression parameters of the next scan line are determined based on the predicted code rate, the code rate range, and the compression parameters of the current scan line.
- the device before the parameter determination module determines the compression parameters of the next scan line based on the predicted code rate, code rate range and the compression parameters of the current scan line, the device further includes a range adjustment Module for:
- the parameter determination module is specifically used to:
- the compression parameters of the next scan line are determined.
- the parameter determination module determines the current code rate range based on the predicted code rate of at least two scan lines before the current scan line and the predicted code rate of the current scan line. During the upper limit adjustment process, it is specifically used for:
- the device further includes a range limiting module for:
- the parameter determination module is specifically used in the process of determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line:
- the upper limit of the current code rate range is adjusted according to the attenuation factor corresponding to the current scan line.
- the attenuation factor is used to control the upper limit of the code rate to converge to the set target.
- the parameter determination module is specifically used to:
- the compression parameters of the next scan line are determined.
- the device further includes a second row number threshold determination module, used for:
- the second line number threshold is obtained based on the total number of lines and the first proportional coefficient
- the second preset line value is determined as the second line number threshold.
- the device further includes an attenuation factor determination module for:
- the attenuation factor is determined according to the current scan line number and the second line number threshold.
- the attenuation factor determination module is specifically used in the process of determining the attenuation factor based on the current scan line number and the second line number threshold:
- the attenuation factor is obtained according to the current scanning line number and the corresponding relationship.
- the device further includes a range determination module for:
- the code rate range is determined according to the set target code rate and the set range coefficient.
- an electronic device including:
- Memory for storing instructions executable by the processor
- the processor is configured to execute executable instructions in the memory to implement the steps of the method described in any embodiment of the first aspect.
- a computer-readable storage medium on which a computer program is stored.
- the program is executed by a processor, the steps of the method described in any embodiment of the first aspect are implemented.
- a chip including:
- One or more interface circuits and one or more processors are configured to receive signals from the memory of the electronic device and send the signals to the processor, where the signals include computer instructions stored in the memory;
- the processor executes the computer instructions, the electronic device is caused to execute the image compression method described in any embodiment of the first aspect.
- the predicted code rate of the entire image after compressing the remaining scan lines with the current compression parameters is obtained, and by setting the code rate range and combining the predicted code rate to adjust the compression parameters of the next scan line, so that each scan
- Each row can adjust the compression parameters of the next scanned row in time, so that the code rate after compression based on the compression parameters is controlled within the code rate range. It avoids relying on empirical information to control compression parameters, reduces code rate fluctuations, makes compression losses even and controllable, and improves the lossless probability of the entire image. In addition, since no complex calculation process is involved, the computing pressure on the device can be reduced.
- Figure 1 is a flow chart of an image compression method according to an exemplary embodiment of the present disclosure
- Figure 2 is a flow chart of compression parameter adjustment according to an exemplary embodiment of the present disclosure
- Figure 3 is a flow chart of determining a second row number threshold according to an exemplary embodiment of the present disclosure
- Figure 4 is a comparison diagram of image compression effects according to an exemplary embodiment of the present disclosure.
- Figure 5 is a schematic diagram of an image compression device according to an exemplary embodiment of the present disclosure.
- FIG. 6 is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure.
- first, second, third, etc. may be used in this disclosure to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other.
- first information may also be called second information, and similarly, the second information may also be called first information.
- word “if” as used herein may be interpreted as "when” or “when” or “in response to determining.”
- Figure 1 shows a flow chart of an image compression method according to an exemplary embodiment of the present disclosure.
- step S101 the compression parameters and code stream length of the current scanning line are obtained, as well as the total length of the code stream from the first line to the current scanning line.
- the compression parameters are used to reflect the degree of compression of the image, and are negatively correlated with the code stream length and code rate of the compressed scan lines.
- the current scan line compress the pixels of the current scan line of the image using the current compression parameters to obtain the compressed code stream length of the current scan line.
- the image is compressed using the compression parameters corresponding to each line to obtain the total length of the code stream from the first line to the current scanning line.
- the quantized prediction residual is encoded by a Golomb encoder, and the compression parameters can be characterized by the quantization step size.
- a large quantization step indicates a high degree of compression for the current scan line, and a small quantization step indicates a low degree of compression for the current scan line.
- the length of the code stream compressed by a larger quantization step is smaller.
- step S102 the predicted code rate of the current scan line is determined based on the code stream length of the current scan line and the total length of the code stream from the first line to the current scan line.
- the predicted code rate represents the compression corresponding to the current scan line.
- the parameter is the final code rate of the image after compression from the next scan line to the last scan line of the image.
- the code stream length of the current scan line and the total length of the code stream from the first line to the current scan line are used to represent the compression status of the current scan line and all historical scan lines.
- the predicted code rate is based on the compression status of the current scan line and the final code rate of the entire image after the remaining scan lines are compressed with the current compression parameters.
- the predicted code rate can be determined by formula (1):
- p represents the predicted code rate
- H represents the total number of lines of the image
- h represents the number of currently scanned lines, which can be obtained through the current row index
- Hh represents the number of remaining unscanned lines of the image
- b line represents the current scanned line.
- the length of the code stream, b total represents the total length of the code stream from the first line to the current scanning line.
- the numerator part of formula (1) represents the final code stream length of the entire image after compressing the remaining scan lines based on the current compression parameters.
- H and W represent the number of pixels in the image based on height and width respectively, and P represents the bit width of the image, which is used to represent the amount of information in each pixel in the image.
- the denominator part in formula (1) represents the total information amount of the image.
- the predicted code rate can be obtained by calculating the proportion of the predicted code stream length to the total amount of information in the image.
- step S103 the compression parameters of the next scan line are determined based on the predicted code rate, the code rate range, and the compression parameters of the current scan line.
- the code rate range is used to limit the fluctuation degree of the predicted code rate, which can be determined by setting a target code rate of the image or multiple experiments.
- the code rate range may include an upper limit and/or a lower limit of the predicted code rate.
- the predicted code rate can be increased or reduced by adjusting the compression parameters of the next scan line so that the predicted code rate returns to the code rate. rate range.
- step S104 the pixel data of the next scanning line is compressed according to the compression parameter of the next scanning line.
- the compression encoding can be controlled by adjusting the compression parameters of the next scanning line to encode and compress the pixels of the next scanning line.
- the quantized prediction residual can be encoded by the Golomb encoder based on the adjusted quantization step size.
- the scheme described in this disclosure obtains the predicted code rate of the entire image after compressing the remaining scan lines with the current compression parameters based on the compression status of the current scan line, and adjusts the code rate of the next scan line by setting the code rate range and combining it with the predicted code rate.
- Compression parameters enable each scan line to adjust the compression parameters of the next scan line in time, so that the code rate after compression based on the compression parameters is controlled within the code rate range. It avoids relying on empirical information or the content characteristics of the image itself to control compression parameters, reduces code rate fluctuations, makes compression losses uniform and controllable, and improves the lossless probability of the entire image. In addition, since no complex calculation process is involved, the computing pressure on the device can be reduced.
- determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line includes:
- the compression parameter of the current scan line is reduced to obtain the compression parameter of the next scan line.
- the predicted code rate of the current scan line exceeds the upper limit of the code rate, which means that the compression degree of the current scan line is too small.
- You can increase the compression parameter of the next scan line that is, increase the compression degree of the next scan line, to reduce Lower the code rate of the next scan line so that the code rate during the compression of the next scan line does not exceed the upper limit of the code rate.
- the predicted code rate of the current scan line is lower than the lower limit of the code rate, it means that the compression degree of the current scan line is too large. You can reduce the compression parameter of the next scan line, that is, reduce the compression degree of the next scan line.
- the code rate of the next scan line is increased so that the code rate during the compression of the next scan line is not lower than the lower limit of the code rate.
- Figure 2 shows a compression parameter adjustment flow chart disclosed in this application according to an exemplary embodiment.
- step S201 it is determined whether the predicted code rate is greater than the upper limit of the code rate.
- step S202 when the predicted code rate is greater than the upper code rate limit, it may be determined whether the current compression parameter is greater than the compression parameter threshold to determine whether the current compression process is in a regular compression mode.
- the compression parameter threshold can be set to 15.
- step S203 when the current compression process is in the normal compression mode, the compression parameters are increased.
- step S204 it is determined whether the predicted code rate is less than the lower limit of the code rate.
- step S205 when the predicted code rate is less than the lower limit of the code rate, it can be determined whether the current compression parameter is less than 0 to determine whether the current compression process is in the compression process, that is, whether the current compression process is in the conventional compression process. model.
- step S206 if the current compression process is in the normal compression mode, the compression parameters are reduced.
- step S207 if the predicted code rate is within the code rate range, the current compression parameters may be maintained.
- the method of maintaining the current compression parameters can also be used to wait for further processing.
- the compression parameter can be increased by adding 1 to the compression parameter and decreased by decrementing the compression parameter by 1 to ensure that the compression parameter variation of adjacent scan lines is controlled at 1 or 0. , to avoid obvious compression losses in the compressed image due to sudden increases or decreases in compression parameters, thereby ensuring uniform compression intensity in the image.
- the scheme described in this disclosure adjusts the compression parameters in time by comparing the predicted code rate of the current scan line with the code rate range so that the code rate of the next scan line is controlled within the code rate range. At the same time, by limiting the compression parameters every The amount of adjustment is to avoid obvious compression loss in the compressed image, thereby ensuring uniform compression intensity in the image.
- determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line includes:
- the compression parameters of the next scan line are determined based on the predicted code rate, the code rate range, and the compression parameters of the current scan line.
- the code rate of different scanning lines of the image is due to the excessive complexity of the image, Due to large fluctuations due to objective reasons, selecting a bit rate range that is too small may cause the compression process to fail to operate normally. Therefore, before determining the bit rate range, scan lines before the first line number threshold can be scanned. For compression limited by a code rate range, the code rate range is determined based on the compression state of the image. In one example, the first line number threshold is 10.
- the code rate range is determined according to the set target code rate and the set range coefficient.
- the set target bit rate represents the final bit rate that the user hopes to compress the current image.
- the set range coefficient may be determined based on the compression state of the scan lines before the first line number threshold. For example, a set target code rate of 110% is determined as the upper limit of the code rate, and a set code rate range of 95% is determined as the lower limit of the code rate to ensure that the code rate during the image compression process always surrounds the set code rate. Target code rate fluctuations.
- the scheme described in this disclosure first performs compression without code rate range restrictions on the first line number threshold and the scanning lines before it, and then determines the code rate range according to the compression state of the image to ensure the compression range. Choose wisely.
- the code rate range is determined according to the target set code rate and the range coefficient to ensure that the code rate during the image compression process always fluctuates around the set target code rate.
- the method before determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line, the method further includes:
- Determining the compression parameters of the next scan line based on the predicted code rate, code rate range and compression parameters of the current scan line includes:
- the compression parameters of the next scan line are determined.
- the prediction of at least two scan lines before the current scan line can be used.
- the code rate and the predicted code rate of the current scan line are obtained, the predicted code rate change trend of the most recent scan lines is obtained, and the code rate range is adaptively adjusted according to the change trend.
- specific code rate range adjustment methods include:
- the overall predicted code rate changes as the number of lines increases, usually showing a W-type or M-type, that is, the prediction at the Nth scanning line
- the predicted code rate of the N+1th scan line is greater than the predicted code rate of the adjacent scan line.
- the most recent scan can be determined by the change trend of the predicted code rate of the adjacent scan lines. Part of the code rate change trend.
- the two predicted code rates corresponding to the current scanning line and its two preceding lines can be determined as the to-be-detected Predicted code rate; when determining the predicted code rate to be detected based on the current scanning line and its first five scanning lines, the current scanning line and the three predictions corresponding to the first two lines and the first four lines can be The code rate is determined as the predicted code rate to be detected, or the three predicted code rates corresponding to the first row, the first three rows and the first five rows from the current scan line are determined as the predicted code rate to be detected, and the code rate is determined according to the predicted code rate to be detected.
- the increase or decrease trend of the predicted code rate is detected to determine the adjustment method for the upper limit of the code rate.
- the predicted code rates corresponding to the first five scan lines adjacent to the current scan line can be fixedly determined as the predicted code rate to be detected, and after the scanning compression of the current scan line is completed, the code rate can be automatically moved to the next line.
- the predicted code rates corresponding to the first five scan lines of the next scan line are determined as the predicted code rates to be detected.
- the scheme described in this disclosure adaptively adjusts the code rate range according to the code rate change trend of the most recent scan lines, so that during the compression process, more code stream lengths are allocated in complex texture areas and less code stream lengths are allocated in simple texture areas.
- the length of the code stream reduces the bit rate oscillation during the encoding process, thereby achieving a reasonable distribution of the code stream during the encoding process and achieving a uniform and excessive effect of reconstructed image quality.
- the method further includes:
- the code rate range can be adaptively adjusted according to the code rate change trend of the most recent scan lines
- the degree of adaptive adjustment of the code rate range should still be limited to a certain extent to avoid the code rate upper limit.
- Unlimited raising or lowering You can limit the number of increases or decreases in the code rate upper limit by setting a threshold for increases and decreases, or you can also set an increase or decrease range value isomorphically to control the specific value of the upper limit of the code rate to remain within an appropriate range.
- the upper limit of the code rate can be adjusted by increasing or decreasing the upper limit of the code rate by 5%, and the result of the increase or decrease in the upper limit of the code rate is marked by the flag bit f. After the upper limit is increased, f is marked as true. After the upper limit is lowered, f is marked as false, so that the upper limit of the code rate cannot be continuously increased or decreased, and can only be adjusted within the range of ⁇ 5%.
- the conditions for increasing and decreasing the code rate upper limit can be expressed by formula (2) and formula (3) respectively.
- P0-P4 represents the predicted code rate corresponding to the five historical scan lines adjacent to the current scan line
- p represents the predicted code rate of the current scan line
- rt represents the set target code rate
- l represents the upper limit distance of 100%.
- the triggering conditions for increasing or decreasing the upper limit of the code rate can be further refined through the difference between the predicted code rate of the current scan line and the set target code rate or the difference between the predicted code rate to be detected.
- the solution described in this disclosure limits the number of increases or decreases in the upper code rate by setting a threshold for the number of increases and a threshold for the number of decreases, or by using a range value to keep the specific value of the upper limit of the code rate within an appropriate range to avoid During the adaptive adjustment process of the upper limit of the code rate, the upper limit of the code rate can increase or decrease without restriction.
- the method before determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line, the method further includes:
- the current upper limit of the code rate range is adjusted according to the attenuation factor corresponding to the current scan line.
- the attenuation factor is used to control the upper limit of the code rate to converge to the set target code. Rate;
- Determining the compression parameters of the next scan line based on the predicted code rate, code rate range and compression parameters of the current scan line includes:
- the compression parameters of the next scan line are determined.
- the final compression code rate in the entire image compression process is constrained by gradually converging the upper limit of the code rate to the set target code rate.
- the attenuation factor is used to control the upper limit of the code rate to converge to a set target code rate.
- the second line number threshold represents the attenuation starting point in the image scanning and compression process. If the code rate upper limit passes through the adaptive adjustment stage before the attenuation starting point, the code rate upper limit is reset at the attenuation starting point. is the initial upper limit, such as the upper limit of the code rate corresponding to the next scan line of the first line number threshold.
- the method further includes:
- the attenuation factor is determined according to the current scan line number and the second line number threshold.
- the attenuation factor can be determined through formula (4):
- decay represents the attenuation factor
- h represents the number of lines currently scanned
- h st represents the second line number threshold, that is, the number of lines from which the attenuation starts. Therefore, the attenuation factor can be expressed by an exponential function with a as the base and the cumulative number of rows after the attenuation starting point as the power.
- the upper limit of the code rate gradually converges to the set target code rate, so as to constrain the final compression code rate in the entire image compression process.
- determining the attenuation factor based on the current number of scanning lines and the second set threshold includes:
- the attenuation factor is obtained according to the current scanning line number and the corresponding relationship.
- the attenuation factor corresponding to each scan line can be obtained by looking up the table. If the table is too large and difficult to obtain, jump point sampling can be performed by setting the step size. Points within the step size range can be calculated through the look-ahead difference between two table lookup results that are close to the table lookup value.
- the attenuation factor corresponding to each scanning line is directly obtained by looking up the table, so as to further reduce the computing pressure of the device.
- the method further includes:
- the second line number threshold is obtained based on the total number of lines and the first proportional coefficient
- the second preset line value is determined as the second line number threshold.
- Figure 3 discloses a second line number threshold determination flowchart according to an exemplary embodiment of the present disclosure, where H represents the total number of lines of the image, and h st represents the second line number threshold.
- the 375th line from the bottom of the image is determined as the second line number threshold
- the tenth line of the total number of image lines is determined as the second line number threshold. Further, in order to avoid that the upper limit of the code rate still cannot converge to the set target code rate at the end of the scan, it can be judged in the tenth line from the bottom of the image whether the convergence of the upper limit of the code rate can be completed based on the current attenuation factor. If If not, the attenuation factor is set to 0, and the set target bit rate is directly determined as the upper limit of the bit rate, so as to complete the convergence of the compression bit rate of the image in a timely manner.
- the scanning compression process is controlled to converge on the upper limit of the code rate at an appropriate convergence starting point, so as to constrain the final result of the entire image compression process. Compression code rate.
- FIG. 4 shows an image compression effect comparison diagram according to an exemplary embodiment of the present disclosure.
- Figure 4 takes as an example whether the bayer image is compressed by the method described in the present disclosure, which can reflect the before and after comparison effect of whether the scheme described in the present disclosure is adopted for image compression.
- the x-axis is the index of the number of scanning lines
- the y-axis is the actual code rate corresponding to each scanning line.
- the code rate oscillation during the image compression process can be significantly reduced, and the actual code rate can be converged to the target code rate faster.
- bit rate control can be achieved for images of different types and sizes.
- the code rate range is adaptively adjusted according to the code rate change trend of the recent scan lines, so that during the compression process, more code stream lengths are allocated in complex texture areas and more code stream lengths are allocated in simple texture areas. , Reduce the bit rate oscillation during the encoding process, thereby achieving a uniform transition of reconstructed image quality, so that the image quality can be effectively controlled.
- the present disclosure also provides embodiments of application function implementation devices and corresponding terminals.
- FIG. 5 A block diagram of an image compression device according to an exemplary embodiment of the present disclosure is shown in Figure 5.
- the device includes:
- Parameter acquisition module used to obtain the compression parameters and code stream length of the current scan line, as well as the total length of the code stream from the first line to the current scan line;
- Code rate prediction module used to determine the predicted code rate of the current scan line based on the code stream length of the current scan line and the total length of the code stream from the first line to the current scan line.
- the predicted code rate representation is based on the current scan.
- the final code rate of the image after the compression parameters corresponding to the row compress the next scan line to the last scan line of the image;
- Parameter determination module used to determine the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line;
- Compression module configured to compress the pixel data of the next scanning line according to the compression parameters of the next scanning line.
- the parameter determination module is specifically used in the process of determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line:
- the compression parameter of the current scan line is reduced to obtain the compression parameter of the next scan line.
- the parameter determination module is specifically used in the process of determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line:
- the compression parameters of the next scan line are determined based on the predicted code rate, the code rate range, and the compression parameters of the current scan line.
- the device before the parameter determination module determines the compression parameters of the next scan line based on the predicted code rate, code rate range and the compression parameters of the current scan line, the device further includes a range adjustment Module for:
- the parameter determination module is specifically used to:
- the compression parameters of the next scan line are determined.
- the parameter determination module determines the upper limit of the current code rate range based on the predicted code rate of at least two scan lines before the current scan line and the predicted code rate of the current scan line. During the adjustment process, it is specifically used for:
- the device further includes a range limiting module for:
- the parameter determination module is specifically used in the process of determining the compression parameters of the next scan line based on the predicted code rate, code rate range, and compression parameters of the current scan line:
- the current upper limit of the code rate range is adjusted according to the attenuation factor corresponding to the current scan line.
- the attenuation factor is used to control the upper limit of the code rate to converge to the set target code. Rate;
- the parameter determination module is specifically used to:
- the compression parameters of the next scan line are determined.
- the device further includes a second row number threshold determination module, used for:
- the second line number threshold is obtained based on the total number of lines and the first proportional coefficient
- the second preset line value is determined as the second line number threshold.
- the device further includes an attenuation factor determination module for:
- the attenuation factor is determined according to the current scan line number and the second line number threshold.
- the attenuation factor determination module is specifically used in the process of determining the attenuation factor based on the current scan line number and the second line number threshold:
- the attenuation factor is obtained according to the current scanning line number and the corresponding relationship.
- the device further includes a range determination module for:
- the code rate range is determined according to the set target code rate and the set range coefficient.
- the device embodiment since it basically corresponds to the method embodiment, please refer to the partial description of the method embodiment for relevant details.
- the device embodiments described above are only illustrative.
- the units described above as separate components may or may not be physically separated.
- the components shown as units may or may not be physical units, that is, they may be located in a place, or can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. Persons of ordinary skill in the art can understand and implement the method without any creative effort.
- FIG. 6 shows a block diagram of an electronic device according to an exemplary embodiment of the present disclosure.
- the device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like.
- the device 600 may include one or more of the following components: a processing component 602, a memory 604, a power supply component 606, a multimedia component 608, an audio component 610, an input/output (I/O) interface 612, a sensor component 614, and communications component 616.
- Processing component 602 generally controls the overall operations of device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations.
- the processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above method.
- processing component 602 may include one or more modules that facilitate interaction between processing component 602 and other components.
- processing component 602 may include a multimedia module to facilitate interaction between multimedia component 608 and processing component 602.
- Memory 604 is configured to store various types of data to support operations at device 600 . Examples of such data include instructions for any application or method operating on device 600, contact data, phonebook data, messages, pictures, videos, etc.
- Memory 604 may be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EEPROM), Programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
- SRAM static random access memory
- EEPROM electrically erasable programmable read-only memory
- EEPROM erasable programmable read-only memory
- EPROM Programmable read-only memory
- PROM programmable read-only memory
- ROM read-only memory
- magnetic memory flash memory, magnetic or optical disk.
- Power component 606 provides power to various components of device 600.
- Power components 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to device 600.
- Multimedia component 608 includes a screen that provides an output interface between the device 600 and the user.
- the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user.
- the touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide action.
- multimedia component 608 includes a front-facing camera and/or a rear-facing camera.
- the front camera and/or the rear camera may receive external multimedia data.
- Each front-facing camera and rear-facing camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
- Audio component 610 is configured to output and/or input audio signals.
- audio component 610 includes a microphone (MIC) configured to receive external audio signals when device 600 is in operating modes, such as call mode, recording mode, and speech recognition mode. The received audio signal may be further stored in memory 604 or sent via communication component 616 .
- audio component 610 includes a speaker for outputting audio signals.
- the I/O interface 612 provides an interface between the processing component 602 and a peripheral interface module, which may be a keyboard, a click wheel, a button, etc. These buttons may include, but are not limited to: Home button, Volume buttons, Start button, and Lock button.
- Sensor component 614 includes one or more sensors for providing various aspects of status assessment for device 600 .
- the sensor component 614 may detect the open/closed state of the device 600, the relative positioning of components, such as the display and keypad of the device 600, the sensor component 614 may detect a change in position of the device 600 or a component of the device 600, The presence or absence of user contact with the device 600, device 600 orientation or acceleration/deceleration and temperature changes of the device 600.
- Sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact.
- Sensor assembly 614 may include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications.
- the sensor component 614 may include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
- Communication component 616 is configured to facilitate wired or wireless communication between apparatus 600 and other devices.
- the device 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G or 5G or a combination thereof.
- the communication component 616 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel.
- the communications component 616 includes a near field communications (NFC) module to facilitate short-range communications.
- NFC near field communications
- the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
- RFID radio frequency identification
- IrDA infrared data association
- UWB ultra-wideband
- Bluetooth Bluetooth
- apparatus 600 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable Gate array (FPGA), controller, microcontroller, microprocessor or other electronic components are implemented for executing the power supply method of the above electronic device.
- ASICs application specific integrated circuits
- DSPs digital signal processors
- DSPDs digital signal processing devices
- PLDs programmable logic devices
- FPGA field programmable Gate array
- controller microcontroller, microprocessor or other electronic components are implemented for executing the power supply method of the above electronic device.
- the present disclosure provides a non-transitory computer-readable storage medium including instructions, such as a memory 604 including instructions.
- the instructions can be executed by the processor 620 of the device 600 to complete the power supply method of the electronic device.
- the non-transitory computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
- the present disclosure also provides a chip, which specifically includes one or more interface circuits and one or more processors.
- the interface circuit is used to receive signals from a memory of an electronic device and send the signals to the processor.
- the signals include computer instructions stored in memory.
- the processor executes the computer instructions, the electronic device is caused to execute the image compression method described in any one of the disclosure.
- the chip can be a conventional CPU (central processing unit, central processing unit) chip, a GPU (graphics processing unit, graphics processor) chip, etc., or it can be an acceleration chip dedicated to artificial intelligence technology, such as AI (Artificial Intelligence). , artificial intelligence) accelerator, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
本公开提供一种图像压缩方法、装置、电子设备、芯片及储存介质,所述方法包括:根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。通过本公开所述方案,避免了依赖经验信息对压缩参数进行控制,并将码率限制在码率范围内,减少码率震荡,使压缩损失更均匀,提升全图的无损概率。此外,由于不涉及复杂计算过程,可以减小设备的运算压力。
Description
本公开涉及图像压缩技术领域,尤其涉及一种图像压缩方法、装置、电子设备、芯片及储存介质。
当前,基于JPEG-LS标准(用于连续色调图像无损压缩的静态图像压缩标准)的图像压缩方法,需要通过当前扫描行的压缩状态对邻近扫描行的待压缩像素进行残差预测,并对残差进行量化处理以对量化后的残差进行编码压缩。
由于常规模式下,需要以经验值确定的压缩参数对图像的扫描行进行压缩编码,而由于图像中不同扫描行生成的预测残差与真实值的偏离程度不同,通过同一压缩参数进行压缩会使每一扫描行压缩后的码流长度出现无规律的波动,引起码率震荡,使图像压缩损失不均匀,难以控制图像压缩后的画质损失。
发明内容
有鉴于此,本公开提供一种图像压缩方法、装置、电子设备、芯片及储存介质,以至少解决相关技术中存在的技术问题。
根据本公开实施例的第一方面,提供了一种图像压缩方法,所述方法包括:
获取当前扫描行的压缩参数和码流长度,以及首行至所述当前扫描行的码流总长度;
根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,所述预测码率表征基于当前扫描行对应的压缩参 数对下一个扫描行至图像最后扫描行压缩后,所述图像的最终码率;
根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数;
根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。
结合本公开的任一实施方式,所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
在所述当前扫描行的预测码率大于码率上限的情况下,提升所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数;和/或,
在所述当前扫描行的预测码率小于码率下限的情况下,降低所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
响应于当前扫描行数大于第一行数阈值,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,在所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,还包括:
响应于当前扫描行数大于所述第一行数阈值且小于等于第二行数阈值,根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整;
所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限 进行调整,包括:
根据预设规则,在所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率中,选取待检测预测码率;
在所述待检测预测码率依次递增的情况下,提升所述码率上限;
在所述待检测预测码率依次递减的情况下,降低所述码率上限。
结合本公开的任一实施方式,所述方法还包括:
在所述码率上限的提升次数超过提升次数阈值的情况下,停止提升所述码率上限,在所述码率上限的降低次数超过降低次数阈值的情况下,停止降低所述码率上限,或;
在提升后的码率上限超出提升范围阈值的情况下,停止提升当次码率上限;
在降低后的码率上限超出降低范围阈值的情况下,停止降低当次码率上限。
结合本公开的任一实施方式,在所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,还包括:
响应于当前扫描行数大于第二行数阈值,根据当前扫描行对应的衰减因子,对当前的码率范围的上限进行调整,所述衰减因子用于控制所述码率上限收敛至设定目标码率;
所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述方法还包括:
在当前图像的总行数大于第三行数阈值的情况下,根据所述总行数和第一比例系数,得到所述第二行数阈值;
在图像的总行数小于第三行数阈值且大于第四行数阈值的情况下,将所 述总行数减去第一预设行数值,得到所述第二行数阈值;
在图像的总行数小于第四行数阈值的情况下,将第二预设行数值确定为所述第二行数阈值。
结合本公开的任一实施方式,所述方法还包括:
根据当前扫描行数和所述第二行数阈值,确定所述衰减因子。
结合本公开的任一实施方式,所述根据当前扫描行数和所述第二设定阈值,确定所述衰减因子,包括:
获取所述当前扫描行数和所述衰减因子的对应关系;
根据所述当前扫描行数和所述对应关系,获取所述衰减因子。
结合本公开的任一实施方式,所述方法还包括:
响应于当前扫描行为所述第一行数阈值对应行的下一行,根据设定目标码率和设定范围系数,确定所述码率范围。
根据本公开实施例的第二方面,提供了一种图像压缩装置,所述装置包括:
参数获取模块:用于获取当前扫描行的压缩参数和码流长度,以及首行至所述当前扫描行的码流总长度;
码率预测模块:用于根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,所述预测码率表征基于当前扫描行对应的压缩参数对下一个扫描行至图像最后扫描行压缩后,所述图像的最终码率;
参数确定模块:用于根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数;
压缩模块:用于根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体 用于:
在所述当前扫描行的预测码率大于码率上限的情况下,提升所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数;和/或,
在所述当前扫描行的预测码率小于码率下限的情况下,降低所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
响应于当前扫描行数大于第一行数阈值,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,所述装置还包括范围调整模块,用于:
响应于当前扫描行数大于所述第一行数阈值且小于等于第二行数阈值,根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整;
所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述参数确定模块在根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整过程中,具体用于:
根据预设规则,在所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率中,选取待检测预测码率;
在所述待检测预测码率依次递增的情况下,提升所述码率上限;
在所述待检测预测码率依次递减的情况下,降低所述码率上限。
结合本公开的任一实施方式,所述装置还包括范围限制模块,用于:
在所述码率上限的提升次数超过提升次数阈值的情况下,停止提升所述码率上限,在所述码率上限的降低次数超过降低次数阈值的情况下,停止降低所述码率上限,或;
在提升后的码率上限超出提升范围阈值的情况下,停止提升当次码率上限;
在降低后的码率上限超出降低范围阈值的情况下,停止降低当次码率上限。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
响应于当前扫描行数大于第二行数阈值,根据当前扫描行对应的衰减因子,对当前的码率范围的上限进行调整,所述衰减因子用于控制所述码率上限收敛至设定目标码率;
所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述装置还包括第二行数阈值确定模块,用于:
在当前图像的总行数大于第三行数阈值的情况下,根据所述总行数和第一比例系数,得到所述第二行数阈值;
在图像的总行数小于第三行数阈值且大于第四行数阈值的情况下,将所述总行数减去第一预设行数值,得到所述第二行数阈值;
在图像的总行数小于第四行数阈值的情况下,将第二预设行数值确定为所述第二行数阈值。
结合本公开的任一实施方式,所述装置还包括衰减因子确定模块,用于:
根据当前扫描行数和所述第二行数阈值,确定所述衰减因子。
结合本公开的任一实施方式,所述衰减因子确定模块在根据当前扫描行数和所述第二行数阈值,确定所述衰减因子过程中,具体用于:
获取所述当前扫描行数和所述衰减因子的对应关系;
根据所述当前扫描行数和所述对应关系,获取所述衰减因子。
结合本公开的任一实施方式,所述装置还包括范围确定模块,用于:
响应于当前扫描行为所述第一行数阈值对应行的下一行,根据设定目标码率和设定范围系数,确定所述码率范围。
根据本公开实施例的第三方面,提供了一种电子设备,包括:
存储器,用于存储所述处理器可执行指令;
处理器,被配置为执行所述存储器中的可执行指令以实现上述第一方面任一实施方式所述方法的步骤。
根据本公开实施例的第四方面,提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述第一方面任一实施方式所述方法的步骤。
根据本公开实施例的第五方面,提供一种芯片,包括:
一个或多个接口电路和一个或多个处理器;所述接口电路用于从电子设备的存储器接收信号,并向所述处理器发送所述信号,所述信号包括存储器中存储的计算机指令;当所述处理器执行所述计算机指令时,使得所述电子设备执行上述第一方面任一实施方式所述的图像压缩方法。
本公开实施例提供的技术方案可以包括以下有益效果:
基于当前扫描行的压缩状态,得到以当前压缩参数压缩剩余扫描行后全图的预测码率,并通过设置码率范围,结合预测码率以调整下一扫描行的压缩参数,使每一扫描行都能够对下一扫描行的压缩参数进行及时调整,使得基于压缩参数压缩后的码率控制在码率范围内。避免依赖经验信息对压缩参数进行控制,减少码率震荡,使压缩损失均匀可控,提升了全图的无损概率。 此外,由于不涉及复杂计算过程,可以减小设备的运算压力。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。
图1是本公开根据一示例性实施例示出的一种图像压缩方法流程图;
图2是本公开根据一示例性实施例示出的一种压缩参数调整流程图;
图3是本公开根据一示例性实施例示出的一种第二行数阈值确定流程图;
图4是本公开根据一示例性实施例示出的一种图像压缩效果对照图;
图5是本公开根据一示例性实施例示出的一种图像压缩装置示意图;
图6是本公开根据一示例性实施例示出的一种电子设备框图。
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。
在本公开使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本公开。在本公开和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。
应当理解,尽管在本公开可能采用术语第一、第二、第三等来描述各种信 息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本公开范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。
图1示出了本公开根据一示例性实施例示出的一种图像压缩方法流程图。
在步骤S101中,获取当前扫描行的压缩参数和码流长度,以及首行至所述当前扫描行的码流总长度。
所述压缩参数用于反应图像的压缩程度,与压缩后扫描行的码流长度和码率负相关。在当前扫描行中,通过当前的压缩参数对图像当前扫描行的像素进行压缩,以获取当前扫描行压缩后的码流长度。同样的,在图像首行至当前扫描行的扫描压缩过程中,通过每行对应的压缩参数对图像进行压缩,得到首行至所述当前扫描行的码流总长度。在JPEG-LS标准中,通过Golomb编码器对量化后的预测残差进行编码,可以通过量化步长表征所述压缩参数。量化步长大,表示当前扫描行的压缩程度高,量化步长小,表示当前扫描行的压缩程度低。对于同一扫描行,通过更大的量化步长压缩后的码流长度更小。
在步骤S102中,根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,所述预测码率表征基于当前扫描行对应的压缩参数对下一个扫描行至图像最后扫描行压缩后,所述图像的最终码率。
所述当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,用于表示在当前扫描行及全部历史扫描行的压缩状态。所述预测码率是基于截止当前扫描行的压缩状态,推算得到的以当前压缩参数压缩剩余扫描行后全图的最终码率。在一个示例中,所述预测码率可以通过公式(1)确定:
其中,p表示所述预测码率,H表示图像的总行数,h表示当前扫描行的行数,可以通过当前所在行索引获取,H-h表示图像的剩余未扫描行数,b
line表示当前扫描行的码流长度,b
total表示首行至所述当前扫描行的码流总长度。公式 (1)的分子部分表示基于当前的压缩参数压缩剩余扫描行后全图的最终码流长度。
H和W分别表示图像基于高度和宽度的像素量,P表示图像的比特位宽,用于表示图像中每个像素的信息量。公式(1)中的分母部分表示图像的总信息量。
通过计算预测码流长度在图像中总信息量的占比,可以获取所述预测码率。
在步骤S103中,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
所述码率范围用于限制所述预测码率的波动程度,可以通过图像的设定目标码率或多次实验确定。所述码率范围可以包括所述预测码率的上限和/或下限。在一个示例中,可以在所述预测码率超出所述码率范围的情况下,通过调整下一扫描行的压缩参数提升或降低预测码率,以使所述预测码率回归至所述码率范围。
在步骤S104中,根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。
可以控制压缩编码通过调整后的下一扫描行的压缩参数,对下一个扫描行的像素进行编码压缩。在JPEG-LS标准中,可以通过Golomb编码器基于调整后的量化步长对量化后的预测残差进行编码。
本公开所述方案,通过基于当前扫描行的压缩状态,得到以当前压缩参数压缩剩余扫描行后全图的预测码率,并通过设置码率范围,结合预测码率以调整下一扫描行的压缩参数,实现每一扫描行都能够对下一扫描行的压缩参数进行及时调整,使得基于压缩参数压缩后的码率控制在码率范围内。避免了依赖经验信息或图像本身内容特性对压缩参数进行控制,减少码率震荡,使压缩损失均匀可控,提升了全图的无损概率。此外,由于不涉及复杂计算过程,可以减小设备的运算压力。
在一个可选的实施例中,所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
在所述当前扫描行的预测码率大于码率上限的情况下,提升所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数;和/或,
在所述当前扫描行的预测码率小于码率下限的情况下,降低所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数。
可选的,当前扫描行的预测码率超出所述码率上限,表示当前扫描行的压缩程度过小,可以通过提升下一个扫描行的压缩参数,即提升下一个扫描行的压缩程度,以降低下一个扫描行的码率,使在对下一扫描行进行压缩的过程中的码率不超出所述码率上限。
同样的,当前扫描行的预测码率低于所述码率下限,表示当前扫描行的压缩程度过大,可以通过降低下一个扫描行的压缩参数,即降低下一个扫描行的压缩程度,以提升下一个扫描行的码率,以使在对下一扫描行进行压缩的过程中的码率不低于所述码率下限。
图2示出了本申请公开根据一示例性实施例示出的一种压缩参数调整流程图。
在步骤S201中,判断所述预测码率是否大于码率上限。
在步骤S202中,在所述预测码率大于所述码率上限的情况下,可以判断当前的压缩参数是否大于压缩参数阈值,以确定当前的压缩过程是否处于常规压缩模式,在一个示例中,所述压缩参数阈值可以设置为15。
在步骤S203中,在当前压缩过程处于常规压缩模式的情况下,提升所述压缩参数。
在步骤S204中,判断所述预测码率是否小于码率下限。
在步骤S205中,在所述预测码率小于所述码率下限的情况下,可以判断当前的压缩参数是否小于0,以确定当前是否处于压缩过程,也即确定当前的压缩过程是否处于常规压缩模式。
在步骤S206中,在当前压缩过程处于常规压缩模式的情况下,降低所述压缩参数。
在步骤S207中,在所述预测码率在码率范围内的情况下,可以保持当前压缩参数。此外,在当前不处于常规压缩模式的情况下,也可以通过保持当前压缩参数的方法等待进一步处理。
在一个示例中,可以通过对压缩参数加1的方式提升所述压缩参数,通过对压缩参数减1的方式降低所述压缩参数,以确保相邻扫描行的压缩参数变化量控制在1或0,避免由于压缩参数的骤增或骤降使压缩后的图像有明显的压缩损失,从而保证图像中压缩强度的均匀过度。
本公开所述方案,通过比较当前扫描行的预测码率与码率范围,及时调整压缩参数,以使下一扫描行的码率控制在码率范围内,同时,通过限制所述压缩参数每次的调整量,避免压缩后的图像有明显的压缩损失,从而保证图像中压缩强度的均匀过度。
在一个可选的实施例中,所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
响应于当前扫描行数大于第一行数阈值,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
可选的,由于在图像刚刚启动扫描压缩过程时,无法确定所述扫描范围的选取是否合理,且前几行没有足够的历史信息,若由于图像复杂程度过大导致图像不同扫描行的码率由于客观原因存在较大波动,选取过小的码率范围可能会导致所述压缩过程无法正常运行,因此可以在确定所述码率范围前,先对第一行数阈值前的扫描行进行***率范围限制的压缩,再根据所述图像的压缩状态确定所述码率范围,在一个示例中,所述第一行数阈值为10。
在一个示例中,响应于当前扫描行为所述第一行数阈值对应行的下一行,根据设定目标码率和设定范围系数,确定所述码率范围。
所述设定目标码率表示用户希望对当前图像压缩后的最终码率。所述设定范围系数可以根据第一行数阈值前的扫描行的压缩状态确定。例如,将110%的设定目标码率确定为所述码率上限,将95%的设定码率范围确定为所述码率下 限,以确保图像压缩过程中的码率始终围绕所述设定目标码率波动。
本公开所述方案,通过先对第一行数阈值及其之前的扫描行进行***率范围限制的压缩,再根据所述图像的压缩状态确定所述码率范围,保证所述压缩范围的合理选取。此外,根据目标设定码率和范围系数确定所述码率范围,以确保图像压缩过程中的码率始终围绕所述设定目标码率波动。
在一个可选的实施例中,在所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,还包括:
响应于当前扫描行数大于所述第一行数阈值且小于等于第二行数阈值,根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围上限进行调整;
所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
可选的,在所述当前扫描行数大于第一行数阈值的情况下,在所述当前扫描行前存在若干历史扫描行,可以根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,获取最近部分扫描行的预测码率变化趋势,并根据所述变化趋势自适应调整所述码率范围。
在一个示例中,具体的码率范围调整方法包括:
根据预设规则,在所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率中,选取待检测预测码率;
在所述待检测预测码率依次递增的情况下,提升所述码率上限;
在所述待检测预测码率依次递减的情况下,降低所述码率上限。
可选的,在基于JPEG-LS标准对图像进行压缩的过程中,由于存在码率小幅震荡,整体预测码率变化随行数增加通常呈现W型或M型,即在第N个扫描行的预测码率小于相邻扫描行的预测码率的情况下,第N+1个扫描行的预测码 率大于相邻扫描行的预测码率,可以通过相隔扫描行的预测码率变化趋势确定最近扫描部分的码率变化趋势。在根据当前扫描行及其前2个扫描行确定所述待检测预测码率的情况下,可以将所述当前扫描行与距其前2行对应的2个预测码率确定为所述待检测预测码率;在根据当前扫描行及其前5个扫描行确定所述待检测预测码率的情况下,可以将所述当前扫描行与距其前2行和前4行对应的3个预测码率确定为所述待检测预测码率,或将距当前扫描行前1行、前3行和前5行对应的3个预测码率确定为所述待检测预测码率,并根据所属待检测预测码率的增减趋势确定所述码率上限的调整方式。在一个示例中,可以固定将当前扫描行相邻的前5个扫描行对应的预测码率确定为所述待检测预测码率,在结束对当前扫描行的扫描压缩后,自动向下一行移动所述历史扫描行的选取范围,将下一扫描行的前5个扫描行对应的预测码率确定为所述待检测预测码率。
在所述预测码率依次递增的情况下,表示最近扫描部分的码率呈增加趋势,间接表示当前扫描部分为图像的复杂纹理区域,可以通过提升所述码率上限,允许在当前区域以较小的压缩参数进行压缩,以在纹理复杂区域分配更多的码流长度。
在所述预测码率依次递减的情况下,表示最近扫描部分的码率呈下降趋势,间接表示当前扫描部分为图像的简单纹理区域,可以通过降低所述码率上限,允许在当前区域以较大的压缩参数进行压缩,以在简单纹理区域分配更少的码流长度。
本公开所述方案,通过根据最近部分扫描行的码率变化趋势自适应调整码率范围,以使压缩过程中,在复杂纹理区域分配更多的码流长度,在简单纹理区域分配更少的码流长度,减少编码过程中的码率震荡,从而实现编码过程中码流的合理分配,达到重建图像画质的均匀过度的效果。
在一个可选的实施例中,所述方法还包括:
在所述码率上限的提升次数超过提升次数阈值的情况下,停止提升所述码 率上限,在所述码率上限的降低次数超过降低次数阈值的情况下,停止降低所述码率上限,或;
在提升后的码率上限超出提升范围阈值的情况下,停止提升当次码率上限;
在降低后的码率上限超出降低范围阈值的情况下,停止降低当次码率上限。
可选的,虽然在前述方法中,可以根据最近部分扫描行的码率变化趋势自适应调整码率范围,但码率范围的适应性调整程度仍应具有一定的程度限制,以避免码率上限无限制的升高或降低。可以通过设置提升次数阈值和降低次数阈值限制所述码率上限的升高或降低次数,也可以同构设置提升或降低范围值的方法,控制所述码率上限的具体数值保持在适当区间。
在一个示例中,可以通过对所述码率上限提升或降低5%实现对码率上限的调整,并且通过标志位f对所述码率上限的提升或降低结果进行标志,在上限提高后,f标记为true,上限降低后,f标记为false,以使所述码率上限无法连续升高或降低,只能够在±5%的范围内进行调整。
在一个示例中,所述码率上限的提升和降低条件可以分别通过公式(2)和公式(3)表示。
其中,P0-P4表示距当前扫描行相邻的5个历史扫描行对应的预测码率,p表示当前扫描行的预测码率,rt表示所述设定目标码率,l表示上限距离100%的偏移量,且每次满足调整条件时,调整量直接加到l上,!f表示所述码率上限可以提升,f表示所述码率上限可以降低。
进一步的,根据实验数据,可以通过当前扫描行的预测码率与设定目标码率的比例范围或待检测预测码率间的差值,进一步精确码率上限提升或降低的触发条件。
本公开所述方案,通过设置提升次数阈值和降低次数阈值,限制所述码率上限的升高或降低次数,或通过范围值,使所述码率上限的具体数值保持在适当区间,避免在对所述码率上限的自适应调整过程中,码率上限的无限制上升或下降。
在一个可选的实施例中,在所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,还包括:
响应于当前扫描行数大于第二行数阈值,根据当前扫描行对应的衰减因子,对当前的码率范围上限进行调整,所述衰减因子用于控制所述码率上限收敛至设定目标码率;
所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
可选的,在扫描压缩的最后阶段,通过逐渐将所述码率上限收敛至设定目标码率,以约束整个图像压缩过程中的最终压缩码率。所述衰减因子用于控制所述码率上限收敛至设定目标码率。所述第二行数阈值表示图像扫描压缩过程中的衰减起点,若所述码率上限在所述衰减起点前经过了自适应调整阶段,则在所述衰减起点将所述码率上限重置为初始上限,例如第一行数阈值的下一扫描行对应的码率上限。
在一个示例中,所述方法还包括:
根据当前扫描行数和所述第二行数阈值,确定所述衰减因子。
可选的,可以通过公式(4)确定所述衰减因子:
decay=pow(a,h-h
st) (4)
其中,decay表示所述衰减因子,h表示当前扫描行的行数,h
st表示第二行数阈值,即衰减起始行的行数。因此,所述衰减因子可以通过以a为底,以经过衰减起点后的累计行数为幂的指数函数表示。其中,a<1,以使衰减因子随 着行数的增加逐渐趋近于0,使得码率上限随着行数的增加逐渐逼近于所述设定目标码率。在一个示例中,a=0.989。
本公开所述方案,通过将衰减因子作为码率上限偏移量系数,逐渐将所述码率上限收敛至设定目标码率,以约束整个图像压缩过程中的最终压缩码率。
在一个可选的实施例中,所述根据当前扫描行数和所述第二设定阈值,确定所述衰减因子,包括:
获取所述当前扫描行数和所述衰减因子的对应关系;
根据所述当前扫描行数和所述对应关系,获取所述衰减因子。
可选的,为了便于硬件实现,可以通过查表获取每一扫描行对应的衰减因子。如果表过大难以获取,可以通过设定步长进行跳点采样,而在步长范围内的点,则可以通过查表值临近的两个查表结果通过先行差值计算得到。
本公开所述方案,通过获取扫描行数和所述衰减因子的对应关系,直接通过查表获取每一扫描行对应的衰减因子,以进一步减小设备的运算压力。
在一个可选的实施例中,所述方法还包括:
在当前图像的总行数大于第三行数阈值的情况下,根据所述总行数和第一比例系数,得到所述第二行数阈值;
在图像的总行数小于第三行数阈值且大于第四行数阈值的情况下,将所述总行数减去第一预设行数值,得到所述第二行数阈值;
在图像的总行数小于第四行数阈值的情况下,将第二预设行数值确定为所述第二行数阈值。
图3公开了本公开根据一示例性实施例示出的一种第二行数阈值确定流程图,其中,H表示所述图像的总行数,h
st表示所述第二行数阈值。
如图3所示,通常,在所述图像总行数H大于1500的情况下,将所述总行数的3/4确定为所述第二行数阈值;
在所述图像总行数在1500行至375行之间的情况下,将所述图像的倒数第375行确定为所述第二行数阈值;
在所述图像总行数小于375行的情况下,将所述图像总行数的第十行确定为所述第二行数阈值。进一步的,为了避免在扫描结束时所述码率上限仍无法收敛至设定目标码率,可以在图像的倒数第十行判断基于当前的衰减因子能否完成所述码率上限的收敛,若不能,则将所述衰减因子设置为0,直接将所述设定目标码率确定为所述码率上限,以及时完成对图像的压缩码率的收敛。
本公开所述方案,通过根据所述图像的总行数确定所述第二行数阈值,控制所述扫描压缩过程在适当的收敛起点进行码率上限的收敛,以约束整个图像压缩过程中的最终压缩码率。
图4示出了本公开根据一示例性实施例示出的一种图像压缩效果对照图。
图4以是否通过本公开所述方法对bayer图像进行压缩为例,能够体现是否采取本公开所述方案进行图像压缩的前后对比效果。其中,x轴为扫描行数索引,y轴为每一扫描行对应的实际码率。
可见,基于本公开所述方案,能过明显降低图像压缩过程中的码率震荡,并使实际码率更快地收敛到目标码率。
此外,由于本公开所述方案不依赖于图像内容本身,只依赖于码率历史信息的变化规律,所以不同类型不同尺寸的图像均可以达到码率控制的效果。
进一步的,通过根据最近部分扫描行的码率变化趋势自适应调整码率范围,以使压缩过程中,在复杂纹理区域分配更多的码流长度,在简单纹理区域分配更多的码流长度,减少编码过程中的码率震荡,从而实现重建图像画质的均匀过度,使得图像画质得到有效控制。
对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本公开并不受所描述的动作顺序的限制,因为依据本公开,某些步骤可以采用其他顺序或者同时进行。
其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本公开所必须的。
与前述应用功能实现方法实施例相对应,本公开还提供了应用功能实现 装置及相应的终端的实施例。
本公开一示例性实施例示出的一种图像压缩的装置框图如图5所示,所述装置包括:
401,参数获取模块:用于获取当前扫描行的压缩参数和码流长度,以及首行至所述当前扫描行的码流总长度;
402,码率预测模块:用于根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,所述预测码率表征基于当前扫描行对应的压缩参数对下一个扫描行至图像最后扫描行压缩后,所述图像的最终码率;
403,参数确定模块:用于根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数;
404,压缩模块:用于根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
在所述当前扫描行的预测码率大于码率上限的情况下,提升所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数;和/或,
在所述当前扫描行的预测码率小于码率下限的情况下,降低所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
响应于当前扫描行数大于第一行数阈值,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码 率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,所述装置还包括范围调整模块,用于:
响应于当前扫描行数大于所述第一行数阈值且小于等于第二行数阈值,根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围上限进行调整;
所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述参数确定模块在根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围上限进行调整过程中,具体用于:
根据预设规则,在所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率中,选取待检测预测码率;
在所述待检测预测码率依次递增的情况下,提升所述码率上限;
在所述待检测预测码率依次递减的情况下,降低所述码率上限。
结合本公开的任一实施方式,所述装置还包括范围限制模块,用于:
在所述码率上限的提升次数超过提升次数阈值的情况下,停止提升所述码率上限,在所述码率上限的降低次数超过降低次数阈值的情况下,停止降低所述码率上限,或;
在提升后的码率上限超出提升范围阈值的情况下,停止提升当次码率上限;
在降低后的码率上限超出降低范围阈值的情况下,停止降低当次码率上限。
结合本公开的任一实施方式,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
响应于当前扫描行数大于第二行数阈值,根据当前扫描行对应的衰减因子, 对当前的码率范围上限进行调整,所述衰减因子用于控制所述码率上限收敛至设定目标码率;
所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:
根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
结合本公开的任一实施方式,所述装置还包括第二行数阈值确定模块,用于:
在当前图像的总行数大于第三行数阈值的情况下,根据所述总行数和第一比例系数,得到所述第二行数阈值;
在图像的总行数小于第三行数阈值且大于第四行数阈值的情况下,将所述总行数减去第一预设行数值,得到所述第二行数阈值;
在图像的总行数小于第四行数阈值的情况下,将第二预设行数值确定为所述第二行数阈值。
结合本公开的任一实施方式,所述装置还包括衰减因子确定模块,用于:
根据当前扫描行数和所述第二行数阈值,确定所述衰减因子。
结合本公开的任一实施方式,所述衰减因子确定模块在根据当前扫描行数和所述第二行数阈值,确定所述衰减因子过程中,具体用于:
获取所述当前扫描行数和所述衰减因子的对应关系;
根据所述当前扫描行数和所述对应关系,获取所述衰减因子。
结合本公开的任一实施方式,所述装置还包括范围确定模块,用于:
响应于当前扫描行为所述第一行数阈值对应行的下一行,根据设定目标码率和设定范围系数,确定所述码率范围。
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作 为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本公开方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
图6示出了本公开根据一示例性实施例示出的一种电子设备框图。
请参照附图6,其示例性的示出了一种电子设备的框图。例如,装置600可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。
参照图6,装置600可以包括以下一个或多个组件:处理组件602,存储器604,电源组件606,多媒体组件608,音频组件610,输入/输出(I/O)的接口612,传感器组件614,以及通信部件616。
处理组件602通常控制装置600的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理部件602可以包括一个或多个处理器620来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件602可以包括一个或多个模块,便于处理组件602和其他组件之间的交互。例如,处理部件602可以包括多媒体模块,以方便多媒体组件608和处理组件602之间的交互。
存储器604被配置为存储各种类型的数据以支持在设备600的操作。这些数据的示例包括用于在装置600上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器604可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
电力组件606为装置600的各种组件提供电力。电力组件606可以包括电源管理***,一个或多个电源,及其他与为装置600生成、管理和分配电力相 关联的组件。
多媒体组件608包括在所述装置600和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件608包括一个前置摄像头和/或后置摄像头。当装置600处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜***或具有焦距和光学变焦能力。
音频组件610被配置为输出和/或输入音频信号。例如,音频组件610包括一个麦克风(MIC),当装置600处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器604或经由通信部件616发送。在一些实施例中,音频组件610包括一个扬声器,用于输出音频信号。
I/O接口612为处理组件602和***接口模块之间提供接口,上述***接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。
传感器组件614包括一个或多个传感器,用于为装置600提供各个方面的状态评估。例如,传感器组件614可以检测到装置600的打开/关闭状态,组件的相对定位,例如所述组件为装置600的显示器和小键盘,传感器组件614可以检测装置600或装置600一个组件的位置改变,用户与装置600接触的存在或不存在,装置600方位或加速/减速和装置600的温度变化。传感器组件614可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件614可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件614可以包括加速度传感器, 陀螺仪传感器,磁传感器,压力传感器或温度传感器。
通信部件616被配置为便于装置600和其他设备之间有线或无线方式的通信。装置600可以接入基于通信标准的无线网络,如WiFi,2G或3G,4G或5G或它们的组合。在一个示例性实施例中,通信部件616经由广播信道接收来自外部广播管理***的广播信号或广播相关信息。在一个示例性实施例中,所述通信部件616包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。
在示例性实施例中,装置600可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述电子设备的供电方法。
本公开在示例性实施例中,提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器604,上述指令可由装置600的处理器620执行以完成上述电子设备的供电方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
本公开还提供一种芯片,具体包括一个或多个接口电路和一个或多个处理器,所述接口电路用于从电子设备的存储器接收信号,并向所述处理器发送所述信号,所述信号包括存储器中存储的计算机指令。当所述处理器执行所述计算机指令时,使得所述电子设备执行本公开任一项所述的图像压缩方法。其中,所述芯片可以为常规的CPU(central processing unit,中央处理器)芯片、GPU(graphics processing unit,图形处理器)芯片等,也可以为人工智能技术专用的加速芯片,例如AI(Artificial Intelligence,人工智能)加速器等。
本领域技术人员在考虑说明书及实践这里公开的公开后,将容易想到本公开的其它实施方案。本申请旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。
Claims (25)
- 一种图像压缩方法,其特征在于,所述方法包括:获取当前扫描行的压缩参数和码流长度,以及首行至所述当前扫描行的码流总长度;根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,所述预测码率表征基于当前扫描行对应的压缩参数对下一个扫描行至图像最后扫描行压缩后,所述图像的最终码率;根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数;根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。
- 根据权利要求1所述的方法,其特征在于,所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:在所述当前扫描行的预测码率大于码率上限的情况下,提升所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数;和/或,在所述当前扫描行的预测码率小于码率下限的情况下,降低所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数。
- 根据权利要求1所述的方法,其特征在于,所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:响应于当前扫描行数大于第一行数阈值,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
- 根据权利要求3所述的方法,其特征在于,在所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,还 包括:响应于当前扫描行数大于所述第一行数阈值且小于等于第二行数阈值,根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整;所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
- 根据权利要求4所述的方法,其特征在于,所述根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整,包括:根据预设规则,在所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率中,选取待检测预测码率;在所述待检测预测码率依次递增的情况下,提升所述码率上限;在所述待检测预测码率依次递减的情况下,降低所述码率上限。
- 根据权利要求5所述的方法,其特征在于,所述方法还包括:在所述码率上限的提升次数超过提升次数阈值的情况下,停止提升所述码率上限,在所述码率上限的降低次数超过降低次数阈值的情况下,停止降低所述码率上限,或;在提升后的码率上限超出提升范围阈值的情况下,停止提升当次码率上限;在降低后的码率上限超出降低范围阈值的情况下,停止降低当次码率上限。
- 根据权利要求3所述的方法,其特征在于,在所述根据所述预测码率、 码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,还包括:响应于当前扫描行数大于第二行数阈值,根据当前扫描行对应的衰减因子,对当前的码率范围的上限进行调整,所述衰减因子用于控制所述码率上限收敛至设定目标码率;所述根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数,包括:根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
- 根据权利要求7所述的方法,其特征在于,所述方法还包括:根据当前扫描行数和所述第二行数阈值,确定所述衰减因子。
- 根据权利要求7所述的方法,其特征在于,所述根据当前扫描行数和所述第二设定阈值,确定所述衰减因子,包括:获取所述当前扫描行数和所述衰减因子的对应关系;根据所述当前扫描行数和所述对应关系,获取所述衰减因子。
- 根据权利要求7所述的方法,其特征在于,所述方法还包括:在当前图像的总行数大于第三行数阈值的情况下,根据所述总行数和第一比例系数,得到所述第二行数阈值;在图像的总行数小于第三行数阈值且大于第四行数阈值的情况下,将所述总行数减去第一预设行数值,得到所述第二行数阈值;在图像的总行数小于第四行数阈值的情况下,将第二预设行数值确定为所述第二行数阈值。
- 根据权利要求3-10中任一项所述的方法,其特征在于,所述方法还 包括:响应于当前扫描行为所述第一行数阈值对应行的下一行,根据设定目标码率和设定范围系数,确定所述码率范围。
- 一种图像压缩装置,其特征在于,所述装置包括:参数获取模块:用于获取当前扫描行的压缩参数和码流长度,以及首行至所述当前扫描行的码流总长度;码率预测模块:用于根据当前扫描行的码流长度和首行至所述当前扫描行的码流总长度,确定当前扫描行的预测码率,所述预测码率表征基于当前扫描行对应的压缩参数对下一个扫描行至图像最后扫描行压缩后,所述图像的最终码率;参数确定模块:用于根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数;压缩模块:用于根据所述下一个扫描行的压缩参数,对下一个扫描行的像素数据进行压缩处理。
- 根据权利要求12所述的装置,其特征在于,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:在所述当前扫描行的预测码率大于码率上限的情况下,提升所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数;和/或,在所述当前扫描行的预测码率小于码率下限的情况下,降低所述当前扫描行的压缩参数,得到下一个扫描行的压缩参数。
- 根据权利要求12所述的装置,其特征在于,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:响应于当前扫描行数大于第一行数阈值,根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
- 根据权利要求14所述的装置,其特征在于,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数之前,所述装置还包括范围调整模块,用于:响应于当前扫描行数大于所述第一行数阈值且小于等于第二行数阈值,根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整;所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
- 根据权利要求15所述的装置,其特征在于,所述参数确定模块在根据所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率,对当前的码率范围的上限进行调整过程中,具体用于:根据预设规则,在所述当前扫描行之前的至少两个扫描行的预测码率和所述当前扫描行的预测码率中,选取待检测预测码率;在所述待检测预测码率依次递增的情况下,提升所述码率上限;在所述待检测预测码率依次递减的情况下,降低所述码率上限。
- 根据权利要求16所述的装置,其特征在于,所述装置还包括范围限制模块,用于:在所述码率上限的提升次数超过提升次数阈值的情况下,停止提升所述码率上限,在所述码率上限的降低次数超过降低次数阈值的情况下,停止降低所述码率上限,或;在提升后的码率上限超出提升范围阈值的情况下,停止提升当次码率上限;在降低后的码率上限超出降低范围阈值的情况下,停止降低当次码率上限。
- 根据权利要求12所述的装置,其特征在于,所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:响应于当前扫描行数大于第二行数阈值,根据当前扫描行对应的衰减因子,对当前的码率范围的上限进行调整,所述衰减因子用于控制所述码率上限收敛至设定目标码率;所述参数确定模块在根据所述预测码率、码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数过程中,具体用于:根据所述预测码率、调整后的码率范围和当前扫描行的压缩参数,确定下一个扫描行的压缩参数。
- 根据权利要求18所述的装置,其特征在于,所述装置还包括衰减因子确定模块,用于:根据当前扫描行数和所述第二行数阈值,确定所述衰减因子。
- 根据权利要求18所述的装置,其特征在于,所述衰减因子确定模块在根据当前扫描行数和所述第二行数阈值,确定所述衰减因子过程中,具体用于:获取所述当前扫描行数和所述衰减因子的对应关系;根据所述当前扫描行数和所述对应关系,获取所述衰减因子。
- 根据权利要求18所述的装置,其特征在于,所述装置还包括第二行 数阈值确定模块,用于:在当前图像的总行数大于第三行数阈值的情况下,根据所述总行数和第一比例系数,得到所述第二行数阈值;在图像的总行数小于第三行数阈值且大于第四行数阈值的情况下,将所述总行数减去第一预设行数值,得到所述第二行数阈值;在图像的总行数小于第四行数阈值的情况下,将第二预设行数值确定为所述第二行数阈值。
- 根据权利要求14~21中任一项所述的装置,其特征在于,所述装置还包括范围确定模块,用于:响应于当前扫描行为所述第一行数阈值对应行的下一行,根据设定目标码率和设定范围系数,确定所述码率范围。
- 一种电子设备,其特征在于,所述电子设备包括:存储器,用于存储处理器可执行指令;处理器,被配置为执行所述存储器中的可执行指令以实现权利要求1~11任一项所述方法的步骤。
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现权利要求1~11任一项所述的方法的步骤。
- 一种芯片,其特征在于,包括:一个或多个接口电路和一个或多个处理器;所述接口电路用于从电子设备的存储器接收信号,并向所述处理器发送所述信号,所述信号包括存储器中存储的计算机指令;当所述处理器执行所述计算机指令时,使得所述电子设备执行权利要求1~11任一项所述的图像压缩方法。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2022/096492 WO2023230933A1 (zh) | 2022-05-31 | 2022-05-31 | 图像压缩方法、装置、电子设备、芯片及储存介质 |
CN202280004643.6A CN116438794B (zh) | 2022-05-31 | 2022-05-31 | 图像压缩方法、装置、电子设备、芯片及储存介质 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2022/096492 WO2023230933A1 (zh) | 2022-05-31 | 2022-05-31 | 图像压缩方法、装置、电子设备、芯片及储存介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023230933A1 true WO2023230933A1 (zh) | 2023-12-07 |
Family
ID=87083713
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/096492 WO2023230933A1 (zh) | 2022-05-31 | 2022-05-31 | 图像压缩方法、装置、电子设备、芯片及储存介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN116438794B (zh) |
WO (1) | WO2023230933A1 (zh) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070133678A1 (en) * | 2005-12-13 | 2007-06-14 | Ryuji Sakai | Information processing apparatus, control method and program |
US20080063293A1 (en) * | 2006-09-08 | 2008-03-13 | Eastman Kodak Company | Method for controlling the amount of compressed data |
CN101159871A (zh) * | 2007-11-12 | 2008-04-09 | 中兴通讯股份有限公司 | 宏块组级视频码率控制方法 |
CN102938838A (zh) * | 2012-10-19 | 2013-02-20 | 西安电子科技大学 | 基于jpeg-ls标准的动态码率控制方法 |
CN106658006A (zh) * | 2017-01-12 | 2017-05-10 | 武汉轻工大学 | 一种率失真性能近似最优的jpeg‑ls图像近无损压缩的码率控制方法 |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO1998053613A1 (en) * | 1997-05-20 | 1998-11-26 | Motorola Inc. | Apparatus, method and computer readable medium for scalable coding of video information |
JPH1118083A (ja) * | 1997-06-25 | 1999-01-22 | Sony Corp | ディジタル信号符号化方法及び装置、信号記録媒体並びに信号伝送方法 |
CA2521467C (en) * | 2003-04-04 | 2008-12-16 | Avid Technology, Inc. | Fixed bit rate, intraframe compression and decompression of video |
JP4063205B2 (ja) * | 2003-11-20 | 2008-03-19 | セイコーエプソン株式会社 | 画像データ圧縮装置及びエンコーダ |
US7844097B2 (en) * | 2007-12-03 | 2010-11-30 | Samplify Systems, Inc. | Compression and decompression of computed tomography data |
CN103297775B (zh) * | 2013-05-17 | 2016-02-10 | 西安电子科技大学 | 基于联合码率分配和控制的多光谱图像压缩***与方法 |
CN103916675B (zh) * | 2014-03-25 | 2017-06-20 | 北京工商大学 | 一种基于条带划分的低延迟帧内编码方法 |
CN105205521B (zh) * | 2015-09-30 | 2018-09-14 | 立德高科(昆山)数码科技有限责任公司 | 将二维码扫描区域中扫描线更改为选定素材的方法及装置 |
CN109379598B (zh) * | 2018-09-12 | 2021-11-19 | 合肥埃科光电科技有限公司 | 一种基于fpga实现的图像无损压缩方法 |
CN113670608B (zh) * | 2021-07-21 | 2022-09-16 | 广州大学 | 基于后缀树和向量机的故障检测方法、***、装置及介质 |
CN114051144A (zh) * | 2021-11-09 | 2022-02-15 | 京东科技信息技术有限公司 | 视频的压缩方法、装置、计算机设备及存储介质 |
CN114357665B (zh) * | 2022-03-15 | 2022-05-20 | 成都中科翼能科技有限公司 | 一种压气机叶片振动限制值的确定方法 |
-
2022
- 2022-05-31 WO PCT/CN2022/096492 patent/WO2023230933A1/zh unknown
- 2022-05-31 CN CN202280004643.6A patent/CN116438794B/zh active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070133678A1 (en) * | 2005-12-13 | 2007-06-14 | Ryuji Sakai | Information processing apparatus, control method and program |
US20080063293A1 (en) * | 2006-09-08 | 2008-03-13 | Eastman Kodak Company | Method for controlling the amount of compressed data |
CN101159871A (zh) * | 2007-11-12 | 2008-04-09 | 中兴通讯股份有限公司 | 宏块组级视频码率控制方法 |
CN102938838A (zh) * | 2012-10-19 | 2013-02-20 | 西安电子科技大学 | 基于jpeg-ls标准的动态码率控制方法 |
CN106658006A (zh) * | 2017-01-12 | 2017-05-10 | 武汉轻工大学 | 一种率失真性能近似最优的jpeg‑ls图像近无损压缩的码率控制方法 |
Also Published As
Publication number | Publication date |
---|---|
CN116438794A (zh) | 2023-07-14 |
CN116438794B (zh) | 2023-12-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10511772B2 (en) | Image capturing device having continuous image capture | |
US11606564B2 (en) | Video encoding code rate control method, apparatus, and device, and storage medium | |
EP3171596B1 (en) | Image compression with adaptive quantization of regions of interest (roi) | |
CN107230182B (zh) | 一种图像的处理方法、装置以及存储介质 | |
US11061202B2 (en) | Methods and devices for adjusting lens position | |
CN106412702B (zh) | 一种视频片段的截取方法和装置 | |
US10277829B1 (en) | Video capture in low-light conditions | |
EP3173923A1 (en) | Method and device for image display | |
JP7166171B2 (ja) | インタフェース画像の表示方法、装置及びプログラム | |
KR20100102186A (ko) | 뎁스 맵 생성을 이용하는 방법 및 장치 | |
EP4007289A1 (en) | Video uploading method and apparatus, electronic device, and storage medium | |
CN111381746B (zh) | 参数调节方法、装置及存储介质 | |
CN109547782B (zh) | Mpm候选列表构建方法、装置、电子设备及存储介质 | |
US9678868B2 (en) | Method and device for optimizing memory | |
US20220415236A1 (en) | Display control method, display control device and storage medium | |
CN115052150A (zh) | 视频编码方法、装置、电子设备和存储介质 | |
WO2023230933A1 (zh) | 图像压缩方法、装置、电子设备、芯片及储存介质 | |
CN105472228B (zh) | 图像处理方法、装置及终端 | |
CN114595785A (zh) | 模型训练方法、装置、电子设备及存储介质 | |
WO2024045967A1 (zh) | 模型调整方法、装置、显示装置和存储介质 | |
CN115469816A (zh) | 存储器的读写切换方法、装置、设备及存储介质 | |
US10979628B2 (en) | Image processing apparatus, image processing system, image processing method, and recording medium | |
EP3575996A1 (en) | Terminal device, sensing method and apparatus | |
KR20080107652A (ko) | 휴대용 단말기의 카메라 기능 수행 방법 | |
CN116634532A (zh) | 终端功耗控制方法、装置和存储介质 |
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: 22944267 Country of ref document: EP Kind code of ref document: A1 |