With the development of Internet technologies and with an increase in proportion of image use on the Internet, image transmission on the Internet becomes increasingly important. Due to the limitation in bandwidth and traffic, an image needs to be compressed before being transmitted on the Internet, to facilitate transmission of the image, and therefore, it is increasingly important perform lossless compression on images to be transmitted on the Internet.
In the conventional technology, a quality factor (which is referred to as “q” for short) is generally used to indicate the quality of an image that is compressed by using the quality factor of the image. A larger value of q indicates higher quality of image compression, and in this case, the compressed image occupies relatively large space; and a smaller value of q indicates lower quality of compression, and in this case, the compressed image occupies relatively small space. For example, for a jpeg-format image generally used in the conventional technology, an empirical initial value q is usually set for the image in the conventional technology, so as to compress the jpeg-format image according to the empirical initial value q. For example, a value range of q may be 0 to 100. At the same time, a score (which is referred to s for short) value of image similarity is further introduced in the conventional technology. The value of s indicates a score of similarity, which is obtained by means of objective evaluation, between a compressed image and an original jpeg-format image after the jpeg-format image is compressed by using the value of q, and may also be interpreted as a score of the quality of a compressed jpeg-format image perceived by human eyes. For example, a value range of s may be 0 to 1. The value of s is generally in direct proportion to the value of q; a larger value of s indicates higher quality of a compressed image and higher similarity between the compressed image and an original image, and corresponds to a larger value of q and a larger compressed jpeg-format image; and a smaller value of s indicates lower quality of a compressed image and lower similarity between the compressed image and an original image, and corresponds to a smaller value of q, and a smaller compressed jpeg-format image. In the conventional technology, generally, a preset threshold is set for s. First, a jpeg-format image is compressed and encoded according to a preset empirical initial value q; then, it is analyzed whether the value of s of the compressed and encoded image is less than the preset threshold of s, and if the value of s is not less than the preset threshold of s, the value of q is reduced correspondingly, and the jpeg-format image is compressed and encoded again; then it is analyzed whether the value of s of the compressed and encoded image is less than the preset threshold of s; the process is repeated until the value of s of the compressed and encoded image is less than the preset threshold of s, and then, the compressed and encoded image is output, so as to transmit the image.
In a process of implementing the present disclosure, the inventor finds that the conventional technology at least has the following problem: a preset empirical initial value q in the conventional technology is set completely according to experience. To acquire a compressed image, iteration and corresponding compression need to be performed multiple times according to the preset empirical initial value q until the value of s is converged. Therefore, in the image compression solution in the conventional technology, an improper preset empirical initial value q leads to a long compression time and low efficiency in image compression.