## 2 Methods
### Embedder and Decoder  
The main purpose of the embedder is to embed a binary watermark with a size of H \(\times\) W into a grayscale image. The embedding method uses the simplest and most well-known LSB substitution method and randomly generates a set of secret keys with a size of H \(\times\) W pixels, and each value ranges from 1-4, where each of these values can be used to specify that each secret bit of information is hidden in the LSB position of the grayscale image pixel value. To explain the embedding algorithm in more detail, we define the following symbols. Original image \(I=\{p_{1},p,\ldots,p_{n}|0\leq p_{i}\leq 255,p_{i}\in N\}\), Secret key \(K=\{k_{1},k_{2},\ldots,k_{n}|k_{i}\in\{1,2,3,4\}\}\), Watermark bit \(M=\{m_{1},m_{2},\ldots,m_{n}|m_{i}\in\{0,1\}\}\), where \(n\) is the number of pixels in the image, which is \(H\times W\). This simplicity enableseffective watermarking without compromising pixel values, which is crucial to an image's quality. The detailed algorithm process is as follows:  
1. Convert each pixel value \(p_{i}\) of the original image into a binary value \(b_{i}\). 2. The secret key value \(k_{i}\) indicates that the watermark bit \(m_{i}\) is embedded in the position of the \(k_{i}\)th least significant bit (LSB) of the binary pixel value \(b_{i}\) by LSB substitution to obtain a new binary value \(b_{i}^{\prime}\). 3. Convert the binary value \(b_{i}^{\prime}\) to the decimal value \(p_{i}^{\prime}\), which is the pixel value after embedding the watermark bits. 4. Repeat steps 1 to 3 until the entire image is processed, and the image \(I^{\prime}\) embedded with the watermark is obtained. An example is shown in Figure 5 to illustrate the detailed embedding method. Assuming an original grayscale image with a size of \(4\times 4\) pixels, the length of a secret message is 16 bits \"11111 1111 0011\". Suppose there is a secret key generated by random numbers, its size is also 16 values, and the value range is {1, 2, 3, 4}. The first pixel value in the upper-left corner of the original grayscale image is 202, which can be converted into a binary 8-bit \"11001010\". The value of the first secret key in Figure 5 is 6, indicating that a secret bit of information can be embedded in the third LSB of the corresponding pixel value. Therefore, after embedding the secret bit 1 in the corresponding position, the binary representation of the new pixel value is \"11001110\", which is converted to 206 in decimals. The above steps are repeated until the entire grayscale image is processed, and the image with the embedded watermark can be obtained. The main purpose of the decoder is to extract a binary image with a size of \(H\times W\) from a JPEG-compressed grayscale image. Because the grayscale image is compressed by JPEG, the previously embedded watermark has been destroyed. The extraction method follows the LSB substitution method. The decoder and the embedder share the same secret key, which can be used as a basis for extracting the secret message. To explain the decoder algorithm in more detail, we have defined the following symbols. Given the input JPEG image \(C=(c_{1},c_{2},\ldots,c_{n}|0\leq c_{i}\leq 255,c_{i}\in N)\), and the secret key \(K=\{k_{1},k_{2},\ldots,k_{n}|k_{i}\in\{1,2,3,4\}\}\), where \(n=H\times W\), the decoding process first converts the pixel value \(c_{i}\) of the input image into a binary value \(b_{i}\) and then extracts the bit \(m_{i}\) which is the \(k_{i}\)th LSB of the value \(b_{i}\). This is repeated to process the entire image until the decoded image is obtained. An example is shown in Figure 6 to illustrate the detailed extraction method. Figure 5: Example of embedder. Suppose a compressed grayscale image with a size of \(4\times 4\) and the same secret key is used as the embedding process, the secret key size is 16 values, and the range of values is [1, 2, 3, 4]. The value of the first pixel in the upper-left corner of the grayscale image is 215, which can be converted into a binary 8-bit \"11010111\".