An image space random distribution lossless secret image steganography and extraction method
By using the lower 4 bits to write secret information in image spatial domain technology and using random samples to shuffle the pixel order and generate random positions with the key, the problem of insufficient embedding capacity and concealment in existing image steganography technology is solved, and efficient, secure lossless secret image transmission and extraction are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINACCS INFORMATION IND
- Filing Date
- 2022-09-07
- Publication Date
- 2026-05-15
AI Technical Summary
Existing image steganography techniques suffer from problems such as large embedding capacity but low concealment and security, or high concealment and security but small embedding capacity. In addition, existing methods consume a lot of computing power and the extracted secret images are degraded.
Spatial domain technology is used to write secret information into the lower 4 bits of the pixels of the carrier image. The pixel order is shuffled by random samples and a key is used to generate randomly uniformly distributed pixel positions. The height and width dimensions of the secret image are embedded and encoded to generate a key to extract the width and height values of the secret image, thus achieving lossless extraction.
It achieves lossless steganography and extraction of secret images, with an embedding capacity of up to 50%, good information security, low computing power consumption, and is not easily detected by changes, with high operating efficiency.
Smart Images

Figure CN116320194B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information security technology, and in particular to a method for lossless steganography and extraction of secret images based on random spatial distribution in the image domain. Background Technology
[0002] With the widespread adoption of internet technology, information can be easily transmitted via computers, tablets, mobile phones, mobile terminals, and smart devices. The application of 5G further accelerates the transmission of large amounts of information. However, this transmission process also makes it easy to leak personal privacy, corporate secrets, and confidential government information. To address information security issues, numerous methods for information encryption / decryption and information concealment have been continuously developed in the field of information security technology.
[0003] Image steganography has become a hot topic in the field of information security. It involves using algorithms to embed secret information (text or image) into a carrier image with minimal impact on its visual quality, making it difficult for others to detect the hidden information. This allows the steganized image to be transmitted over the internet, making this technology of great significance and with wide-ranging applications.
[0004] This invention relates to a method for embedding a secret image into a carrier image using image steganography, transmitting it to the recipient, and then retrieving the secret image. For ease of description, the image to be hidden can be called the secret image, the host image of the secret image can be called the carrier image, and the image containing the secret image can be called the steganographic image. Image steganography integrates technologies from multiple disciplines such as digital imaging, cryptography, and biology. It focuses on making the steganographic image more concealed, the secret image more secure, having a higher embedding capacity, and consuming as little computational power as possible.
[0005] Image steganography techniques are generally divided into two categories: spatial domain techniques and frequency domain techniques. For spatial domain techniques, the secret image is directly written into the pixels of the carrier image. This technique has a high embedding capacity and is simple to implement, but its resistance to attacks is relatively low. For frequency domain techniques, the secret data is written into the transform coefficients. This technique generally has stronger resistance to attacks, but its embedding capacity is relatively low.
[0006] In recent years, image steganography technology based on AI adversarial network models has also made good progress. However, this often requires collecting a large amount of image data, consuming a lot of GPU computing power, and training the model for a long time. Moreover, the model's inference also has high computing power requirements. Another problem is that the extracted secret image is lossy. Although the changes in the image are not perceptible to the human eye, there are actually differences from the original image, and many scenarios require 100% restoration of the secret image.
[0007] Research and analysis of existing technologies revealed that some methods have large embedding capacity but low concealment and security, resulting in lossy extraction; while other methods have high concealment and security but small embedding capacity and high computational consumption. Summary of the Invention
[0008] To address the problems in the existing technologies, this invention provides a lossless method for steganography and extraction of secret images. For the image steganography method, spatial domain techniques are used to write secret information into the lower 4 bits of the pixels in the carrier image, achieving an embedding capacity of up to 50%. The pixel values of the secret image are randomly sampled and shuffled before being embedded into the carrier image; these random samples are generated using a key, improving the data security of the secret image. For the embedding position of the secret image in the carrier image, a randomly and uniformly distributed pixel position is generated using the key, further enhancing the positional security of the secret image. The height and width dimensions of the secret image are encoded and hidden within the key, providing excellent security. For the image extraction method, 16 characters are extracted from the end of the key and decoded into the width and height values of the secret image. Random samples of the secret image pixel positions and the embedding position of the secret information in the carrier image are generated using the key. The secret information is extracted from the embedding position, and each pixel of the secret image is reconstructed based on the pixel position samples, generating the reconstructed secret image.
[0009] The present invention is achieved through the following technical solution: a method for lossless steganography and extraction of secret images based on random spatial distribution in the image domain, including a steganography method and a lossless extraction method;
[0010] The secret image steganography method includes the following steps:
[0011] E-S1. Select an image as the carrier image a, read the carrier image a, obtain the height ah and width aw of the carrier image a, and calculate the number of pixels an:
[0012] E-S2. Select an image as a secret image b to be embedded into the carrier image a. The total number of pixels in the secret image b is less than or equal to half the total number of pixels in the carrier image a. Read the secret image b and obtain its height bh and width bw. Calculate the number of pixels bn.
[0013] E-S3 generates a key to encrypt the secret image b. Specifically, 48 characters are randomly selected from 52 uppercase and lowercase letters and 10 numbers to generate a 48-byte string key48. The width bw, commas, and height bh of the secret image b are concatenated to form an 11-byte string key11, where the width and height each occupy 5 bits, padded with leading zeros if less than 5 bits. Then, key11 is base64 encoded to generate a 16-byte string key16. Finally, key48 and key16 are concatenated to form the key, which is a 64-byte string.
[0014] E-S4. Generate the embedding positions of the secret image b pixels in the carrier image a, which are randomly and uniformly distributed. Specifically, generate a sequence of all integers contained in the interval [0, an). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample 2 times bn elements from the above interval an elements to generate a sorted list of pseudo-random number sample tuples ASampleBN with 2 times bn non-repeating elements. This list stores the embedding positions of the secret information pixels in the carrier image a.
[0015] E-S5: Re-encode the secret image by randomly shuffling the pixel positions of the secret image; specifically: generate a sequence of all integers contained in the interval [0, bn), use the key as the seed, and use a pseudo-random number generation algorithm to randomly sample bn elements from the bn elements in the above interval to generate a list of pseudo-random number sample tuples BSPangleBN with bn non-repeating elements. This list stores the new positions of the secret image pixels after random sampling.
[0016] E-S6: Sequentially embed the pixels of the re-encoded secret image into the embedding positions of the carrier image a to generate a complete steganalytic image. This step is crucial for embedding the secret information because a pixel value in the secret image is 8 bits, while the carrier image uses the lower 4 bits of each pixel to store the embedding information. Therefore, a pixel value in the secret image needs to be stored using two embedding positions in the carrier image. Specifically:
[0017] E-S601, Prepare the embedded information, set the loop variable i to 0;
[0018] E-S602, Extract the three-channel pixel values of BGR from the corresponding position BSAmpleBN[i] of the secret image b: bb, bg, br;
[0019] E-S603. At the ASampleBN[i*2]th embedding position of the carrier image a, replace the low 4 bits of the three-channel pixel values ab1, ag1, ar1 of the carrier image BGR with the high 4 bits of the three-channel pixel values bb, bg, br of the secret image BGR.
[0020] E-S604. At the ASampleBN[i*2+1]th embedding position of the carrier image a, replace the lower 4 bits of the three-channel pixel values ab2, ag2, ar2 of the carrier image BGR with the lower 4 bits of the three-channel pixel values bb, bg, br of the secret image BGR.
[0021] E-S605: Increment the loop variable i by 1. If the value of i is less than bn, repeat steps E-S602-E-S604 until the value of i is greater than or equal to bn and the loop ends. After the above loop is completed, a complete steganographic image is generated.
[0022] The method for non-destructive extraction of secret images includes the following steps:
[0023] D-S1: The receiver receives the steganographic image and obtains the key that comes with the steganographic image.
[0024] D-S2: Extract the width and height of the secret image from the key key; specifically: extract 16 characters key16 from the end of the key key, decode it using base64 to generate the original text, and divide the original text into two parts using commas as separators. The first part is the width value bw of the secret image, and the second part is the height value bh of the secret image.
[0025] D-S3: Read the steg image, obtain the height ah and width aw of the steg image, and calculate the number of pixels an.
[0026] D-S4: Calculate the number of pixels bn based on the height bh and width bw of the secret image;
[0027] D-S5, Restore the embedding position of the secret image pixel in the carrier image, specifically: Generate a sequence of all integers contained in the interval [0, an), using the key as the seed, and using a pseudo-random number generation algorithm, randomly sample 2 times bn elements from the above interval an elements to generate a sorted pseudo-random number sample tuple list ASampleBN with 2 times bn non-repeating elements. This list stores the embedding position of the secret image pixel in the carrier image.
[0028] D-S6, Decode the secret image and restore the actual position of the pixels in the secret image; Specifically, generate a sequence of all integers contained in the interval [0, bn), use the key as the seed, and use a pseudo-random number generation algorithm to randomly sample bn elements from the bn elements in the above interval to generate a list of pseudo-random number sample tuples BSPangleBN with bn non-repeating elements. This list stores the actual pixel arrangement position of the secret image.
[0029] D-S7: Extract the embedding positions of pixels in the carrier image from the two embedding positions in the carrier image, combine them to generate a pixel value of the secret image, and then arrange the pixels in the secret image according to their actual positions to extract the complete secret image; specifically:
[0030] D-S701. Prepare to extract secret information, generate a secret image zero matrix b with dimension (bn,3), and set the loop variable i to 0;
[0031] D-S702. Extract the lower 4 bits alow_b1, alow_g1, alow_r1 of the BGR three-channel pixel values ab1, ag1, ar1 from the ASampleBN[i*2]th embedding position of the carrier image;
[0032] D-S703. Extract the lower 4 bits of the BGR three-channel pixel values ab2, ag2, ar2 from the ASampleBN[i*2+1]th embedding position of the carrier image: alow_b2, alow_g2, alow_r2.
[0033] D-S704, shift aow_b1, aow_g1, aow_r1 left by 4 bits and OR them with aow_b2, aow_g2, aow_r2 to obtain the actual pixel values of the secret image: bb, bg, br. Write the three-channel pixel values bb, bg, br into the corresponding position BSAmpleBN[i] of the secret image b.
[0034] D-S705. The loop variable i is incremented by 1. If the value of i is less than twice bn, then the loop executes steps D-S702-D-S704 repeatedly until the value of i is greater than or equal to twice bn and the loop ends.
[0035] D-S706. Convert the dimensions of the secret image matrix b to (bh, bw, 3). At this point, the secret image is extracted.
[0036] The beneficial effects of this invention are: it can be used for the covert transmission of confidential information, featuring lossless extraction, large embedding capacity, good information security, low detectability, and low computational consumption. By employing spatial domain technology to write secret information into the lower 4 bits of image pixels, the embedding capacity can reach up to 50% of the carrier capacity, and the lower 4 pixel values have minimal impact on human vision, making the changes virtually imperceptible. Through methods such as encrypting the secret image and randomly generating embedding positions, the secret image receives double security protection. Furthermore, this algorithm consumes relatively little computational power and has high operating efficiency. Attached Figure Description
[0037] Figure 1 This is the model of the image steganography and extraction system of the present invention.
[0038] Figure 2 This is a flowchart of the secret image embedding process of the present invention.
[0039] Figure 3 This is a flowchart of the secret image extraction process of the present invention.
[0040] Figure 4 This is a flowchart illustrating the key generation process of this invention.
[0041] Figure 5 This is a flowchart illustrating the process of extracting the width and height of a secret image according to the present invention.
[0042] Figure 6 This is an example of embedding a secret image in this invention.
[0043] Figure 7 This is an image of the carrier used in the test experiment of this invention.
[0044] Figure 8 This is the original secret image used in the test experiment of this invention.
[0045] Figure 9 This is a steganographic image used in the test experiments of this invention.
[0046] Figure 10 This is a secret image extracted from the test experiments of this invention.
[0047] Figure 11 This is a comparison of the histograms of the carrier image and the stegographic image in the test experiment of this invention. Detailed Implementation
[0048] To clearly illustrate the technical features of this solution, the following detailed implementation method will be used to explain the solution.
[0049] Example 1
[0050] See Figure 1 and Figure 2This invention provides a method for lossless steganography and extraction of secret images based on random spatial distribution in the image domain, comprising the following steps:
[0051] S1, Select an image as the carrier image, read the carrier image a, obtain the height ah and width aw of the carrier image, and calculate the number of pixels an:
[0052] an = ah × aw;
[0053] S2, select an image as the secret image to be embedded into the carrier image. This secret image is the information to be transmitted. The total number of pixels in this image should be less than or equal to half the total number of pixels in the carrier image. Read the secret image b, obtain its height bh and width bw, and calculate the number of pixels bn.
[0054] bn = bh × bw;
[0055] S3, see S3. Figure 4 This step aims to generate a key for steganography encryption and secret image extraction. Specifically, it involves: randomly selecting 48 characters from 52 uppercase and lowercase letters and 10 digits to generate a 48-byte string, key48. Then, concatenating the width (bw), commas, and height (bh) of the secret image into an 11-byte string, key11, with each dimension occupying 5 characters (padded with leading zeros if necessary). Next, base64 encoding key11 generates a 16-byte string, key16. Finally, concatenating key48 and key16 forms the key, which is a 64-byte string.
[0056] Furthermore, S3 is illustrated with an example. Assuming the width and height of the secret image are 320 and 316 respectively, then:
[0057] key11 = "00320,00316"
[0058] key16 = base64encode(key11)
[0059] ="MDAzMjAsMDAzMTY="
[0060] key48="Et3f8D8GIB1MPkrGvmXVPjK5tMkeG3MiMEVmCkpMEGhxSPj6"
[0061] key = key48 + key16
[0062] ="Et3f8D8GIB1MPkrGvmXVPjK5tMkeG3MiMEVmCkpMEGhxSPj6MDAzMjAsMDAzMTY="
[0063] S4, see S4 Figure 6 To generate the embedding positions of the secret image pixels in the carrier image, which are randomly and uniformly distributed, we generate a sequence of all integers contained in the interval [0, an). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample 2xbn elements from the above interval an elements, generating a sorted list of pseudo-random sample tuples ASampleBN with 2xbn unique elements. This list stores the embedding positions of the secret information in the carrier image, and the specific formula is as follows:
[0064]
[0065] S5 re-encodes the secret image by randomly shuffling the pixel positions. Specifically, it generates a sequence of all integers within the interval [0, bn). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample bn elements from the bn elements in the above interval, generating a list of pseudo-random number sample tuples BSampleBN with bn unique elements. This list stores the new positions of the secret image pixels after random sampling. The specific formula is as follows:
[0066]
[0067] S6, prepare to embed information, set the loop variable i to 0;
[0068] S7, this step is the key step for embedding secret information. Because a pixel value of the secret image is 8 bits, while the carrier image uses the lower 4 bits of each pixel to store the embedded information, a pixel value of the secret image needs to be stored using two embedding positions of the carrier image. Specifically: extract the BGR three-channel pixel values: bb, bg, br from the corresponding position BSAmpleBN[i] of the secret image b. At the ASampleBN[i*2]th embedding position of the carrier image, replace the lower 4 bits of the BGR three-channel pixel values ab1, ag1, ar1 of the carrier image with the higher 4 bits of the secret image BGR three-channel pixel values bb, bg, br; at the ASampleBN[i*2+1]th embedding position of the carrier image, replace the lower 4 bits of the BGR three-channel pixel values ab2, ag2, ar2 of the carrier image with the lower 4 bits of the secret image BGR three-channel pixel values bb, bg, br.
[0069] Furthermore, S7 specifically includes:
[0070] S71, extract the three-channel pixel values of BGR at position BSAmpleBN[i] of the secret image b: bb, bg, br;
[0071] S72, extract the high 4 bits of the secret image b's three-channel BGR pixel values: bb1, bg1, br1, using the following formula:
[0072] bb1=bb&0xF0>>4
[0073] bg1 = bg & 0xF0 >> 4
[0074] br1=br&0xF0>>4
[0075] S73, extract the BGR three-channel pixel values of carrier image a at position ASampleBN[i*2]: ab1, ag1, ar1;
[0076] S74, embeds the high 4 bits of the secret image's BGR three-channel pixel values into the lower 4 bits of the carrier image a, with the specific formula as follows:
[0077] ab1 = ab1 & 0xF0 | bb1
[0078] ag1 = ag1 & 0xF0 | bg1
[0079] ar1 = ar1 & 0xF0 | br1
[0080] S75, update the BGR three-channel pixel value of carrier image a at position ASampleBN[i*2], the specific formula is as follows:
[0081] a[ASampleBN[i*2]]=[ab1,ag1,ar1]
[0082] S76, extract the lower 4 bits of the secret image b's three-channel BGR pixel values: bb2, bg2, br2, using the following formula:
[0083] bb2 = bb & 0x0F
[0084] bg2 = bg & 0x0F
[0085] br2 = br & 0x0F
[0086] S77, extract the BGR three-channel pixel values of carrier image a at position ASampleBN[i*2+1]: ab2, ag2, ar2;
[0087] S78, embed the lower 4 bits of the secret image's BGR three-channel pixel values into the lower 4 bits of the carrier image a, using the following formula:
[0088] ab2 = ab2 & 0xF0 | bb2
[0089] ag2 = ag2 & 0xF0 | bg2
[0090] ar2 = ar2 & 0xF0 | br2
[0091] S79, update the BGR three-channel pixel value of carrier image a at position ASampleBN[i*2+1], the specific formula is as follows:
[0092] a[ASampleBN[i*2+1]]=[ab2,ag2,ar2]
[0093] S8 increments the loop variable i by 1. If the value of i is less than bn, S7 is executed again until the value of i is greater than or equal to bn, at which point the loop ends. After the above loop is completed, a complete steganographic image is generated.
[0094] See Figure 1 and Figure 3 The specific method for extracting secret images is as follows:
[0095] S9, the receiver receives the steganographic image and obtains the key that comes with the image;
[0096] S10, see S10. Figure 5 The process of extracting the width and height of the secret image from the key key includes: extracting 16 characters key16 from the end of the key key, decoding it using base64 to generate the original text, and dividing the original text into two parts using commas as separators. The first part is the width value bw of the secret image, and the second part is the height value bh of the secret image.
[0097] Furthermore, S10 is illustrated by an example. Suppose the key of the secret image is: "Et3f8D8GIB1MPkrGvmXVPjK5tMkeG3MiMEVmCkpMEGhxSPj6MDAzMjAsMDAzMTY=", then;
[0098] key16 = "MDAzMjAsMDAzMTY = "
[0099] key11 = base64decode(key16)
[0100] ="00320,00316"
[0101] bw=320
[0102] bh = 316
[0103] S11, Read the steganalysis image a, obtain the height ah and width aw of the steganalysis image, and calculate the number of pixels an:
[0104] an = ah × aw;
[0105] S12, calculate the number of pixels bn based on the height bh and width bw of the secret image:
[0106] bn = bh × bw;
[0107] S13, restore the embedding position of the secret image pixels in the carrier image. Specifically, generate a sequence of all integers contained in the interval [0, an). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample 2xbn elements from the an elements in the above interval, generating a sorted list of pseudo-random sample tuples ASampleBN with 2xbn unique elements. This list stores the embedding position of the secret information in the carrier image. The specific formula is as follows:
[0108]
[0109] S14, Decode the secret image and restore the actual positions of the secret image pixels. Specifically, generate a sequence of all integers contained in the interval [0, bn). Using the key as the seed, employ a pseudo-random number generation algorithm to randomly sample bn elements from the bn elements in the above interval, generating a list of pseudo-random number sample tuples BSampleBN with bn unique elements. This list stores the actual pixel positions of the secret image. The specific formula is as follows:
[0110]
[0111] S15, prepare to extract secret information, generate a secret image zero matrix b with dimension (bn,3), and set the loop variable i to 0;
[0112] S16, this step is crucial for extracting the secret information. Since a pixel value in the secret image is 8 bits, and the carrier image uses the lower 4 bits of each pixel to store embedded information, it's necessary to extract information from two embedding positions in the carrier image and combine them to generate a pixel value for the secret image. Specifically: From the ASampleBN[i*2]th embedding position in the carrier image, extract the lower 4 bits (alow_b1,alow_g1,alow_r1) of the BGR three-channel pixel values ab1, ag1, ar1. Then, from the ASampleBN[i*2+1]th embedding position in the carrier image, extract the lower 4 bits (alow_b2,alow_g2,alow_r2) of the BGR three-channel pixel values ab2, ag2, ar2. Left-shift abow_b1, abow_g1, abow_r1 by 4 bits and perform an OR operation with abow_b2, abow_g2, abow_r2 to obtain the actual pixel values of the secret image: bb, bg, br. Write the three-channel pixel values bb, bg, br of BGR to the corresponding position BSAmpleBN[i] in the secret image b.
[0113] Furthermore, S16 specifically includes:
[0114] S161. Extract the lower 4 bits of the BGR three-channel pixel values ab1, ag1, ar1 at position ASampleBN[i*2] of the carrier image a: alow_b1, alow_g1, alow_r1. The specific formula is as follows:
[0115] alow_b1 = ab1 & 0x0F
[0116] alow_g1 = ag1 & 0x0F
[0117] alow_r1 = ar1 & 0x0F
[0118] S162. Extract the lower 4 bits (alow_b2,alow_g2,alow_r2) of the BGR three-channel pixel values ab2,ag2,ar2 at position ASampleBN[i*2+1] of the carrier image a. The specific formula is as follows:
[0119] alow_b2=ab2&0x0F
[0120] alow_g2=ag2&0x0F
[0121] alow_r2 = ar2 & 0x0F
[0122] S163. Left-shift alow_b1, alow_g1, alow_r1 by 4 bits and perform an OR operation with alow_b2, alow_g2, alow_r2 to obtain the actual pixel values of the secret image: bb, bg, br. The specific formula is as follows:
[0123] bb=(alow_b1<<4)|alow_b2
[0124] bg = (alow_g1 << 4) | alow_g2
[0125] br = (alow_r1<<4)|alow_r2
[0126] S164. Update the BGR three-channel pixel value of the secret image b at position BSampleBN[i], using the following formula:
[0127] b[BSampleBN[i]] = [bb, bg, br]
[0128] S17: Increment the loop variable i by 1. If the value of i is less than twice bn, execute S16 repeatedly until the value of i is greater than or equal to twice bn.
[0129] S18, convert the dimensions of the secret image matrix b to (bh, bw, 3), and the secret image is thus extracted.
[0130] Example 2
[0131] See Figure 1 and Figure 2 This invention provides a lossless secret image steganography method based on random spatial distribution in the image domain, comprising the following steps:
[0132] S1, Select an image as the carrier image, read the carrier image a, obtain the height ah and width aw of the carrier image, and calculate the number of pixels an:
[0133] an = ah × aw;
[0134] S2, select an image as the secret image to be embedded into the carrier image. This secret image is the information to be transmitted. The total number of pixels in this image should be less than or equal to half the total number of pixels in the carrier image. Read the secret image b, obtain its height bh and width bw, and calculate the number of pixels bn.
[0135] bn = bh × bw;
[0136] S3, see S3. Figure 4This step aims to generate a key for steganography encryption and secret image extraction. Specifically, it involves: randomly selecting 48 characters from 52 uppercase and lowercase letters and 10 digits to generate a 48-byte string, key48. Then, concatenating the width (bw), commas, and height (bh) of the secret image into an 11-byte string, key11, with each dimension occupying 5 characters (padded with leading zeros if necessary). Next, base64 encoding key11 generates a 16-byte string, key16. Finally, concatenating key48 and key16 forms the key, which is a 64-byte string.
[0137] Furthermore, S3 is illustrated with an example. Assuming the width and height of the secret image are 320 and 316 respectively, then:
[0138] key11 = "00320,00316"
[0139] key16 = base64encode(key11)
[0140] ="MDAzMjAsMDAzMTY="
[0141] key48="Et3f8D8GIB1MPkrGvmXVPjK5tMkeG3MiMEVmCkpMEGhxSPj6"
[0142] key = key48 + key16
[0143] ="Et3f8D8GIB1MPkrGvmXVPjK5tMkeG3MiMEVmCkpMEGhxSPj6MDAzMjAsMDAzMTY="
[0144] S4, generate the embedding positions of the secret image pixels in the carrier image that are randomly and uniformly distributed. Specifically, generate a sequence of all integers contained in the interval [0, an). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample 2xbn elements from the above interval an elements to generate a sorted list of pseudo-random sample tuples ASampleBN with 2xbn unique elements. This list stores the embedding positions of the secret information in the carrier image, and the specific formula is:
[0145]
[0146] S5 re-encodes the secret image by randomly shuffling the pixel positions. Specifically, it generates a sequence of all integers within the interval [0, bn). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample bn elements from the bn elements in the above interval, generating a list of pseudo-random number sample tuples BSampleBN with bn unique elements. This list stores the new positions of the secret image pixels after random sampling. The specific formula is as follows:
[0147]
[0148] S6, prepare to embed information, set the loop variable i to 0;
[0149] S7, this step is the key step for embedding secret information. Because a pixel value of the secret image is 8 bits, while the carrier image uses the lower 4 bits of each pixel to store the embedded information, a pixel value of the secret image needs to be stored using two embedding positions of the carrier image. Specifically: extract the BGR three-channel pixel values: bb, bg, br from the corresponding position BSAmpleBN[i] of the secret image b. At the ASampleBN[i*2]th embedding position of the carrier image, replace the lower 4 bits of the BGR three-channel pixel values ab1, ag1, ar1 of the carrier image with the higher 4 bits of the secret image BGR three-channel pixel values bb, bg, br; at the ASampleBN[i*2+1]th embedding position of the carrier image, replace the lower 4 bits of the BGR three-channel pixel values ab2, ag2, ar2 of the carrier image with the lower 4 bits of the secret image BGR three-channel pixel values bb, bg, br.
[0150] Furthermore, S7 specifically includes:
[0151] S71, extract the three-channel pixel values of BGR at position BSAmpleBN[i] of the secret image b: bb, bg, br;
[0152] S72, extract the high 4 bits of the secret image b's three-channel BGR pixel values: bb1, bg1, br1, using the following formula:
[0153] bb1=bb&0xF0>>4
[0154] bg1 = bg & 0xF0 >> 4
[0155] br1=br&0xF0>>4
[0156] S73, extract the BGR three-channel pixel values of carrier image a at position ASampleBN[i*2]: ab1, ag1, ar1;
[0157] S74, embeds the high 4 bits of the secret image's BGR three-channel pixel values into the lower 4 bits of the carrier image a, with the specific formula as follows:
[0158] ab1 = ab1 & 0xF0 | bb1
[0159] ag1 = ag1 & 0xF0 | bg1
[0160] ar1 = ar1 & 0xF0 | br1
[0161] S75, update the BGR three-channel pixel value of carrier image a at position ASampleBN[i*2], the specific formula is as follows:
[0162] a[ASampleBN[i*2]]=[ab1,ag1,ar1]
[0163] S76, extract the lower 4 bits of the secret image b's three-channel BGR pixel values: bb2, bg2, br2, using the following formula:
[0164] bb2 = bb & 0x0F
[0165] bg2 = bg & 0x0F
[0166] br2 = br & 0x0F
[0167] S77, extract the BGR three-channel pixel values of carrier image a at position ASampleBN[i*2+1]: ab2, ag2, ar2;
[0168] S78, embed the lower 4 bits of the secret image's BGR three-channel pixel values into the lower 4 bits of the carrier image a, using the following formula:
[0169] ab2 = ab2 & 0xF0 | bb2
[0170] ag2 = ag2 & 0xF0 | bg2
[0171] ar2 = ar2 & 0xF0 | br2
[0172] S79, update the BGR three-channel pixel value of carrier image a at position ASampleBN[i*2+1], the specific formula is as follows:
[0173] a[ASampleBN[i*2+1]]=[ab2,ag2,ar2]
[0174] S8 increments the loop variable i by 1. If the value of i is less than bn, S7 is executed again until the value of i is greater than or equal to bn, at which point the loop ends. After the above loop is completed, a complete steganographic image is generated.
[0175] Example 3
[0176] See Figure 1 and Figure 3 This invention provides a lossless method for extracting secret images based on random spatial distribution in the image domain, comprising the following steps:
[0177] S9, the receiver receives the steganographic image and obtains the key that comes with the image;
[0178] S10, see S10. Figure 5 The process of extracting the width and height of the secret image from the key key includes: extracting 16 characters key16 from the end of the key key, decoding it using base64 to generate the original text, and dividing the original text into two parts using commas as separators. The first part is the width value bw of the secret image, and the second part is the height value bh of the secret image.
[0179] Furthermore, S10 is illustrated with an example. Assume the key of the secret image is: "Et3f8D8GIB1MPkrGvmXVPjK5tMkeG3MiMEVmCkpMEGhxSPj6MDAzMjAsMDAzMTY=", then;
[0180] key16 = "MDAzMjAsMDAzMTY = "
[0181] key11 = base64decode(key16)
[0182] ="00320,00316"
[0183] bw=320
[0184] bh = 316
[0185] S11, Read the steganalysis image a, obtain the height ah and width aw of the steganalysis image, and calculate the number of pixels an:
[0186] an = ah × aw;
[0187] S12, calculate the number of pixels bn based on the height bh and width bw of the secret image:
[0188] bn = bh × bw;
[0189] S13, restore the embedding position of the secret image pixels in the carrier image. Specifically, generate a sequence of all integers contained in the interval [0, an). Using the key as the seed, a pseudo-random number generation algorithm is used to randomly sample 2xbn elements from the an elements in the above interval, generating a sorted list of pseudo-random sample tuples ASampleBN with 2xbn unique elements. This list stores the embedding position of the secret information in the carrier image. The specific formula is as follows:
[0190]
[0191] S14, Decode the secret image and restore the actual positions of the secret image pixels. Specifically, generate a sequence of all integers contained in the interval [0, bn). Using the key as the seed, employ a pseudo-random number generation algorithm to randomly sample bn elements from the bn elements in the above interval, generating a list of pseudo-random number sample tuples BSampleBN with bn unique elements. This list stores the actual pixel positions of the secret image. The specific formula is as follows:
[0192]
[0193] S15, prepare to extract secret information, generate a secret image zero matrix b with dimension (bn,3), and set the loop variable i to 0;
[0194] S16, this step is crucial for extracting the secret information. Since a pixel value in the secret image is 8 bits, and the carrier image uses the lower 4 bits of each pixel to store embedded information, it's necessary to extract information from two embedding positions in the carrier image and combine them to generate a pixel value for the secret image. Specifically: From the ASampleBN[i*2]th embedding position in the carrier image, extract the lower 4 bits (alow_b1,alow_g1,alow_r1) of the BGR three-channel pixel values ab1, ag1, ar1. Then, from the ASampleBN[i*2+1]th embedding position in the carrier image, extract the lower 4 bits (alow_b2,alow_g2,alow_r2) of the BGR three-channel pixel values ab2, ag2, ar2. Left-shift abow_b1, abow_g1, abow_r1 by 4 bits and perform an OR operation with abow_b2, abow_g2, abow_r2 to obtain the actual pixel values of the secret image: bb, bg, br. Write the three-channel pixel values bb, bg, br of BGR to the corresponding position BSAmpleBN[i] in the secret image b.
[0195] Furthermore, S16 specifically includes:
[0196] S161. Extract the lower 4 bits of the BGR three-channel pixel values ab1, ag1, ar1 at position ASampleBN[i*2] of the carrier image a: alow_b1, alow_g1, alow_r1. The specific formula is as follows:
[0197] alow_b1 = ab1 & 0x0F
[0198] alow_g1 = ag1 & 0x0F
[0199] alow_r1 = ar1 & 0x0F
[0200] S162. Extract the lower 4 bits (alow_b2,alow_g2,alow_r2) of the BGR three-channel pixel values ab2,ag2,ar2 at position ASampleBN[i*2+1] of the carrier image a. The specific formula is as follows:
[0201] alow_b2=ab2&0x0F
[0202] alow_g2=ag2&0x0F
[0203] alow_r2 = ar2 & 0x0F
[0204] S163. Left-shift alow_b1, alow_g1, alow_r1 by 4 bits and perform an OR operation with alow_b2, alow_g2, alow_r2 to obtain the actual pixel values of the secret image: bb, bg, br. The specific formula is as follows:
[0205] bb=(alow_b1<<4)|alow_b2
[0206] bg = (alow_g1 << 4) | alow_g2
[0207] br = (alow_r1<<4)|alow_r2
[0208] S164. Update the BGR three-channel pixel value of the secret image b at position BSampleBN[i], using the following formula:
[0209] b[BSampleBN[i]] = [bb, bg, br]
[0210] S17: Increment the loop variable i by 1. If the value of i is less than twice bn, execute S16 repeatedly until the value of i is greater than or equal to twice bn.
[0211] S18, convert the dimensions of the secret image matrix b to (bh, bw, 3), and the secret image is thus extracted.
[0212] Test Experiment
[0213] Verification tests and analysis for this invention: The purpose of the experiment was to evaluate the performance of the algorithm in this invention. The algorithm was implemented using Python 3.7, and the operating environment was: processor (Intel(R)core(TM) i7-4500U 1.8GHz), memory (8GB RAM), and operating system (Windows 10 64-bit).
[0214] All images used are from the ImageNet ILSVRC2012 dataset. A 1024x768 color image file, ILSVRC2012_val_00038529.JPEG, was randomly selected as the carrier image. (See attached image.) Figure 7 Four color images (ILSVRC2012_val_00020125.JPEG (200x198), ILSVRC2012_val_00032277.JPEG (320x316), ILSVRC2012_val_00029416.JPEG (249x300), ILSVRC2012_val_00048109.JPEG (200x300)) were extracted as secret images (see...). Figure 8 The steganography algorithm of this invention is used to embed four secret images into a carrier image, forming four steganographic images (see...). Figure 9 Visually comparing the stegana and the carrier image reveals no difference to the human eye, indicating that the stegana is difficult to detect. Histogram comparisons of the carrier and stegana further demonstrate this. Figure 11 As can be seen, the overall differences are not significant, with only minor local differences. The extracted secret image ( Figure 10 ) and the original secret image ( Figure 8 A pixel-by-pixel comparison was performed, and all differences were zero, indicating that the two secret images are completely identical without any loss. Actual testing showed a processing speed of 1.5 seconds per image under the aforementioned CPU environment.
[0215] In the description of this invention, the foregoing detailed description has illustrated various embodiments of the apparatus and / or processes using block diagrams, flowcharts, and / or examples. To the extent that such block diagrams, flowcharts, and / or examples contain one or more functions and / or operations, those skilled in the art will understand that each function and / or operation within such block diagrams, flowcharts, or examples can be implemented individually and / or collectively by a great many different hardware, software, firmware, or virtually any combination thereof.
[0216] There is little difference between the hardware and software implementations of various aspects of the system; the use of hardware or software is often (but not always, as the choice between hardware and software may become important in some situations) a design choice representing a trade-off between cost and efficiency. Various means (e.g., hardware, software, and / or firmware) by which the processes and / or systems and / or other technologies described herein can be implemented exist, and preferred means will vary depending on the context in which the processes and / or systems and / or other technologies are deployed. For example, if the implementer determines that speed and accuracy are extremely important, then the implementer may choose a primarily hardware and / or firmware approach; if flexibility is extremely important, then the implementer may choose a primarily software implementation; or, but equally alternatively, the implementer may choose a combination of hardware, software, and / or firmware.
[0217] The terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0218] The technical features of this invention not described can be implemented by or using existing technology, and will not be repeated here. Of course, the above description is not a limitation of this invention, and this invention is not limited to the examples above. Any changes, modifications, additions or substitutions made by those skilled in the art within the scope of this invention should also be within the protection scope of this invention.
[0219] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "setting" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0220] 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 principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for lossless steganography and extraction of secret images based on random spatial distribution in the image domain, characterized in that, This includes methods for steganography and lossless extraction of images; The secret image steganography method includes the following steps: E-S1. Select an image as the carrier image a, read the carrier image a, obtain the height ah and width aw of the carrier image a, and calculate the number of pixels an; E-S2. Select an image as a secret image b to be embedded into the carrier image a. The total number of pixels in the secret image b is less than or equal to half the total number of pixels in the carrier image a. Read the secret image b and obtain its height bh and width bw. Calculate the number of pixels bn. E-S3: Generate a key to encrypt the secret image b; E-S4, Generate the embedding positions of the secret image b pixels randomly and uniformly distributed in the carrier image a; E-S5 re-encodes the secret image by randomly shuffling the pixel positions of the secret image; E-S6: The pixels of the re-encoded secret image are sequentially embedded into the embedding positions of the carrier image a to generate a complete steganalysis image; Step E-S3 includes: 48 characters are randomly selected from 52 uppercase and lowercase letters and 10 numbers to generate a 48-byte string key48; the width bw, commas, and height bh of the secret image b are concatenated to form an 11-byte string key11, where the width and height each occupy 5 bits, and leading zeros are added if less than 5 bits; key11 is then base64 encoded to generate a 16-byte string key16; finally, key48 and key16 are concatenated to form the key, which is a 64-byte string. Step E-S6 includes: E-S601, Prepare the embedded information, set the loop variable i to 0; E-S602, Extract the three-channel pixel values of BGR from the corresponding position BSAmpleBN[i] of the secret image b: bb, bg, br; E-S603. At the ASampleBN[i*2]th embedding position of the carrier image a, replace the low 4 bits of the three-channel pixel values ab1, ag1, ar1 of the carrier image BGR with the high 4 bits of the three-channel pixel values bb, bg, br of the secret image BGR. E-S604. At the ASampleBN[i*2+1]th embedding position of the carrier image a, replace the lower 4 bits of the three-channel pixel values ab2, ag2, ar2 of the carrier image BGR with the lower 4 bits of the three-channel pixel values bb, bg, br of the secret image BGR. E-S605: Increment the loop variable i by 1. If the value of i is less than bn, repeat steps E-S602-E-S604 until the value of i is greater than or equal to bn and the loop ends. After the above loop is completed, a complete steganographic image is generated.
2. The method according to claim 1, characterized in that, Step E-S4 includes: generating a sequence of all integers contained in the interval [0, an); using the key key as a seed, and employing a pseudo-random number generation algorithm, randomly sampling 2 times bn elements from the above interval an elements to generate a sorted list of pseudo-random number sample tuples ASampleBN with 2 times bn non-repeating elements, which stores the embedding position of the secret information pixel in the carrier image a.
3. The method according to claim 1, characterized in that, Step E-S5 includes: generating a sequence of all integers contained in the interval [0, bn), using the key as the seed, employing a pseudo-random number generation algorithm, randomly sampling bn elements from the bn elements in the above interval, and generating a pseudo-random number sample tuple list BSPangleBN with bn non-repeating elements. This list stores the new positions of the secret image pixels after random sampling.
4. The method according to claim 1, characterized in that, The method for non-destructive extraction of secret images includes the following steps: D-S1: The receiver receives the steganographic image and obtains the key that comes with the steganographic image. D-S2, extract the width and height of the secret image from the key; D-S3: Read the steg image, obtain the height ah and width aw of the steg image, and calculate the number of pixels an. D-S4: Calculate the number of pixels bn based on the height bh and width bw of the secret image; D-S5, restores the embedding position of the secret image pixels in the carrier image; D-S6 decodes the secret image and restores the actual position of the secret image pixels; D-S7: Extract the embedding positions of the carrier image pixels from the two embedding positions of the carrier image, combine them to generate a pixel value of the secret image, and then arrange them according to the actual positions of the secret image pixels to extract the complete secret image.
5. The method according to claim 1, characterized in that, The D-S2 step includes: specifically, extracting 16 characters key16 from the end of the key, decoding it using base64 to generate the original text, and dividing the original text into two segments using commas as separators. The first segment is the width value bw of the secret image, and the second segment is the height value bh of the secret image.
6. The method according to claim 1, characterized in that, Step D-S5 includes: specifically, generating a sequence of all integers contained in the interval [0, an), using the key as the seed, and employing a pseudo-random number generation algorithm to randomly sample 2 times bn elements from the above interval an elements, generating a sorted list of pseudo-random sample tuples ASampleBN with 2 times bn non-repeating elements, which stores the embedding positions of the secret image pixels in the carrier image.
7. The method according to claim 1, characterized in that, Step D-S6 includes: specifically, generating a sequence of all integers contained in the interval [0, bn), using the key as the seed, employing a pseudo-random number generation algorithm, randomly sampling bn elements from the bn elements in the above interval, and generating a pseudo-random number sample tuple list BSPangleBN with bn non-repeating elements, which stores the actual pixel arrangement positions of the secret image.
8. The method according to claim 1, characterized in that, Step D-S7 includes: D-S701. Prepare to extract secret information, generate a secret image zero matrix b with dimension (bn,3), and set the loop variable i to 0; D-S702. Extract the lower 4 bits alow_b1, alow_g1, alow_r1 of the BGR three-channel pixel values ab1, ag1, ar1 from the ASampleBN[i*2]th embedding position of the carrier image; D-S703. Extract the lower 4 bits of the BGR three-channel pixel values ab2, ag2, ar2 from the ASampleBN[i*2+1]th embedding position of the carrier image: alow_b2, alow_g2, alow_r2. D-S704, shift aow_b1, aow_g1, aow_r1 left by 4 bits and OR them with aow_b2, aow_g2, aow_r2 to obtain the actual pixel values of the secret image: bb, bg, br. Write the three-channel pixel values bb, bg, br into the corresponding position BSAmpleBN[i] of the secret image b. D-S705. The loop variable i is incremented by 1. If the value of i is less than twice bn, then the loop executes steps D-S702-D-S704 repeatedly until the value of i is greater than or equal to twice bn and the loop ends. D-S706. Convert the dimensions of the secret image matrix b to (bh, bw, 3). At this point, the secret image is extracted.