A method for converting between color and grayscale images

By decomposing a color image into red, green, and blue components and performing data compression and information hiding, the visual quality problem when converting a color image to a grayscale image is solved, and efficient storage and transmission of color images are achieved.

CN116823970BActive Publication Date: 2026-05-26XIAN INSTITUE OF SPACE RADIO TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAN INSTITUE OF SPACE RADIO TECH
Filing Date
2023-06-20
Publication Date
2026-05-26

Smart Images

  • Figure CN116823970B_ABST
    Figure CN116823970B_ABST
Patent Text Reader

Abstract

This invention proposes a method for converting between color and grayscale images. It can convert a color image to a grayscale image, significantly reducing storage requirements and concealing the true color image; conversely, it can convert the grayscale image back to a color image, restoring the true color image without visual distortion. By utilizing information hiding and data compression to store and transmit color images as grayscale images, the data volume can be reduced to one-third of the original. This ensures that the image holder can recover the original color image, while others can only obtain a grayscale image and cannot recover the original color image from it.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a data transmission method, and more particularly to a method for converting between color images and grayscale images, belonging to the field of communication (such as data communication technology). Background Technology

[0002] With the development of technology, people have an increasing demand for high-resolution images and the volume of data is growing, making data compression imperative. The preprocessing of the source image used for hiding encrypted domain information has a significant impact on the system's hiding capacity and other performance characteristics.

[0003] In layman's terms, a grayscale image is a black and white image in everyday life; it contains only brightness (grayscale) information and no color information.

[0004] Compared to grayscale images, color images include not only grayscale information but also color information. In some fields, due to equipment limitations, it is necessary to convert color images to grayscale images to reduce the amount of data stored and speed up image processing. While it's desirable to store grayscale images with small data volumes, it's desirable to view them in color; therefore, converting grayscale images to color images is a very necessary conversion method.

[0005] Methods for converting color images to grayscale

[0006] Most color images use the RGB model, where each pixel is composed of different values ​​of the three primary colors: red, green, and blue. Therefore, storing color information requires three bytes to store the R, G, and B pixel values, respectively. Grayscale images, on the other hand, only require one byte per pixel. The process of converting a color image to grayscale involves using different methods to convert the R, G, and B component values ​​into a single grayscale value. There are many methods for converting color images to grayscale, and the technology is relatively mature. Different conversion methods produce different grayscale effects. However, converting a grayscale image obtained from a color image back to its original color image is impossible due to the lack of color components; both prediction and learning methods yield unsatisfactory results.

[0007] The following section introduces various conversion methods and their advantages and disadvantages.

[0008] Component method

[0009] The component method is a relatively simple and practical method among many processing methods. Its idea is to directly convert any one of the three component values, R, G, and B, into a grayscale value without any processing.

[0010] The human eye has different sensitivities to various colors. According to scientific experiments, among the three colors of red, green, and blue, green has the highest sensitivity, followed by red, and blue has the lowest sensitivity. Therefore, the following formula can be used to convert the three components of a color image into a grayscale image f(x,y): a weighted average of the RGB components can be used to obtain a grayscale image.

[0011] f(x,y)=0.30 R(x,y)+0.59 G(x,y)+0.11 B(x,y)

[0012] When converting from RGB color to grayscale, different weighting coefficients are applied to the red, green, and blue color components. These coefficients are determined by the magnitude of the influence of the color component signals on the conversion result.

[0013] When storing a color image, the amount of data is generally three times that of the corresponding grayscale image. Summary of the Invention

[0014] The technical problem solved by this invention is to overcome the shortcomings of the prior art, utilize the characteristics of data compression and information hiding to hide color information, realize the conversion of a color image into a grayscale image for storage and transmission, and be able to convert the grayscale image back into the original color image, with excellent visual quality of the color image.

[0015] The technical solution of this invention is: a method for converting between color images and grayscale images, comprising:

[0016] Size 3 M A color image A of N is divided into three images, RGB, each with a size of M. N represents the green component image G as the basic grayscale image; M and N are positive integers.

[0017] The red component image R and the blue component image B are combined into one image W. Image W is then compressed with a compression ratio of h to obtain data U.

[0018] The data U is hidden in the green component image G to obtain image G1, which is the grayscale image obtained by converting the color image A;

[0019] Store and transmit the grayscale image G1;

[0020] Receive image G1, dehide image G1 to obtain data U, decompress data U to obtain restored image W, and then obtain restored red component image R1 and restored blue component image B1;

[0021] Using the restored image R1, image G1, and restored image B1 as RGB components, the restored color image A1 is formed.

[0022] The amount of data in image G1 remains unchanged relative to the green component image G.

[0023] Combine the red component image R and the blue component image B into a single image W, including:

[0024] The red component image R and the blue component image B are combined side-by-side to form an image W, with a size of 2. M N.

[0025] Combine the red component image R and the blue component image B into a single image W, including:

[0026] Half-sampled images of the red component (R) and blue component (B) are combined to form an adjacent image (W). The size of image W is... M N.

[0027] Typical h values ​​are 4, 8, or 16.

[0028] Image W is compressed, typically using the AMBTC-based data compression method.

[0029] The step of hiding data U into the green component image G to obtain image G1 includes:

[0030] If the data size of data U is half that of G, hide data U in the lowest 4 bits of image G based on the LSB algorithm;

[0031] If the data size of data U is 1 / 4 of that of G, hide data U in the lowest 2 bits of image G based on the LSB algorithm;

[0032] If the data size of data U is 1 / 8 of that of G, hide data U in the lowest bit of image G based on the LSB algorithm.

[0033] Compared with the prior art, the present invention has the following substantial differences and advancements:

[0034] (1) This method obtains a converted grayscale image by hiding information based on the color image components. The grayscale image contains the color information of the original image. In contrast, the grayscale image obtained by the traditional conversion method does not contain the original color information.

[0035] (2) This method finds out the green image that the human visual system is sensitive to in advance as the basic grayscale image, which ensures the visual quality of the recovered image during the conversion process;

[0036] (3) This method combines image data compression and information hiding outside the basic grayscale image. Visually sensitive images are not compressed to ensure high image quality; other components are compressed and then hidden in the grayscale image, thus maintaining the subjective and objective performance of the restored image. Attached Figure Description

[0037] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation

[0038] like Figure 1 As shown, in order to verify the performance of the algorithm proposed in this paper, an 8-bit color image A with a size of 512×512 was used in the simulation experiment to perform mutual conversion between color image and grayscale image using the method of this invention.

[0039] The steps of a method for converting, compressing, and hiding the transmission of a color grayscale image are as follows:

[0040] 1) Put the size of 3 M A color image A of N is divided into three images, RGB, each with a size of M. N represents the green component image G as the basic grayscale image; M and N are positive integers.

[0041] 2) Combine the red component image R and the blue component image B into a single image W and compress it with a compression ratio of h to obtain data U;

[0042] 3) Hide the data U into the green component image G to obtain image G1. The amount of data in image G1 remains unchanged relative to G. G1 is the grayscale image obtained by converting the color image A.

[0043] 4) Store and transmit the grayscale image G1;

[0044] 5) Receive image G1, unhide image G1 to obtain data U, decompress U to obtain restored image W, and then obtain the restored red component image R1 and the restored blue component image B1;

[0045] 6) Using the restored image R1, image G1, and restored image B1 as RGB components, a color image A1 is formed.

[0046] The method for combining the red component image R and the blue component image B into a single image W involves one of the following steps: (1) adjacent image data are combined to form an image W, and the size of image W is 2. M N; (2) After half sampling of the image data, adjacent samples are combined to form an image W, and the size of image W is M. N;

[0047] Compress W with a compression ratio of h, where h is typically 4, 8, or 16.

[0048] A method for converting between color and grayscale images, which compresses W with a compression ratio of h, with a typical compression method being the AMBTC-based data compression method;

[0049] The step of hiding data U into the green component image G to obtain image G1 includes:

[0050] If the data size of data U is half that of G, hide data U in the lowest 4 bits of image G based on the LSB algorithm;

[0051] If the data size of data U is 1 / 4 of that of G, hide data U in the lowest 2 bits of image G based on the LSB algorithm;

[0052] If the data size of data U is 1 / 8 of that of G, hide data U in the lowest bit of image G based on the LSB algorithm.

[0053] Experimental results

[0054] The experiment used the MATLAB 2014a platform, and the image data consisted of a standard 512×512 color image with three components.

[0055] The red component image R and the blue component image B are combined into a grayscale image W (img AA1). W is then compressed at a fixed compression ratio h to obtain data U. The recovered grayscale image W (img AA2) is obtained by decompression.

[0056] The data U is hidden in the green image G to obtain the grayscale image G1.

[0057] The grayscale image G1 is dehidden and decompressed to obtain the three components of the color image A1.

[0058] Peak Signal-to-Noise Ratio (PSNR) is used to measure the performance of compression algorithms. For an 8-bit digital image of size H×W, PSNR is defined as follows:

[0059]

[0060] In the formula, MSE is the mean square error between the original image and the restored image, and the calculation formula is:

[0061]

[0062] here , Let i and j represent the pixel values ​​at (i, j) in the original image and the restored image, respectively.

[0063] Performance testing

[0064] When the compression ratio h = 8, the PSNR is 41dB when image W is compressed based on the JPEG2000 method.

[0065] When the compression ratio h = 8, the image W is compressed based on the AMBTC method, and the PSNR = 30 dB.

[0066] The PSNR of the green image G recovered from the grayscale image G1 is: PSNR = 51 dB;

[0067] When the compression ratio h = 4, the image W is compressed based on the JPEG2000 method, and the PSNR = 44dB.

[0068] When the compression ratio h = 4, the image W is compressed based on the AMBTC method, and the PSNR = 33 dB.

[0069] The PSNR of the green image G recovered from the grayscale image G1 is: PSNR=48dB.

[0070] This method opens up new technical avenues for the practical application of color images. By preprocessing and based on data compression and information hiding, it can achieve high-quality conversion between color and grayscale images. It achieves three times the compression of color images and hides color information while converting color to grayscale, resulting in unconventional conversion effects. At the same time, it can recover color images with high quality from grayscale images, hide the real color image during storage and transmission, and only expose the grayscale image. Moreover, the conversion is easy to implement in both hardware and software, has practical value in satellite image compression and transmission systems, and can play a role in any other image compression scenario.

Claims

1. A method for converting between color images and grayscale images, characterized in that, include: Size 3 M A color image A of N is divided into three images, RGB, each with a size of M. N, using the green component image G as the basic grayscale image; M and N are positive integers; The red component image R and the blue component image B are combined into one image W. Image W is then compressed with a compression ratio of h to obtain data U. Hide the data U in the green component image G to obtain image G1, which is the grayscale image obtained by converting the color image A; Store and transmit image G1; Receive image G1, dehide image G1 to obtain data U, decompress data U to obtain restored image W, and then obtain restored image R1 of red component and restored image B1 of blue component; Using the restored image R1, image G1, and restored image B1 as RGB components, a restored color image A1 is formed; The amount of data in image G1 remains unchanged relative to the green component image G; Combine the red component image R and the blue component image B into a single image W, including: The red component image R and the blue component image B are combined side-by-side to form an image W, with a size of 2. M N.

2. The method for converting between color images and grayscale images according to claim 1, characterized in that, Combine the red component image R and the blue component image B into a single image W, including: Half-sampled images of the red component (R) and blue component (B) are combined to form an adjacent image (W). The size of image W is... M N.

3. The method for converting between color images and grayscale images according to claim 1, characterized in that, Typical h values ​​are 4, 8, or 16.

4. The method for converting between color images and grayscale images according to claim 1, characterized in that, Image W is compressed, typically using the AMBTC-based data compression method.

5. The method for converting between color images and grayscale images according to claim 4, characterized in that, The step of hiding data U into the green component image G to obtain image G1 includes: If the data size of data U is half that of the green component image G, hide data U in the lowest 4 bits of the green component image G based on the LSB algorithm.

6. The method for converting between color images and grayscale images according to claim 4, characterized in that, The step of hiding data U into the green component image G to obtain image G1 includes: if the data size of data U is 1 / 4 of the green component image G, hiding data U into the lowest 2 bits of the green component image G based on the LSB algorithm.

7. The method for converting between color images and grayscale images according to claim 4, characterized in that, The step of hiding data U into the green component image G to obtain image G1 includes: if the data size of data U is 1 / 8 of the green component image G, hiding data U into the lowest bit of the green component image G based on the LSB algorithm.