Keywords

1 Introduction

In order to protect the integrity and authenticity of image, this paper proposes a new semi-fragile digital watermarking algorithm based on the literature [1, 2], which is used for image content integrity authentication, and according to the algorithm [3], we change our method for better effect.

In this chapter, we propose the related work of our method. We shall study the related work and change some parts of them to suit for our algorithm preferably [4].

1.1 Torus Automorphism Mapping

Torus isomorphic mapping is a typical chaotic map. In this method, a point is mapped to another different point, and for each point there is only one corresponding mapping point.

$$\begin{aligned} \left[ \begin{array}{ccc} x_{n+1}\\ y_{n+1} \end{array} \right] =A\times { \left[ \begin{array}{ccc} x_{n}\\ y_{n} \end{array} \right] }\pmod N \end{aligned}$$
(1)

A is a matrix of \(2\times {2}\), like \(\left[ \begin{array}{ccc}a &{} b\\ c&{}d\\ \end{array}\right] \) and \(\det A=1\).

In this paper, we use this for the selection of watermark embedded position. Since the sequence of image blocks is a one-dimensional sequence, the Torus mapping is transformed into a one-dimensional transformation formula.

$$\begin{aligned} X^{'} = f(X) = (k \times {X})\bmod N + 1 \end{aligned}$$
(2)

\(X,X^{'} (\in [1,N])\) are respectively the current serial number and the mapping number; \(k (\in [0,N - 1])\) must be a prime number and belong to a private key; \(N( \in Z - \{ 0\} )\) is the total number.

1.2 Arnold Image Scrambling Algorithm

Arnold Scrambling is proposed by Russian mathematician Vladimir l. Arnold, also known as cat face transformation. Arnold scrambling has a periodicity, and after multiple transformations, the image will become very chaotic, but after specific transformations, re-transformed into the initial image. Such transformation can be used as image encryption [9].

In Arnold scrambling, the image is digitized into a matrix, and the rows and columns of its elements correspond to the values of the arguments, and the values of the elements represent image information. The position \((x',y')\) of the matrix in one transformation is

$$\begin{aligned} \left[ \begin{array}{ccc} x'\\ y' \end{array} \right] =\left[ \begin{array}{ccc} 1 &{} 1\\ 1 &{} 2 \end{array} \right] \times { \left[ \begin{array}{ccc} x\\ y \end{array} \right] } \pmod N \end{aligned}$$
(3)

\(x,y \in \{ 0,1,2, \cdots ,N - 1\}\) indicates the position of the pixel before transformation. Digital images can be seen as a two-dimensional matrix, and after Arnold transformation, the pixel position will be rearranged, so the image will appear chaotic to achieve the effect of scrambling encryption.

2 Proposed Method

In this paper, based on the literature [1, 5], our algorithm is proposed for hierarchical tamper localization and restoration, which can be applied to both plain-image and scrambling images. Wherein tamper localization is based on the three-layer detection [1], and the effective recovery depends on the pixel information embedded in the Torus mapping block. The three-layer localization is carried out directly on the plain-image, and the tamper of the scrambling image can be detected on the cloud side, and we can decrypt the result and carry on the secondary detection for a better effect. The following sections describe the process of the watermark embedding, plain-image tamper detection, confused image tamper localization and recovery [6, 8].

2.1 Based on Block Watermark Embedding

In this section, the original image is preprocessed to generate the watermark, and the watermark is embedded according to the Torus automorphism mapping. The watermark is embedded in the lowest 2 bits of each pixel.

2.1.1 Pretreatment

Assuming the original image I is 256 gray levels, its size is \(M\times {M}\), where M is a multiple of 2. The image is segmented and the block mapping sequence \(A\rightarrow B \rightarrow C \rightarrow D \rightarrow \ldots \rightarrow A\) is obtained by the Torus automorphism transformation. Each letter in the sequence represents a separate block. That means the pixel value of block A is embedded in block B, the pixel value of block B is embedded in block C, and so on.

Firstly, we divide the image I into \(2\times {2}\) blocks and number them. Secondly, calculate their Torus mapping blocks.

2.1.2 Watermark Generation and Embedding

Assuming A and B are a pair of Torus automorphism mapping blocks in the image I.

The watermark of the image block B is represented by an array(vpr), where vp are one bit, and r is 6 bits determined by the pixel value of A. The generation of watermark and the embedding process are as follows:

\(Step\ 1:\) The 2-bit LSB of the pixels of B is set to zero.

\(Step\ 2:\) Generates authentication watermark v of the block B.

$$\begin{aligned} v = \left\{ {\begin{array}{*{20}{c}} {\begin{array}{*{20}{c}} 1&{}{{B_{14}} > {B_{23}}} \end{array}}\\ {\begin{array}{*{20}{c}} 0&{}{{B_{14}} \le {B_{23}}} \end{array}} \end{array}} \right. \end{aligned}$$
(4)

\(Step\ 3:\) Calculate the 6 bit MSB average \(B_{avg}\) of image block B.

\(Step\ 4:\) Calculate the quantity N of 1 in \(B_{avg}\), and the parity watermark p.

$$\begin{aligned} p = \left\{ {\begin{array}{*{20}{c}} 1&{}{N \rightarrow Even}\\ 0&{}{N \rightarrow Odd} \end{array}} \right. \end{aligned}$$
(5)

\(Step\ 5:\) The average \(A_{avg}\) of the 6 bit MSB of the image block A is as the recovery watermark r.

\(Step\ 6:\) The watermark (vpr) are composed of 8 bits, and then embedded into the 8-bit LSB of the four pixels of the image block B.

Repeat the above steps (1) to (6) for the other blocks, obtain the embedded image \(I'\).

2.2 Arnold Transformation

Divide the embedded image \(I'\) into \(2\times {2}\) image blocks, and take the image block A for an example.

\(Step\ 1:\) The coordinate of the first pixel point of the block A are \((x_A,y_A)\), and the other coordinates are calculated as \((x_A,y_A+1),(x_A+1,y_A),(x_A+1,y_A+1)\).

\(Step\ 2:\) Assume the private key is (abN), and after Arnold transformation, the coordinate \((x_A,y_A)\) is converted to \(({x_A}^{'},{y_A}^{'})\).

$$\begin{aligned} \left[ \begin{array}{ccc} {x_A}^{'}\\ {y_A}^{'} \end{array} \right] =\left[ \begin{array}{ccc} 1 &{} b\\ a &{} ab+1 \end{array} \right] \left[ \begin{array}{ccc} x_A\\ y_A \end{array} \right] \pmod M \end{aligned}$$
(6)

\(Step\ 3:\) The pixels \((x_A,y_A+1),(x_A+1,y_A),(x_A+1,y_A+1)\) of the block A are respectively converted into \(({x_A}^{'},{y_A}^{'}+1),({x_A}^{'}+1,{y_A}^{'}),({x_A}^{'}+1,{y_A}^{'}+1)\).

The Arnold scrambling image \(I'_{arnold}\) can be obtained by repeating the above steps (1) to (3) on other image blocks.

2.3 Tamper Detection

2.3.1 Tamper Detection of Plain-Images

The tampered image \(I'_w\) is detected in three layers. In the first layer, we detect the \(2\times {2}\) image blocks. And in the second layer, we mark the independent \(4\times {4}\) blocks that has more than one marked \(2\times {2}\) block. In the third layer, mark the independent blocks according to the surrounding image blocks.

In the first detection, the image \(I'_w\) is divided into independent \(2\times {2}\) image blocks. Take the block \(B'\) as an example and the specific steps are as follows:

\(Step\ 1:\) The watermark (vp) in the image block \(B'\) is extracted according to the embedding rules.

\(Step\ 2:\) Set the 2 bit LSB of the pixels of \(B'\) to 0, and calculate the average pixel value \(B'_{avg}\) of \(B'\).

\(Step\ 3:\) Calculate the quantity \(N'\) of 1 in \(B'_{avg}\) and the parity code \(p'\).

\(Step\ 4:\) If \(p'=p\), the image block \(B'\) is authenticated, otherwise the image block is marked.

\(Step\ 5:\) When the parity code \(p'\) is verified, the image block \(B'\) is evaluated for the watermark \(v'\).

\(Step\ 6:\) If \(v'=v\), the image block \(B'\) is authenticated, otherwise the image block \(B'\) is marked.

Repeat the above steps (1) to (6) for other image blocks of \(I'_w\), and the detection result \(I_{locate}\) is acquired.

In the second detection, the localization image \(I_{locate}\) is divided into independent \(4\times {4}\) image blocks and each individual image block is divided into four \(2\times {2}\) image blocks. And mark each individual \(4\times {4}\) image block that has more than one marked \(2\times {2}\) block, and finally obtain the second localization image \(I'_{locate}\).

In the third detection, the second localization image \(I'_{locate}\) is divided into non-overlapping \(4\times {4}\) image blocks, and as shown in Fig. 1, the image block is marked where there are more than five marked image blocks of the eight surrounding blocks. After that, we get the final localization image \(I''_{locate}\).

Fig. 1.
figure 1

Secondary tampering localization image block

2.3.2 Tamper Detection of Scrambled Images

Assume the scrambled image \(I'_{Arnold}\) requires tamper detection in an unsafe third party, the insecure cloud detection system is \(A_{cloud}\), and the local security detection system is \(B_{locate}\), then the first layer of the confused image is detected in the cloud detection system. \(A_{cloud}\) send detection results to the local security detection system for 2, 3 layer detection. The specific steps are as follows:

\(Step\ 1:\) At the cloud system, calculate the localization image \(I_{locate}^{cloud}\) like Sect. 2.3.1.

\(Step\ 2:\) In the local detection system, use the private key to decrypt \(I_{locate}^{cloud}\) to get the localization image \(I_{locate}^{location}\).

\(Step\ 3:\) In the second detection, the localization image \(I_{locate}^{location}\) is divided into independent \(4\times {4}\) image blocks and it is detected whether there is a marked independent \(2\times {2}\) image block in each individual \(4\times {4}\) image block. And finally get the second localization image \({I'}_{locate}^{location}\)

\(Step\ 4:\) In the third detection, the localization image \({I'}_{locate}^{location}\) is divided into \(4\times {4}\) image blocks. Mark the image block where there are more than five marked surrounding image blocks, and finally get the localization image \({I''}_{locate}^{location}\).

2.4 Tampering Recovery

After the above tamper detection, we need to recover the image. So assume the image block \(B'\) has a tamper mark, and take \(B'\) for an example.

\(Step\ 1:\) The image block \(C^{'}\) is calculated according to the key k of the Torus transformation.

\(Step\ 2:\) If the image block \(C^{'}\) is not marked with tamper, extract the recovery watermark r, shift r left twice, and get \(r'\) to recover the image block \(B'\).

\(Step\ 3:\) The pixel value of the image block \(B^{'}\) is replaced with \(r^{'}\).

\(Step\ 4:\) If the image block \(C'\) has a tamper mark, the image block \(B'\) is re-marked.

Repeat the steps (1) to (4) for all the image blocks, and finally obtain the recovery image \(I_{recover}\). Because there are some image blocks that are not recovered, preform the following operations.

\(Step\ 1:\) Calculate the average \(B'_{surroud}\) of the surrounding recovered image blocks around the image block \(B'\)

\(Step\ 2:\) Recover the image block \(B'\) according to \(B'_{surround}\).

The above operations (1) to (2) are performed for each unrecovered image blocks to obtain the final recovery image \(I'_{recover}\).

3 Results and Analysis

In this paper, the gray images Peppers, Lena, Plane, Baboon are used as test images. The peak signal to noise ratio and the structure similarity of the image are used to measure the ability of localization and recovery [7].

3.1 Peak Signal-to-Noise Ratio and Image Structure Similarity

3.1.1 Peak Signal-to-Noise Ratio

Assume the images are the reference image f and the test image g, whose size is \(M\times {N}\), the calculation formula between f and g is as follows.

$$\begin{aligned} MSE(f,g) = \frac{1}{{MN}}\sum \limits _{i = 1}^M {\sum \limits _{j = 1}^N {{{({f_{ij}} - g_{ij}^{})}^2}}} \end{aligned}$$
(7)
$$\begin{aligned} PSNR(f,g) = 10{\log _{10}}({255^2}/MSE(f,g)) \end{aligned}$$
(8)

When MSE approaches zero, the PSNR is near infinity, that indicates higher PSNR provides higher image quality. The peak signal-to-noise ratio can reflect the mean square error between the watermark image and the original image. The larger value shows the smaller difference between the embedded image and the original image.

3.1.2 Image Structure Similarity

Structured similarity is not designed using a traditional error summation method, but by modeling any image distortion as a combination of three factors, which are correlation loss, luminance distortion, and contrast distortion. Assume the images are the reference image f and the test image g whose size is \(M\times {N}\), the formula is as follows.

$$\begin{aligned} \left\{ {\begin{array}{ccc} l(f,g) = \frac{{2{\mu _f}{\mu _g} + {C_1}}}{{\mu _f^2 + \mu _g^2 + {C_1}}}\\ c(f,g) = \frac{{2{\sigma _f}{\sigma _g} + {C_2}}}{{\sigma _f^2 + \sigma _g^2 + {C_2}}}\\ s(f,g) = \frac{{{\sigma _{fg}} + {C_3}}}{{{\sigma _f}{\sigma _g} + {C_3}}} \end{array}} \right. \end{aligned}$$
(9)
$$\begin{aligned} SSIM(f,g) = l(f,g)\times {c(f,g)\times {s(f,g)}} \end{aligned}$$
(10)

\(\mu _f\), \(\mu _g\) are the average of the reference image f and the test image g, \(\sigma _f\), \(\sigma _g\) stand for their standard deviation, \(\sigma _f^2\), \(\sigma _g^2\) are their variance, \(\sigma _{fg}\) is the covariance. In order to avoid the above formula denominator to 0, \(C_1\), \(C_2\) and \(C_3\) are constants. In general, \({C_1} = {({K_1} \times L)^2}\), \({C_2} = {({K_2} \times L)^2}\), \({C_3} = {C_2}/2\). Usually, \({K_1} = 0.01\), \({K_2} = 0.03\), \(L=255\).

We use the peak signal to noise ratio and structured similarity of the image to measure the image quality. Figure 2 shows the original image of Lena, Peppers, Plane and Baboon, and the image after adding watermark. As shown in Table 1, this method increases the PSNR after embedding the watermark, and this paper has great superiority in embedding the watermarking invisibility.

Fig. 2.
figure 2

The effect of the images embedded watermark

Table 1. The PSNR and SSIM of images

As we can see, the performance of our algorithm has the high peak signal-to-noise ratio and image structure similarity, which reflect the mean square error between the watermark image and the original image. The larger value shows the smaller difference between the embedded image and the original image.

3.2 Test and Analysis

3.2.1 Result in Plain-Image

As shown in Fig. 3(a2), (b2) are the tampering image after attack and Fig. 3(a3), (b3) are the localization results. And Fig. 3(a4), (b4) are the recovery results, we can see this method has a great advantage in resisting attack.

Fig. 3.
figure 3

The effect of localization and recovery

After the shear attack, we can see that the image Lena has the half lost and our algorithm can localize the attack precisely and perfectly. Besides, through recovery of our method, the image has very little difference compared with the original image, which shows that our algorithm has unparalleled superiority.

3.2.2 Result in Scrambling Image

The algorithm can directly locate the scrambling image, and it has the same effect compared with the plain-image. The experimental results are shown in Fig. 4. As we can see, tamper can be localized in the scrambling image and the image can be recovery accurately, that is a great innovation, and the result in the scrambling image is still as well as the plain-image

Fig. 4.
figure 4

Localization and recovery of scrambling image

4 Conclusion

This paper presents a semi-fragile image digital watermarking algorithm for plain-image and scrambling image. The main features of this algorithm include the following aspects:

(1) The hierarchical idea is used to locate the tampering position, and it has better anti-shear attack ability, and adds a recovery watermark for tampering recovery. The authentication watermark is composed of the parity check code and the comparison result; the recovery watermark is the average pixel value.

(2) The embedded algorithm uses the well-known spatial domain LSB algorithm. The aim is to improve the tampering recovery effect. The algorithm is simple in principle, has higher localization accuracy and better recovery effect.

(3) This paper use three layers to detect and localize tamper. In this algorithm, the experimental verification can detect the location of tampering in the image, and can effectively recover the tampering content, and can effectively prevent the vector quantization attack.

(4) This algorithm can directly localize tamper in the scrambling conditions, and it can detect tamper without revealing the plain-image, greatly improve privacy and security of the image.