Reversible grayscale method and system based on bit field multichannel fusion coding, computer readable storage medium and computer program product
Through the method of bit-domain multi-channel fusion coding, the problems of high computational complexity and large resource occupation of deep learning reversible grayscale methods are solved, and efficient and low-complexity reversible grayscale image processing is realized, which is suitable for embedded platforms.
Patent Information
- Application Number
- CN202510772799.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-09-23
AI Technical Summary
Existing reversible grayscale methods based on deep learning have high computational complexity, large resource consumption, limited generalization ability, and the encoding process is unexplainable and difficult to optimize.
A method based on bit-domain multi-channel fusion coding is adopted. By normalizing and converting RGB images to HSV, the three-channel data of the HSV image are used for encoding and decoding to achieve the generation and restoration of reversible grayscale images, and a zero-parameter storage design is adopted.
It reduces information loss, lowers computational complexity and memory usage, improves computing speed, supports high-resolution image processing, is suitable for embedded platforms, and is flexible for cross-platform porting.
Smart Images

Figure CN120689197A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a reversible grayscale method, system, computer-readable storage medium, and computer program product based on bit-domain multi-channel fusion coding. Background Art
[0002] Reversible grayscale methods are methods that can convert a color image into a grayscale image while retaining enough information to restore the original color image with high fidelity when needed.
[0003] Most existing reversible grayscale methods are based on deep learning, which leverages powerful nonlinear mapping capabilities to achieve high color reproduction. However, existing deep learning-based reversible grayscale methods require complex network structures and a large number of parameters, which not only increases computational complexity but also increases the use of computing resources. Furthermore, the performance of this method is strongly correlated with the training data samples, requiring large-scale datasets for supervised training, with limited generalization capabilities and significantly reduced cross-domain processing performance. Furthermore, the encoding process of deep learning methods is similar to a black-box transformation, making it difficult to intuitively understand how color information is encoded and embedded in grayscale images. This method has a certain degree of inexplicability, which increases the difficulty of further optimization and improvement. Summary of the Invention
[0004] The object of the present invention is to provide a reversible grayscale method, system, computer-readable storage medium and computer program product based on bit-domain multi-channel fusion coding to solve or at least partially solve the technical problems mentioned in the above background technology.
[0005] To achieve this object, the present invention adopts the following technical solutions:
[0006] In a first aspect, the present invention provides a reversible grayscale method based on bit-domain multi-channel fusion coding, comprising:
[0007] Normalize the input original RGB image to obtain a normalized RGB image;
[0008] Convert the normalized RGB image to the corresponding HSV image and normalize the H channel of the HSV image;
[0009] A reversible grayscale image is obtained by calculating the three-channel data of the HSV image using a predetermined coding rule; wherein the three-channel data of the HSV image includes saturation, lightness, and normalized hue;
[0010] Decoding the reversible grayscale image using a predetermined decoding rule to restore the three-channel data of the HSV image; wherein the predetermined decoding rule matches or corresponds to the predetermined encoding rule;
[0011] According to the three-channel data of the restored HSV image, the final RGB image is converted.
[0012] Optionally, normalizing the input original RGB image to obtain a normalized RGB image specifically includes:
[0013] Normalize the original RGB image to obtain a normalized RGB image and record it as R'G'B' image. The normalization method is:
[0014] Among them, (r,c) indicates pixel-by-pixel calculation.
[0015] Optionally, converting the normalized RGB image into a corresponding HSV image and normalizing the H channel of the HSV image specifically includes:
[0016] Calculate the maximum value C of each pixel in the R'G'B' image max , minimum value C min The sum difference Δ is calculated as:
[0017] C max =max(R′,G′,B′),C min =min(R',G',B'), Δ=C max -C min ;
[0018] Calculate hue H (r,c) , saturation S (r,c) and brightness V (r,c) ; The calculation method is:
[0019]
[0020] Among them, mod means remainder operation, Indicates floor operation;
[0021] Normalize the H channel of the HSV image to obtain the normalized H channel data H' (r,c) , the method is:
[0022] H′ (r,c) =H (r,c) ÷360.
[0023] Optionally, the step of calculating the reversible grayscale image based on the three-channel data of the HSV image using a predetermined coding rule specifically includes:
[0024] The saturation S (r,c) , brightness V (r,c) and the normalized hue H' (r,c), calculate a 16-bit reversible grayscale image IG through a predetermined coding rule (r,c) ; The predetermined coding rule is:
[0025]
[0026] a + b + c = 16;
[0027] Among them, 丨 represents the bitwise AND operation of binary numbers, represents the floor operation, and a, b, and c represent the number of bits occupied by each channel of HSV in the reversible grayscale image.
[0028] Optionally, decoding the reversible grayscale image through a predetermined decoding rule to restore the three-channel data of the HSV image specifically includes:
[0029] Decode and restore the three-channel data of the HSV image from the 16-bit reversible grayscale image through a predetermined decoding rule; The predetermined decoding rule is:
[0030] Hg (r,c) = (IG (r,c) & 2 a ) ÷ 2 a × 360, Sg (r,c) = [IG (r,c) ÷ 2 a ) & 2 b ÷ 2 b , Vg (r,c) = [IG (r,c) ÷ 2 (a+b) ) & 2 c ÷ 2 c ;
[0031] Among them, & represents the bitwise AND operation, Hg (r,c) is the hue of the restored HSV image, Sg (r,c) is the saturation of the restored HSV image, and Vg (r,c) is the lightness of the restored HSV image.
[0032] Optionally, converting to the final RGB image according to the three-channel data of the restored HSV image specifically includes:
[0033] Fuse the three-channel data of the restored HSV image to obtain a new HSV image;
[0034] Convert the new HSV image to the final RGB image.
[0035] Optionally, the conversion of the new HSV image to the final RGB image specifically includes:
[0036] Calculate the temporary components C, X, and M based on the three-channel data of the new HSV image. The calculation method is:
[0037] C (r,c) =Vg (r,c) -Sg (r,c) ,
[0038] X (r,c) =C (r,c) ×{1-|[(Hg (r,c) ÷60)mod 2]-1|},
[0039] M (r,c) =Vg (r,c) -C (r,c) ;
[0040] According to Hg (r,c) The value of determines the temporary RGB components of each pixel as follows:
[0041]
[0042] According to M (r,c) Adjust the temporary RGB components by:
[0043] in,(.) T represents transpose;
[0044] Generate the final RGB image based on the adjusted RGB components.
[0045] Optionally, a is 6, b is 5, and c is 5.
[0046] Optionally, after converting the new HSV image into the final RGB image, the method further includes:
[0047] The mean absolute error (MAE) of the final RGB image and the original RGB image is calculated to obtain a corresponding error map.
[0048] Optionally, before normalizing the input original RGB image to obtain the normalized RGB image, the method further includes:
[0049] Input the original RGB image to be converted.
[0050] In a second aspect, the present invention provides a reversible grayscale system based on bit-domain multi-channel fusion coding, comprising:
[0051] The image preprocessing module is used to normalize the input original RGB image to obtain a normalized RGB image;
[0052] a conversion module, electrically connected to the image preprocessing module, configured to convert the normalized RGB image into a corresponding HSV image and normalize the H channel of the HSV image;
[0053] an encoding module electrically connected to the conversion module, configured to calculate and obtain a reversible grayscale image according to three-channel data of the HSV image using a predetermined encoding rule; wherein the three-channel data of the HSV image includes saturation, lightness, and normalized hue;
[0054] a decoding module, electrically connected to the encoding module, configured to decode the reversible grayscale image using a predetermined decoding rule to restore the three-channel data of the HSV image; wherein the predetermined decoding rule matches or corresponds to the predetermined encoding rule;
[0055] The image output module is electrically connected to the decoding module and is used to convert the three-channel data of the restored HSV image into a final RGB image.
[0056] Optionally, the image preprocessing module is specifically used to:
[0057] Normalize the original RGB image to obtain a normalized RGB image and record it as R'G'B' image. The normalization method is:
[0058] Among them, (r,c) indicates pixel-by-pixel calculation.
[0059] Optionally, the conversion module is specifically configured to:
[0060] Calculate the maximum value C of each pixel in the R'G'B' image max , minimum value C min The sum difference Δ is calculated as:
[0061] C max =max(R′,G′,B′),C min =min(R′, G′, B′), Δ=C max -C min ;
[0062] Calculate hue H (r,c) , saturation S (r,c) and brightness V (r,c) ; The calculation method is:
[0063]
[0064] Among them, mod means remainder operation, Indicates floor operation;
[0065] Normalize the H channel of the HSV image to obtain the normalized H channel data H'. (r,c) , the method is as follows:
[0066] H′ (r,c) = H (r,c) ÷ 360.
[0067] Optionally, the encoding module is specifically configured to:
[0068] Saturate S (r,c) , lightness V (r,c) and the normalized hue H' (r,c) , calculate the 16-bit reversible grayscale image IG (r,c) through a predetermined encoding rule; the predetermined encoding rule is:
[0069] <00003...
[0077] The three-channel data of the restored HSV image are fused to obtain a new HSV image;
[0078] Convert the new HSV image to the final RGB image.
[0079] Optionally, converting the new HSV image into the final RGB image specifically includes:
[0080] Calculate the temporary components C, X, and M based on the three-channel data of the new HSV image. The calculation method is:
[0081] C (r,c) =Vg (r,c) -Sg (r,c) ,
[0082] X (r,c) =C (r,c) ×{1-|[(Hg (r,c) ÷60)mod 2]-1|},
[0083] M (r,c) =Vg (r,c) -C (r,c) ;
[0084] According to Hg (r,c) The value of determines the temporary RGB components of each pixel as follows:
[0085]
[0086] According to M (r,c) Adjust the temporary RGB components by:
[0087] in,(.) T represents transpose;
[0088] Generate the final RGB image based on the adjusted RGB components.
[0089] Optionally, a is 6, b is 5, and c is 5.
[0090] Optionally, the image output module is further configured to, after converting the new HSV image into a final RGB image, calculate a mean absolute error between the final RGB image and the original RGB image to obtain a corresponding error map.
[0091] Optionally, the reversible grayscale system further includes an image input module for inputting an original RGB image to be converted; and the image preprocessing module is electrically connected to the image input module.
[0092] In a third aspect, the present invention further provides a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to implement the reversible grayscale method based on bit-domain multi-channel fusion coding as described above.
[0093] In a fourth aspect, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the above-mentioned reversible grayscale method based on bit-domain multi-channel fusion coding.
[0094] Compared with the prior art, the present invention has the following beneficial effects:
[0095] The present invention provides a reversible grayscale method based on bit-domain multi-channel fusion coding, which greatly reduces information loss during compression coding by utilizing bit-domain multi-channel fusion coding in the HSV channel. It adopts a lightweight design with zero parameter storage, which speeds up the calculation speed while effectively reducing memory usage. It can realize high-resolution image processing on embedded platforms, making cross-platform transplantation more flexible. BRIEF DESCRIPTION OF THE DRAWINGS
[0096] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.
[0097] Figure 1 A flowchart of a reversible grayscale method based on bit-domain multi-channel fusion coding is provided in an embodiment of the present invention.
[0098] Figure 2 An input original RGB image is provided in an embodiment of the present invention.
[0099] Figure 3 The embodiment of the present invention provides Figure 2 The resulting reversible grayscale image.
[0100] Figure 4 The embodiment of the present invention provides Figure 3 The final RGB image is restored.
[0101] Figure 5 The embodiment of the present invention provides Figure 2 and Figure 4 Calculated error map.
[0102] Figure 6 Another input original RGB image provided by an embodiment of the present invention.
[0103] Figure 7 The embodiment of the present invention provides Figure 6 The resulting reversible grayscale image.
[0104] Figure 8 The embodiment of the present invention provides Figure 7 The final RGB image is restored.
[0105] Figure 9 The embodiment of the present invention provides Figure 6 and Figure 8 Calculated error map.
[0106] Figure 10 Another input original RGB image is provided in an embodiment of the present invention.
[0107] Figure 11 The embodiment of the present invention provides Figure 10 The resulting reversible grayscale image.
[0108] Figure 12 The embodiment of the present invention provides Figure 11 The final RGB image is restored.
[0109] Figure 13 The embodiment of the present invention provides Figure 10 and Figure 12 Calculated error map.
[0110] Figure 14 This is a schematic diagram of the architecture of a reversible grayscale system based on bit-domain multi-channel fusion coding provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0111] In order to make the purpose, features, and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0112] Example 1:
[0113] For details, please refer to Figure 1 , Figure 1 A flowchart of a reversible grayscale method based on bit-domain multi-channel fusion coding provided by an embodiment of the present invention, the method specifically includes:
[0114] Step 100: Input the original RGB image to be converted.
[0115] In this step, an RGB image is a color image synthesized from the three basic color channels of red, green, and blue. It consists of three independent color channels: red, green, and blue. Each channel typically uses an 8-bit binary number to represent the intensity or brightness of the color, so the value of each channel ranges from 0 to 255. 0 represents the minimum intensity of the color channel (i.e., black), while 255 represents the maximum intensity (i.e., pure color).
[0116] Step 110: Normalize the input original RGB image to obtain a normalized RGB image.
[0117] Specifically, for ease of distinction, the normalized RGB image obtained in this step is recorded as R'G'B' image, and the normalization method used in this step is as follows;
[0118] Among them, (r,c) indicates pixel-by-pixel calculation.
[0119] Step 120: Convert the normalized RGB image into a corresponding HSV image, and normalize the H channel of the HSV image.
[0120] The HSV image in this step is an image represented by a color model based on three elements: hue, saturation, and lightness (or brightness).
[0121] Step 120 specifically includes:
[0122] Step 121: Calculate the maximum value C of each pixel in the R'G'B' image max , minimum value C min and the difference Δ.
[0123] C max , minimum value C min The sum difference Δ is calculated as follows:
[0124] C max =max(R′,G′,B′),C min =min(R′, G′, B′), Δ=C max -C min ;
[0125] Step 122: Calculate the hue H (r,c) , saturation S (r,c) and brightness V (r,c) .
[0126] Hue H (r,c) , saturation S (r,c) and brightness V (r,c) The calculation method is as follows:
[0127]
[0128] Among them, mod represents the modulo operation, represents the floor operation;
[0129] Step 123: Normalize the H channel of the HSV image to obtain the normalized H channel data H'. (r,c) .
[0130] The normalization method of the H channel is as follows:
[0131] H′ (r,c) = H (r,c) ÷360.
[0132] Step 130: Calculate a reversible grayscale image according to the three-channel data of the HSV image through a predetermined coding rule.
[0133] In this step, the three-channel data of the HSV image includes saturation, value, and normalized hue; Step 130 is specifically implemented as:
[0134] Take the saturation S (r,c) , the value V (r,c) and the normalized hue H' (r,c) , and calculate a 16-bit reversible grayscale image IG (r,c) through a predetermined coding rule;
[0135] Among them, the predetermined coding rule is:
[0136]
[0137] a + b + c = 16;
[0138] Among them, 丨 represents the bitwise AND operation of binary numbers, represents the floor operation, and a, b, and c represent the number of bits occupied by each channel of HSV in the reversible grayscale image.
[0139] Step 140: Decode the reversible grayscale image through a predetermined decoding rule to restore the three-channel data of the HSV image.
[0140] Specifically, Step 140 is implemented as:
[0141] Decode the 16-bit reversible grayscale image through a predetermined decoding rule to restore the three-channel data of the HSV image; the predetermined decoding rule is:
[0142] Hg (r,c) = (IG (r,c) & 2 a ) ÷ 2 a×360, Sg (r,c) =[IG (r,c) ÷2 a )&2 b ]÷2 b , Vg (r,c) =[IG (r,c) ÷2 (α+b) )&2 c ]÷2 c ;
[0143] Among them, & represents the bitwise AND operation, Hg (r,c) is the hue of the restored HSV image, Sg (r,c) is the saturation of the restored HSV image, Vg (r,c) is the brightness of the restored HSV image.
[0144] It should be noted that the predetermined decoding rule in step 140 matches or corresponds to the predetermined encoding rule in step 130 .
[0145] Step 150: Convert the restored three-channel data of the HSV image to obtain a final RGB image.
[0146] Specifically, step 150 includes:
[0147] Step 151: Fuse the three-channel data of the restored HSV image to obtain a new HSV image.
[0148] Step 152: Convert the new HSV image to the final RGB image.
[0149] More specifically, step 152 further includes:
[0150] Step 1521: Calculate temporary components C, X, and M based on the three-channel data of the new HSV image.
[0151] The calculation methods of C, X, and M are as follows:
[0152] C (r,c) =Vg (r,c) -Sg (r,c) ,
[0153] X (r,c) =C (r,c) ×{1-|[(Hg (r,c) ÷60)mod 2]-1|},
[0154] M (r,c) =Vg (r,c) -C (r,c) ;
[0155] Step 1522: According to Hg (r,c)The value of determines the temporary RGB components of each pixel.
[0156] The temporary RGB components are determined as follows:
[0157]
[0158] Step 1523: According to M (r,c) Adjust temporary RGB components.
[0159] The temporary RGB components are adjusted as follows:
[0160] in,(.) T represents transpose;
[0161] Step 1524: Generate a final RGB image based on the adjusted RGB components.
[0162] Step 160: Calculate the mean absolute error between the final RGB image and the original RGB image to obtain a corresponding error map.
[0163] It is understandable that the calculation formula of the mean absolute error (MAE) is common knowledge in the art, and therefore will not be described in detail in this embodiment.
[0164] To facilitate understanding of the reversible grayscale method based on bit-domain multi-channel fusion coding provided by this embodiment, this embodiment also provides the following three examples:
[0165] First of all, it should be noted that this embodiment provides a reversible grayscale method based on bit-domain multi-channel fusion coding, which includes two parts: RGB to Gray and Gray to RGB restoration. It uses a non-learning image processing algorithm to achieve pixel-level high efficiency and high color restoration calculation.
[0166] Specifically, such as Figure 2 As shown, Figure 2 An input original RGB image provided by an embodiment of the present invention;
[0167] In the RGB to Gray conversion, the RGB2HSV conversion algorithm is used, and the H channel data is normalized at the same time. Then, according to the designed bit field multi-channel fusion encoding rule, this example selects the values of a, b, and c parameters as 6, 5, and 5 respectively, and encodes HSV into a 16-bit reversible grayscale image, such as Figure 3 shown.
[0168] Further, Figure 3 The reversible grayscale image is restored in the decoding module of the Gray restoration RGB part. The HSV matrix is restored through the decoding rules corresponding to the a, b, and c parameters, and then the final RGB image is restored through the HSV2RGB algorithm, as shown in the following example: Figure 4 shown.
[0169] Finally, the mean absolute error of the restored final RGB image and the original RGB image is calculated to obtain the corresponding error map, as shown in Figure 5 shown.
[0170] It can be understood that the original RGB image, the reversible grayscale image, the final RGB image and the error image in the other two examples can all be obtained by implementing the above steps;
[0171] For one of the other two examples, see the original RGB image, reversible grayscale image, final RGB image, and error image. Figure 6-Figure 9 , Figure 6 Another input original RGB image provided by an embodiment of the present invention, Figure 7 The embodiment of the present invention provides Figure 6 The resulting reversible grayscale image, Figure 8 The embodiment of the present invention provides Figure 7 The final RGB image restored is Figure 9 The embodiment of the present invention provides Figure 6 and Figure 8 Calculated error map;
[0172] For the other two examples, see the original RGB image, reversible grayscale image, final RGB image, and error image. Figure 10-13 , Figure 10 Another input original RGB image provided by an embodiment of the present invention is: Figure 11 The embodiment of the present invention provides Figure 10 The resulting reversible grayscale image, Figure 12 The embodiment of the present invention provides Figure 11 The final RGB image restored is Figure 13 The embodiment of the present invention provides Figure 10 and Figure 12 Calculated error map.
[0173] In summary, the reversible grayscale method based on bit-domain multi-channel fusion coding provided by this embodiment has at least the following beneficial effects:
[0174] First, the hardware adaptation cost is low. Encoding algorithms can be designed on the CPU to achieve high-fidelity processing. Pixel-level encoding kernel functions designed based on the CUDA (Compute Unified Device Architecture) parallel architecture can also be used to further achieve real-time processing of high-resolution images with tens of millions of pixels.
[0175] Second, a multi-channel dynamic bit field allocation coding rule is proposed to support the flexible design of different HSV channel quantization precision allocations based on specific needs to meet different application scenarios, such as medical imaging focusing on preserving brightness and artistic processing focusing on preserving hue.
[0176] Third, the lightweight design with zero parameter storage speeds up the calculation while effectively reducing memory usage. It can realize high-resolution image processing on embedded platforms and is more flexible in cross-platform porting.
[0177] Example 2:
[0178] Please refer to Figure 14 , Figure 14 This is a schematic diagram of the architecture of a reversible grayscale system based on bit-domain multi-channel fusion coding provided by an embodiment of the present invention. The system specifically includes:
[0179] The image preprocessing module 10 is used to normalize the input original RGB image to obtain a normalized RGB image;
[0180] The conversion module 20 is electrically connected to the image preprocessing module 10 and is used to convert the normalized RGB image into a corresponding HSV image and normalize the H channel of the HSV image;
[0181] The encoding module 30 is electrically connected to the conversion module 20 and is configured to calculate and obtain a reversible grayscale image based on the three-channel data of the HSV image using a predetermined encoding rule; wherein the three-channel data of the HSV image includes saturation, lightness, and normalized hue;
[0182] The decoding module 40 is electrically connected to the encoding module 30 and is used to decode the reversible grayscale image according to a predetermined decoding rule to restore the three-channel data of the HSV image; wherein the predetermined decoding rule matches or corresponds to the predetermined encoding rule;
[0183] The image output module 50 is electrically connected to the decoding module 40 and is used to convert the three-channel data of the restored HSV image into a final RGB image.
[0184] Specifically, the image preprocessing module 10 is specifically used to:
[0185] Normalize the original RGB image to obtain a normalized RGB image and record it as R'G'B' image. The normalization method is:
[0186] Among them, (r,c) indicates pixel-by-pixel calculation.
[0187] Specifically, the conversion module 20 is specifically used to:
[0188] Calculate the maximum value C of each pixel in the R'G'B' image max , the minimum value C min and the difference Δ. The calculation method is as follows:
[0189] C max = max(R′, G′, B′), C min = min(R′, G′, B′), Δ = C max - C min ;
[0190] Calculate the hue H (r,c) , the saturation S (r,c) and the value V (r,c) ; The calculation method is as follows:
[0191]
[0192] where mod represents the modulo operation, represents the floor operation;
[0193] Normalize the H channel of the HSV image to obtain the normalized H channel data H' (r,c) , the method is:
[0194] H' (r,c) = H (r,c) ÷ 360.
[0195] Specifically, the encoding module 30 is specifically used for:
[0196] Using the saturation S (r,c) , the value V (r,c) and the normalized hue H' (r,c) , calculate the 16-bit reversible grayscale image IG (r,c) ; The predetermined encoding rule is:
[0197]
[0198] a + b + c = 16;
[0199] where | represents the bitwise AND operation of binary numbers, represents the floor operation, and a, b, c represent the number of bits occupied by each channel of HSV in the reversible grayscale image.
[0200] Specifically, the decoding module 40 is specifically used for:
[0201] Decode and restore the three-channel data of the HSV image from the 16-bit reversible grayscale image through a predetermined decoding rule; The predetermined decoding rule is:
[0202] Hg (r,c) =(IG(r,c) &2 a )÷2 a ×360, Sg (r,c) =[IG (r,c) ÷2 a )&2 b ]÷2 b , Vg (r,c) =[IG (r,c) ÷2 (a+b) )&2 c ]÷2 c ;
[0203] Among them, & represents the bitwise AND operation, Hg (r,c) is the hue of the restored HSV image, Sg (r,c) is the saturation of the restored HSV image, Vg (r,c) is the brightness of the restored HSV image.
[0204] Specifically, the image output module 50 is specifically used to:
[0205] The three-channel data of the restored HSV image are fused to obtain a new HSV image;
[0206] Convert the new HSV image to the final RGB image.
[0207] Specifically, converting the new HSV image to the final RGB image includes:
[0208] Calculate the temporary components C, X, and M based on the three-channel data of the new HSV image. The calculation method is:
[0209] C (r,c) =Vg (r,c) -Sg (r,c) ,
[0210] X (r,c) =C (r,c) ×{1-|[(Hg (r,c) ÷60)mod 2]-1|},
[0211] M (r,c) =Vg (r,c) -C (r,c) ;
[0212] According to Hg (r,c) The value of determines the temporary RGB components of each pixel as follows:
[0213]
[0214] According to M (r,c) Adjust the temporary RGB components by:
[0215] in,(.) T represents transpose;
[0216] Generate the final RGB image based on the adjusted RGB components.
[0217] Specifically, the image output module 50 is further configured to, after converting the new HSV image into the final RGB image, calculate the mean absolute error between the final RGB image and the original RGB image to obtain a corresponding error map.
[0218] Specifically, the reversible grayscale system further includes an image input module 60 for inputting the original RGB image to be converted; the image preprocessing module 10 is electrically connected to the image input module 60 .
[0219] This embodiment provides a reversible grayscale system based on bit-domain multi-channel fusion coding, which adopts a lightweight design with zero parameter storage. While accelerating the computing speed, it effectively reduces memory usage. It can realize high-resolution image processing on embedded platforms, making cross-platform porting more flexible.
[0220] Example 3:
[0221] This embodiment also provides a computer-readable storage medium, which stores at least one instruction. The instruction is loaded and executed by a processor to implement a reversible grayscale method based on bit-domain multi-channel fusion coding as described in Example 1.
[0222] Since the reversible grayscale method based on bit-domain multi-channel fusion coding has been described in detail in the first embodiment, it will not be described in detail in this embodiment.
[0223] Example 4:
[0224] The present invention also provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, a reversible grayscale method based on bit-domain multi-channel fusion coding as described in Example 1 is implemented.
[0225] Since the reversible grayscale method based on bit-domain multi-channel fusion coding has been described in detail in the first embodiment, it will not be described in detail in this embodiment.
[0226] Those skilled in the art will appreciate that all or part of the steps of the above-described embodiments can be implemented by hardware or by programs instructing the relevant hardware to perform the steps. The programs can be stored in a computer-readable storage medium, which can be a read-only memory, a magnetic disk, or an optical disk. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0227] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A reversible grayscale method based on bit-domain multi-channel fusion coding, characterized in that: include: Normalize the input original RGB image to obtain a normalized RGB image; Convert the normalized RGB image to the corresponding HSV image and normalize the H channel of the HSV image; A reversible grayscale image is obtained by calculating the three-channel data of the HSV image using a predetermined coding rule; wherein the three-channel data of the HSV image includes saturation, lightness, and normalized hue; Decoding the reversible grayscale image using a predetermined decoding rule to restore the three-channel data of the HSV image; wherein the predetermined decoding rule matches or corresponds to the predetermined encoding rule; According to the three-channel data of the restored HSV image, the final RGB image is converted.
2. A reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 1, characterized in that: Normalizing the input original RGB image to obtain a normalized RGB image specifically includes: Normalize the original RGB image to obtain a normalized RGB image and record it as R'G'B' image. The normalization method is: Among them, (r,c) indicates pixel-by-pixel calculation.
3. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 2, characterized in that: The step of converting the normalized RGB image into a corresponding HSV image and normalizing the H channel of the HSV image specifically includes: Calculate the maximum value C of each pixel in the R'G'B' image max , minimum value C min The sum difference Δ is calculated as: C max =max(R′,G′,B′),C min =min(R′, G′, B′), Δ=C max -C min ; Calculate hue H (r,c) , saturation S (r,c) and brightness V (r,c) ; The calculation method is: Among them, mod means remainder operation, Indicates floor operation; Normalize the H channel of the HSV image to obtain the normalized H channel data H' (r,c) , the method is: H′ (r,c) =H (r,c) ÷360。 4. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 3, characterized in that: The method of calculating the reversible grayscale image based on the three-channel data of the HSV image by a predetermined coding rule specifically includes: The saturation S (r,c) , brightness V (r,c) and the normalized hue H' (r,c) , calculate the 16-bit reversible grayscale image IG through the predetermined encoding rules (r,c) ; The predetermined coding rule is: Among them, 丨 represents the bitwise AND operation of binary numbers, represents the floor operation, and a, b, and c represent the number of bits occupied by each channel of HSV in the reversible grayscale image.
5. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 4, characterized in that: Decoding the reversible grayscale image using a predetermined decoding rule to restore the three-channel data of the HSV image specifically includes: The 16-bit reversible grayscale image is decoded and restored into the three-channel data of the HSV image using a predetermined decoding rule; the predetermined decoding rule is: Mercury (r,c) =(I.G. (r,c) &2 a )÷2 a ×360, Sg (r,c) =[I.G. (r,c) ÷2 a )&2 b ]÷2 b ,Vg (r,c) =[I.G. (r,c) ÷2 (a +b) )&2 c ]÷2 c ; Among them, & represents the bitwise AND operation, Hg (r,c) is the hue of the restored HSV image, Sg (r,c) is the saturation of the restored HSV image, Vg (r,c) is the brightness of the restored HSV image.
6. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 5, characterized in that: The conversion of the restored three-channel data of the HSV image to obtain the final RGB image specifically includes: The three-channel data of the restored HSV image are fused to obtain a new HSV image; Convert the new HSV image to the final RGB image.
7. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 6, characterized in that: The new HSV image is converted into the final RGB image, specifically including: Calculate the temporary components C, X, and M based on the three-channel data of the new HSV image. The calculation method is: C (r,c) =Vg (r,c) -Sg (r,c) , X (r,c) =C (r,c) ×{1-|[(Hg (r,c) ÷60)mod 2]-1|}, M (r,c) =Vg (r,c) -C (r,c) ; According to Hg (r,c) The value of determines the temporary RGB components of each pixel as follows: According to M (r,c) Adjust the temporary RGB components by: in,(.) T represents transpose; Generate the final RGB image based on the adjusted RGB components.
8. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 4, characterized in that: a is 6, b is 5, and c is 5.
9. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 6, characterized in that: After converting the new HSV image into the final RGB image, the following steps are also included: The mean absolute error (MAE) of the final RGB image and the original RGB image is calculated to obtain a corresponding error map.
10. The reversible grayscale method based on bit-domain multi-channel fusion coding according to claim 1, characterized in that: Before normalizing the input original RGB image to obtain the normalized RGB image, the method further includes: Input the original RGB image to be converted.
11. A reversible grayscale system based on bit-domain multi-channel fusion coding, characterized in that: include: The image preprocessing module is used to normalize the input original RGB image to obtain a normalized RGB image; a conversion module, electrically connected to the image preprocessing module, configured to convert the normalized RGB image into a corresponding HSV image and normalize the H channel of the HSV image; an encoding module electrically connected to the conversion module, configured to calculate and obtain a reversible grayscale image according to three-channel data of the HSV image using a predetermined encoding rule; wherein the three-channel data of the HSV image includes saturation, lightness, and normalized hue; a decoding module, electrically connected to the encoding module, configured to decode the reversible grayscale image using a predetermined decoding rule to restore the three-channel data of the HSV image; wherein the predetermined decoding rule matches or corresponds to the predetermined encoding rule; The image output module is electrically connected to the decoding module and is used to convert the three-channel data of the restored HSV image into a final RGB image.
12. A reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 11, characterized in that: The image preprocessing module is specifically used for: Normalize the original RGB image to obtain a normalized RGB image and record it as R'G'B' image. The normalization method is: Among them, (r,c) indicates pixel-by-pixel calculation.
13. A reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 12, characterized in that: The conversion module is specifically used for: Calculate the maximum value C of each pixel in the R'G'B' image max , minimum value C min The sum difference Δ is calculated as: C max =max(R′,G′,B′),C min =min(R′, G′, B′), Δ=C max -C min ; Calculate hue H (r,c) , saturation S (r,c) and brightness V (r,c) ; The calculation method is: Among them, mod means remainder operation, Indicates floor operation; Normalize the H channel of the HSV image to obtain the normalized H channel data H' (r,c) , the method is: H′ (r,c) =H (r,c) ÷360。 14. A reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 13, characterized in that: The encoding module is specifically used for: The saturation S (r,c) , brightness V (r,c) and the normalized hue H' (r,c) , calculate the 16-bit reversible grayscale image IG through the predetermined encoding rules (r,c) ; The predetermined coding rule is: Among them, 丨 represents the bitwise AND operation of binary numbers, represents the floor operation, and a, b, and c represent the number of bits occupied by each channel of HSV in the reversible grayscale image.
15. The reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 14, characterized in that: The decoding module is specifically used for: The 16-bit reversible grayscale image is decoded and restored into the three-channel data of the HSV image using a predetermined decoding rule; the predetermined decoding rule is: Mercury (r,c) =(I.G. (r,c) &2 a )÷2 a ×360, Sg (r,c) =[I.G. (r,c) ÷2 a )&2 b )÷2 b ,Vg (r,c) =[I.G. (r,c) ÷2 (a +b) )&2 c ]÷2 c ; Among them, & represents the bitwise AND operation, Hg (r,c) is the hue of the restored HSV image, Sg (r,c) is the saturation of the restored HSV image, Vg (r,c) is the brightness of the restored HSV image.
16. A reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 15, characterized in that: The image output module is specifically used for: The three-channel data of the restored HSV image are fused to obtain a new HSV image; Convert the new HSV image to the final RGB image.
17. A reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 16, characterized in that: The new HSV image is converted into the final RGB image, specifically including: Calculate the temporary components C, X, and M based on the three-channel data of the new HSV image. The calculation method is: C (r,c) =Vg (r,c) -Sg (r,c) , X (r,c) =C (r,c) ×{1-|[(Hg (r,c) ÷60)mod 2]-1|}, M (r,c) =Vg (r,c) -C (r,c) ; According to Hg (r,c) The value of determines the temporary RGB components of each pixel as follows: According to M (r,c) Adjust the temporary RGB components by: in,(.) T represents transpose; Generate the final RGB image based on the adjusted RGB components.
18. The reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 14, characterized in that: a is 6, b is 5, and c is 5.
19. The reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 16, characterized in that: The image output module is further configured to, after converting the new HSV image into a final RGB image, calculate the mean absolute error between the final RGB image and the original RGB image to obtain a corresponding error map.
20. The reversible grayscale system based on bit-domain multi-channel fusion coding according to claim 11, characterized in that: It also includes an image input module for inputting the original RGB image to be converted; the image preprocessing module is electrically connected to the image input module.
21. A computer-readable storage medium, wherein at least one instruction is stored in the storage medium, characterized in that: The instructions are loaded and executed by the processor to implement a reversible grayscale method based on bit-domain multi-channel fusion coding as described in any one of claims 1-10.
22. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by the processor, the reversible grayscale method based on bit-domain multi-channel fusion coding described in any one of claims 1-10 is implemented.