An image data compression method and system based on artificial intelligence
By converting the image data to CIE-xyY color space and using the Gaussian fitting and color trend of the autoencoding neural network to construct a loss function, the problem of difficulty in lossless compression of image data is solved and efficient lossless compression is achieved.
Patent Information
- Application Number
- CN202111471673.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-12-06
AI Technical Summary
Lossless compression of image data in the existing technology is difficult, resulting in high network construction costs and affecting compression efficiency. It is also difficult for self-encoding neural networks to achieve complete lossless compression during the image compression process.
By converting image data to CIE-xyY color space, using autoencoding neural network for compression, using Gaussian fitting and color trend to construct a loss function, and combining the first color difference and the second color difference, lossless compression of the image is achieved.
It achieves lossless compression within color tolerance, ensures the color quality of compressed images, reduces network construction costs, and improves compression efficiency.
Smart Images

Figure CN114170331B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an image data compression method and system based on artificial intelligence. Background Art
[0002] A common data compression method is to perform a relatively complex inverse operation on the image to achieve lossless compression. The inverse operation is relatively complex and difficult to operate on different types of image data. With the continuous development of the field of artificial intelligence, the existing technology can use artificial intelligence to build a network to adaptively and quickly compress image data. Common networks include autoencoder neural networks, etc.
[0003] When compressing image data using the network, it is hoped to achieve lossless compression of the image, that is, the color information in the image remains unchanged before and after compression. For image data, achieving completely lossless compression is relatively complex and difficult, which will increase the cost of network construction and affect compression efficiency. Summary of the invention
[0004] In order to solve the above technical problems, the purpose of the present invention is to provide an image data compression method and system based on artificial intelligence. The technical solutions adopted are as follows:
[0005] The present invention proposes an image data compression method based on artificial intelligence, the method comprising:
[0006] Acquire multiple training images; convert the training images into CIE-xyY color space to obtain two-dimensional color information;
[0007] The two-dimensional color information is used as training data for an autoencoder neural network; the output of the autoencoder neural network is compressed color information; Gaussian fitting is performed based on the two-dimensional standard deviation of the two-dimensional color information of each pixel in the training image at a preset order to obtain a Gaussian model for each pixel; boundary two-dimensional color information of the two-dimensional color information is obtained based on the two-dimensional standard deviation; color tendency is obtained based on the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model; the difference between the two-dimensional color information of the pixel and other pixels within a preset neighborhood is used as a first color difference; the difference between the compressed color information of the pixel and other pixels within the neighborhood is used as a second color difference; a loss function of the autoencoder neural network is constructed based on the difference between the first color difference and the second color difference and the color tendency; and the autoencoder neural network is trained based on the loss function and the training data;
[0008] The two-dimensional color information of the image to be compressed is input into the autoencoder neural network, and image compression data is output.
[0009] Furthermore, the preset order is set to three orders.
[0010] Furthermore, performing Gaussian fitting based on the two-dimensional standard deviation of the two-dimensional color information of each pixel in the training image at a preset order includes:
[0011] The Gaussian model is obtained by performing Gaussian fitting with the two-dimensional color information of the pixel as the center and the two-dimensional standard deviation as the model mean.
[0012] Furthermore, the obtaining of the boundary two-dimensional color information of the two-dimensional color information according to the two-dimensional standard deviation includes:
[0013] The boundary two-dimensional color information includes negative boundary two-dimensional color information and positive boundary two-dimensional color information; the two-dimensional color information is subtracted from the two-dimensional standard deviation to obtain the negative boundary two-dimensional color information; the two-dimensional color information is added to the standard deviation to obtain the positive boundary two-dimensional color information.
[0014] Further, obtaining the color tendency according to the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model includes:
[0015] The color tendency is obtained according to a color tendency formula; the color tendency formula includes:
[0016]
[0017] Among them, qx i is the color tendency of the i-th pixel, G i (y i ') is the model value of the compressed color information of the i-th pixel on the Gaussian model, (X i , Y i ) is the two-dimensional color information of the i-th pixel, is the two-dimensional standard deviation of the i-th pixel, is the model value of the boundary two-dimensional color information of the i-th pixel on the Gaussian model.
[0018] Furthermore, the loss function of the autoencoder neural network constructed according to the difference between the first color difference and the second color difference and the color tendency includes:
[0019] The loss function includes:
[0020]
[0021] Wherein, loss is the loss function, I is the total number of pixels, qx iis the color tendency of the i-th pixel, S is the neighborhood range, y i is the two-dimensional color information of the i-th pixel, m j is the two-dimensional color information of the jth pixel in the neighborhood, E(y i ,m j ) is the first color difference, y′ i is the compressed color information of the i-th pixel, m′ j is the compressed color information of the jth pixel in the neighborhood, E(y′ i ,m′ j ) is the second color difference.
[0022] Furthermore, the step of inputting the two-dimensional color information of the image to be compressed into the autoencoder neural network and outputting the image compression data further comprises:
[0023] The grayscale information of the image to be compressed is obtained, the grayscale information of the image to be compressed and the two-dimensional color information are input into the autoencoder neural network, and composite image compression data is output; the composite image compression data includes the image compression data and the grayscale information.
[0024] Furthermore, the outputting of the composite image compressed data further includes:
[0025] The composite image compression data is decoded to obtain color information and the grayscale information; the grayscale information is replaced with the brightness component information in the color information to obtain a restored image.
[0026] The present invention also proposes an artificial intelligence-based image data compression system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the steps of the artificial intelligence-based image data compression method when executing the computer program.
[0027] The present invention has the following beneficial effects:
[0028] The embodiment of the present invention analyzes the two-dimensional color information of the image, and obtains the boundary two-dimensional color information according to the two-dimensional standard deviation of the two-dimensional color information. The purpose of obtaining the two-dimensional standard deviation is to obtain the MacAdam ellipse of the two-dimensional color information, and the boundary two-dimensional color information is the boundary of the MacAdam ellipse. The color tendency is further obtained, and the color tendency is used as a part of the loss function, so that the compressed color information can be within the boundary color information, that is, within the MacAdam ellipse, without causing color difference values that can be perceived by the human eye, thereby achieving lossless compression. The color difference relationship between the pixel point and the surrounding pixel points is further analyzed through the first color difference and the second color difference, and the difference between the first color difference and the second color difference is used as a part of the loss function, so that the contrast between a pixel point and the surrounding pixel points in the compressed color information can be close to the contrast before compression, thereby ensuring the quality of the compressed color information. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 A flow chart of an image data compression method based on artificial intelligence provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the image data compression method and system based on artificial intelligence proposed by the present invention, its specific implementation, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures, or characteristics in one or more embodiments may be combined in any suitable form.
[0032] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0033] The following is a detailed description of a specific solution of an image data compression method and system based on artificial intelligence provided by the present invention in conjunction with the accompanying drawings.
[0034] See also Figure 1 , which shows a flow chart of an image data compression method based on artificial intelligence provided by an embodiment of the present invention, the method comprising:
[0035] Step S1: Acquire multiple training images; convert the training images into CIExyY color space to obtain two-dimensional color information.
[0036] The common color measurement model of image data is generally the RGB model, that is, the color of the image is expressed according to the channel values in the three channels of R, G, and B. However, the RGB color model is a device-related color space. Each device has a different definition when using the RGB model, so the color effect presented will be different. Therefore, the definition of RGB between devices is not universal. Therefore, in image data compression, directly compressing the RGB color information will cause the color effect difference presented by the compressed color information in different devices to be more obvious. Therefore, multiple training images are converted to the CIE-xyY color space. The CIE-xyY color space is an imaginary primary color system related to RGB, which defines a standard light source and is more suitable for color calculation. It should be noted that the CIE-xyY color space is converted from CIE-xyz, that is, the RGB color model is first converted to the CIE-xyz color space, and then converted from the CIE-xyz color space to the CIE-xyY color space. The conversion relationship is a well-known technology and will not be explained here. Finally, the two-dimensional color information y of the training image in the CIE-xyY color space is obtained. i =[X i ,Y i ], where i represents the i-th pixel in the training image.
[0037] Step S2: using two-dimensional color information as training data for an autoencoder neural network; the output of the autoencoder neural network is compressed color information; performing Gaussian fitting based on the two-dimensional standard deviation of the two-dimensional color information of each pixel in the training image at a preset order to obtain a Gaussian model for each pixel; obtaining boundary two-dimensional color information of the two-dimensional color information based on the two-dimensional standard deviation; obtaining color tendency based on the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model; using the difference in two-dimensional color information between a pixel point and other pixels within a preset neighborhood as a first color difference; using the difference in compressed color information between a pixel point and other pixels within a neighborhood as a second color difference; constructing a loss function for the autoencoder neural network based on the difference between the first color difference and the second color difference and the color tendency; and training the autoencoder neural network based on the loss function and the training data.
[0038] The two-dimensional color information of the training image is used as the training data of the autoencoder neural network. Since each pixel includes a two-dimensional color information, the input data volume of the autoencoder neural network is twice the image size. In the embodiment of the present invention, the autoencoder neural network adopts a fully connected network structure to expand the two-dimensional color information of the image to form a one-dimensional input data and output the compressed color information y i', where i represents the i-th pixel in the training image. It should be noted that the autoencoder neural network for image data compression is a well-known technology in the art, and the image data compression related methods in the autoencoder neural network are not described here.
[0039] When common autoencoder neural networks are compressing images, in order to ensure lossless compression of image color information, various complex processing methods are used to retain more color information. However, because the autoencoder neural network is essentially a fitter, it cannot achieve 100% consistency in the color information of all pixels before and after image compression, and using too many processing methods will increase the number of network iterations, consume resources excessively, and increase the cost of the compression task. It should be noted that the change of image color information has color tolerance, that is, the human eye cannot distinguish the color change within the color tolerance. Therefore, when the autoencoder neural network is used for image compression, the fitting requirements can be relaxed so that the color information before and after compression changes within the color tolerance. It can be considered that the image color has not changed, and lossless compression of the image is achieved.
[0040] The MacAdam ellipse is a closed shape formed in the process of analyzing the color difference between a pixel and the pixel in different directions. The standard deviation of the color information of the pixel represented by the MacAdam ellipse and other pixels represents the resolution of the color quality, that is, the first-order MacAdam ellipse refers to the standard deviation of the difference in color matching results at a distance of one times the color information of the target pixel, and the other orders are the same as the first order. The color information of the pixels within the first-order MacAdam ellipse and the second-order MacAdam ellipse cannot be distinguished by the human eye, so the pixels within the first-order MacAdam ellipse and the second-order MacAdam ellipse can be considered to be the same color. The color corresponding to the boundary of the third-order MacAdam ellipse is noticeably different from the center point, so the third-order MacAdam ellipse can be used as the boundary, that is, the preset order is set to the third order, and the two-dimensional color information [X i ,Y i ] Analyze on.
[0041] Because the ellipse equation is relatively complex, the calculation amount is complex to use the ellipse equation to analyze whether the compressed color information is within the range of the third-order MacAdam ellipse. Because the distance distribution between the pixel point and the center of the MacAdam ellipse is approximately Gaussian, the position of the compressed color information can be analyzed in the Gaussian distribution model. The Gaussian model of each pixel obtained by Gaussian fitting based on the two-dimensional standard deviation specifically includes:
[0042] The Gaussian model is obtained by taking the two-dimensional color information of the pixel as the center and the two-dimensional standard deviation as the model mean for Gaussian fitting.
[0043] Because the compressed color information needs to be within the third-order MacAdam ellipse and not on the ellipse boundary, it is necessary to obtain the boundaries of the MacAdam ellipse. The boundaries of the two-dimensional color information can be obtained based on the two-dimensional standard deviation, including:
[0044] The boundary two-dimensional color information includes negative boundary two-dimensional color information and positive boundary two-dimensional color information. Subtract the two-dimensional color information from the two-dimensional standard deviation to obtain the negative boundary two-dimensional color information. Add the two-dimensional color information to the standard deviation to obtain the positive boundary two-dimensional color information. That is, the boundary two-dimensional color information of the i-th pixel point is The boundary two-dimensional color information is reflected in the MacAdam ellipse as the intersection of the major axis and the minor axis of the ellipse on the boundary of the ellipse.
[0045] Because the center point of the MacAdam ellipse is two-dimensional color information, the closer the compressed color information is to the center point in the MacAdam ellipse, the better the color information. Therefore, when fitting in the autoencoder neural network, it is also necessary to ensure that the compressed color information is close to the two-dimensional color information. Therefore, only the extreme case of the boundary two-dimensional color information is analyzed, and there is no need to consider other points on the boundary of the ellipse.
[0046] When the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model is greater than zero, it can be considered that the current compressed color information is within the third-order MacAdam ellipse, and the greater the difference, the closer it is to the center point of the Gaussian model. Therefore, the color tendency qx can be obtained according to the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model. i , including:
[0047] The color tendency is obtained according to the color tendency formula. The color tendency formula includes:
[0048]
[0049] Among them, qx i is the color tendency of the i-th pixel, G i (y′ i ) is the model value of the compressed color information of the i-th pixel on the Gaussian model, (X i , Y i ) is the two-dimensional color information of the i-th pixel, is the two-dimensional standard deviation of the i-th pixel, is the model value of the boundary two-dimensional color information of the i-th pixel on the Gaussian model. In the color tendency formula, the data is corrected by the -exp() function. When the model value difference is too large, the color tendency is a number that tends to 0 to avoid being too close to the center point, increasing the number of network fittings, and wasting network resources. And through the negative correlation relationship, the smaller the color tendency, the better the quality of the compressed color information.
[0050] By constraining the network according to color tendency, the effect of compressed color information can meet the lossless state in human eyes. However, the lossless state at this time is only the state of the pixel itself before and after compression. For the main body of the image, if there is a large difference in the color information between pixels, it will still cause a large visual difference before and after image compression. Therefore, it is necessary to analyze the color information difference between the pixel and other pixels in the preset neighborhood before and after compression, including:
[0051] The difference in two-dimensional color information between a pixel point and other pixels within a preset neighborhood is used as the first color difference. The difference in compressed color information between a pixel point and other pixels within a neighborhood is used as the second color difference. The first color difference before and after compression should be similar to the second color difference, so the difference between the first color difference and the second color difference can be obtained to indicate the degree of similarity, that is, the smaller the difference, the closer the two are, and the better the compression effect. In the embodiment of the present invention, the neighborhood range is set to 8 neighborhoods.
[0052] The loss function of the autoencoder neural network is further constructed in combination with the color tendency. Since the color tendency and the difference between the first color difference and the second color difference are inversely proportional to the compression quality, the loss function includes:
[0053]
[0054] Among them, loss is the loss function, I is the total number of pixels, qx i is the color tendency of the i-th pixel, S is the neighborhood range, y i is the two-dimensional color information of the i-th pixel, m j is the two-dimensional color information of the jth pixel in the neighborhood, E(y i ,m j ) is the first color difference, y′ i is the compressed color information of the i-th pixel, m′ j is the compressed color information of the jth pixel in the neighborhood, E(y′ i ,m′ j ) is the second color difference.
[0055] The loss function can be used to analyze the loss value of each iteration of the network. The smaller the loss value, the better the compression quality. When the loss value reaches a stable and minimum value through fitting methods such as gradient descent, the network training is completed.
[0056] Step S3: Input the two-dimensional color information of the image to be compressed into the autoencoder neural network and output the image compression data.
[0057] After training the training data and the loss function, the two-dimensional color information of the image to be compressed can be directly input into the autoencoder neural network to output the image compression data. It should be noted that the loss function obtained in the embodiment of the present invention can also be combined with the loss function of other conventional image compression autoencoder neural networks for training, which can further achieve better compression effect.
[0058] Preferably, the grayscale information of the image to be compressed is obtained, the grayscale information and two-dimensional color information of the image to be compressed are input into the autoencoder neural network, and composite image compression data is output. The composite image compression data includes image compression data and grayscale information. The composite image compression data can be used for data storage and data transmission. When the composite image compression data is needed for image restoration, the composite image compression data is decoded to obtain color information and grayscale information; the grayscale information is replaced with the brightness component information in the color information to obtain a restored image. The difference in color information between the restored image and the image to be compressed cannot be observed by the human eye, that is, a lossless image visually viewed by the human eye, thereby achieving lossless compression of the image.
[0059] In summary, the embodiment of the present invention analyzes the two-dimensional color information of the training image, analyzes the boundary two-dimensional color information that reaches the boundary of the lossless effect based on the two-dimensional standard deviation of the two-dimensional color information at a preset order, and obtains the Gaussian model of each pixel based on the two-dimensional standard deviation, obtains the color tendency based on the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model, and further constructs the loss function by combining the color difference between the pixel before and after compression and other pixels in the neighborhood. The autoencoder neural network is trained using the two-dimensional color information as training data. Lossless compression is achieved through the autoencoder neural network. The embodiment of the present invention constrains the network by obtaining the boundary of color tolerance, thereby achieving lossless compression of image data using the autoencoder neural network.
[0060] The present invention also proposes an artificial intelligence-based image data compression system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the system implements any one of the steps of an artificial intelligence-based image data compression method when the processor executes the computer program.
[0061] It should be noted that the sequence of the embodiments of the present invention described above is for description only and does not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0062] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0063] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An image data compression method based on artificial intelligence, It is characterized in that The method comprises: Acquire multiple training images; convert the training images into CIE-xyY color space to obtain two-dimensional color information; The two-dimensional color information is used as training data for an autoencoder neural network; the output of the autoencoder neural network is compressed color information; Gaussian fitting is performed based on the two-dimensional standard deviation of the two-dimensional color information of each pixel in the training image at a preset order to obtain a Gaussian model for each pixel; boundary two-dimensional color information of the two-dimensional color information is obtained based on the two-dimensional standard deviation; color tendency is obtained based on the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model; the difference between the two-dimensional color information of the pixel and other pixels within a preset neighborhood is used as a first color difference; the difference between the compressed color information of the pixel and other pixels within the neighborhood is used as a second color difference; a loss function of the autoencoder neural network is constructed based on the difference between the first color difference and the second color difference and the color tendency; and the autoencoder neural network is trained based on the loss function and the training data; Inputting the two-dimensional color information of the image to be compressed into the autoencoder neural network, and outputting image compression data; The obtaining of the boundary two-dimensional color information of the two-dimensional color information according to the two-dimensional standard deviation comprises: The boundary two-dimensional color information includes negative boundary two-dimensional color information and positive boundary two-dimensional color information; subtracting the two-dimensional color information from the two-dimensional standard deviation to obtain negative boundary two-dimensional color information; adding the two-dimensional color information to the standard deviation to obtain positive boundary two-dimensional color information; The obtaining of color tendency according to the difference between the compressed color information and the boundary two-dimensional color information on the Gaussian model comprises: The color tendency is obtained according to a color tendency formula; the color tendency formula includes: Among them, qx i is the color tendency of the i-th pixel, G i (y i ') is the model value of the compressed color information of the i-th pixel on the Gaussian model, (X i , Y i ) is the two-dimensional color information of the i-th pixel, is the two-dimensional standard deviation of the i-th pixel, is the model value of the boundary two-dimensional color information of the i-th pixel point on the Gaussian model; The loss function of the autoencoder neural network constructed according to the difference between the first color difference and the second color difference and the color tendency includes: The loss function includes: Wherein, loss is the loss function, I is the total number of pixels, qx i is the color tendency of the i-th pixel, S is the neighborhood range, y i is the two-dimensional color information of the i-th pixel, m j is the two-dimensional color information of the jth pixel in the neighborhood, E(y i ,m j ) is the first color difference, y i ′ is the compressed color information of the i-th pixel, m j ′ is the compressed color information of the jth pixel in the neighborhood, E(y i ′ ,m j ′ ) is the second color difference.
2. The method for compressing image data based on artificial intelligence according to claim 1, It is characterized in that The preset order is set to three orders.
3. The method for compressing image data based on artificial intelligence according to claim 1, It is characterized in that The performing Gaussian fitting according to the two-dimensional standard deviation of the two-dimensional color information of each pixel in the training image at a preset order comprises: The Gaussian model is obtained by performing Gaussian fitting with the two-dimensional color information of the pixel as the center and the two-dimensional standard deviation as the model mean.
4. The method for compressing image data based on artificial intelligence according to claim 1, It is characterized in that The step of inputting the two-dimensional color information of the image to be compressed into the autoencoder neural network and outputting the image compression data further comprises obtaining the grayscale information of the image to be compressed, inputting the grayscale information of the image to be compressed and the two-dimensional color information into the autoencoder neural network, and outputting the composite image compression data; The composite image compression data includes the image compression data and the grayscale information.
5. The method for compressing image data based on artificial intelligence according to claim 4, It is characterized in that The output of the composite image compressed data also includes: The composite image compression data is decoded to obtain color information and the grayscale information; the grayscale information is replaced with the brightness component information in the color information to obtain a restored image.
6. An artificial intelligence-based image data compression system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
