1 Introduction

When confidential images are transmitted through insecure environments, they might be exposed to manipulations. For some vital data like medical and military images, changes may be so risky because these manipulations might alter essential information inside images. As a result, these data should be kept safe against any changes.

The digital watermarking algorithms can be categorized into robust, fragile, and semi-fragile methods based on data during the watermark extraction trend.

Robust watermarking does not react to attacks easily. Therefore, it plays a vital role in copyright protection. Despite different manipulations, the watermarked image does not change, and owners will not be concerned about illegal copyright infringement.

A fragile watermarking algorithm detects the weakest manipulations, and it is useful for recognizing any weak attacks. A semi-fragile algorithm is a method that is appropriate for both of the above goals. It is sensitive to attacks, so it helps to recognize attacks, and it is robust against a weak attack so that it can play a role in copyright protection. Nevertheless, it is not as sensitive as a fragile method. If we have valuable data, and it is crucial to keep it safe from any weak attacks, a semi-fragile method is not appropriate.

So far, several watermarking methods from the three mentioned categories have been introduced. Based on the application they developed to have higher visual quality and/or higher robustness against attacks compared to the existing watermarking algorithms.

In this article, a fragile watermarking algorithm is presented based on Fourier transform and QR decomposition. The goal of the method is to have high visual quality and high sensitivity against attacks. In the beginning, the Fourier transformation is used on the host image. After that, QR factorization is used to factorize the transformed host image along with the watermark image. Two upper triangular matrices are obtained. By choosing a proper coefficient of matrix R from the watermark image, a sign of the watermark image is embedded into the host image, resulting in an upper triangular matrix. The Q matrix of the host image and this upper triangular matrix should be multiplied together, and as a result, the matrix of the watermarked image is achieved. In the experimental part, it is understandable that although embedding and extraction parts work well, this algorithm is susceptible to the weakest attacks. So if the watermarked image is exposed to any threats, one will not be able to extract the watermark image. The current paper is an extension of the conference paper [1]. Experimental results show higher visual quality measured with two criteria compared to the existing watermarking algorithms.

The novelty of the proposed method is in the way of employing FT and QR decomposition. Although both FT and QR decomposition have been used previously in the watermarking field, the way of embedding mechanism and altering the value of coefficients affects the visual quality of the watermarked images directly. Therefore, in this paper, we proposed a novel embedding process to have higher performance.

2 Related Works

Recently, researchers have been working on fragile watermarking methods to improve the results. In this section, some fragile watermarking algorithms are summarized. Some of them employed a transform to transfer the host image from the spatial domain to the transform domain. The previous research works have been shown that embedding the bits in the transform coefficients results in watermarked images with higher visual quality.

The first fragile watermarking algorithm was presented in 1995 [2]. Based on this algorithm, a checksum is calculated from the seven most significant bits and is placed into the least important bit. Afterward, another algorithm was proposed to localize tampered image content [3] effectively. In this method, the watermark embedding procedure is comprised of two phases- i.e., authentication code generation from some selected salient bits of each pixel of the original image content.

Another fragile watermarking scheme was suggested for authenticating color-images. In this scheme, the input image is factorized into two blocks that do not overlap. For each i-th block, the watermarks are embedded into a different block according to an embedding sequence given by a permutation process [4]. A prediction-error expansion based on a reversible watermarking strategy was proposed to detect and localize malicious modifications and recovers back the original data at watermark detection [5].

A fragile watermarking was presented using the Local Binary Pattern (LBP) and Discrete Wavelet Transform (DWT) for image authentication. In this method, the LBP pattern of low-frequency wavelet coefficients is adopted as a feature watermark [6]. A pixel-based fragile watermarking algorithm for image tamper recognition was presented in [7]. By evaluating the left and right singular matrices of Singular Value Decomposition (SVD), it is found that the matrix product between the first column of the left singular matrix and the change of the first column in the right singular matrix is nearly related to the image texture attributes.

Another method with high-quality recovery capability according to an overlapping embedding approach was presented in [8]. The block-wise system is used for tampering localization, and the pixel-wise system for content reconstruction participates in this algorithm. In another fragile watermarking method for digital image tamper localization (TL) along with the self-recovery capability, at first, the host image is divided into blocks of size 4 × 4; then, singular value decomposition is performed on each block [9].

A fragile watermarking scheme for stereo image authentication was proposed in [10]. Using SHA-256 hash function, a block-based fragile watermark embedding and tamper detection method is proposed [11]. At first, the host image is divided into 32 × 32 non-overlapped blocks. Each 32 × 32 block is then divided into four 16 × 16 non-overlapped sub-blocks. The entire hash value of the first three sub-blocks is generated as a watermark using the SHA-256 hash function.

A Region of Interest (RoI) based fragile watermarking scheme for medical image tamper detection is presented in [12]. An image authentication approach is designed using block-based fragile watermarking [13]. Moreover, an effective recovery technique based on unsupervised machine learning is proposed. The authentication data is generated, for each 8 × 8 image block, using the Discrete Cosine Transform. Another fragile watermarking method for the authentication of digital images is proposed based on a binary rotation invariant and noise-tolerant (local texture descriptor and an Extreme Learning Machine (ELM) [14].

A self-embedding fragile watermarking scheme for medical images is presented [15]. Both self-recovery information and authentication code for each block is generated in advance and then embedded into other blocks separately with the turtle shell and embedding table's help. A frequency data-hiding scheme, which will be examined in accordance with the Linear Cellular Automata Transform using Manhattan distances, is proposed in [16]. Various invertible integer mappings are applied in order to find out the Manhattan distances from coordinates.

In a fragile watermarking technique for securing the copyrights of sensitive images, a combination of Compressive Sensing (CS) theory, Discrete Wavelet Transform (DWT), and Non-Subsampled Contourlet Transform (NSCT) are employed [17]. In a self-recovery based fragile watermarking [18], to improve the watermarked image quality, a bit-reduction technology is employed to generate a watermark with fewer bits. The watermark is then embedded into the original image using the turtle shell, based data hiding technique.

In [19], the authors present a methodology to protect multichannel images' integrity, having some highly redundant channels, using a reversible fragile watermarking algorithm. The watermark embedding phase uses a lossless compression method to compress the high redundancy channels, stores the compressed stream into their most significant bits, then embeds a secret fragile watermark by modifying the least significant bits of the high redundancy channels.

A secure fragile image watermarking scheme used to detect modification or tampering on image content is proposed in [20]. The scheme is developed into two steps, i.e., computation of secure authentication code/watermark bit from some of the most significant bits of each pixel, and subsequently hides the watermark bit in the Least Significant Bit (LSB) of each pixel by suggested watermark embedding procedure. In another fragile watermarking method, the watermark embedding procedure is comprised of two phases- i.e., authentication code generation from some selected salient bits of each pixel of the original image content, and encryption of the authentication code before realizing it for embedding into the insignificant bits of each pixel in the original cover image. The authentication code is computed from each block using Hamming Code. Subsequently, the encrypted code is concealed into the pixels of that particular block using the suggested payload embedding strategy [27]. The authors of [27] proposed two other fragile watermarking methods [28, 29], which embed the watermark in the least Significant Bits (LSBs) of pixels. Usually, LSB-based watermarking techniques result in higher visual quality measures. In some research works, different encryption methods (e.g. [30,31,32]) have been applied to enhance the performance of watermarking methods.

Although the research works about fragile watermarking, have been used different techniques for watermark production and watermark embedding processes, both in spatial (e.g. LSB based methods) and transform (e.g. LBP and DWT transforms) domains, nevertheless improving the visual quality of the resulted watermarked images is still an important issue.

3 Background

3.1 Fourier Transform

A grayscale image has two dimensions, so a two-dimensional Fourier transformation is applied to it. In this case, a matrix is taken as an amount of the Discrete Fourier Transformation (DFT), and it returns another matrix as output. Both matrices are of the same size.

Suppose i and j to be the indices. Then, f(i,j) shows the original matrix values, and F(u,v) is the output matrix values. F is f’s Fourier transformation (Eq. 1).

$$F = {\mathcal{F}}\left( f \right)$$
(1)

Suppose the image yields an M × N matrix. The forward transform is calculated using Eq. (2). For simplicity, we consider i indices to range from 0 to M-1 and j indices to range from 0 to N − 1.

$$F\left( {u,v} \right) = \mathop \sum \limits_{i = 0}^{{{\text{M}} - 1}} \mathop \sum \limits_{j = 0}^{{{\text{N}} - 1}} f\left( {i,j} \right){\text{exp}}\left[ { - 2{\pi i}\left( {\frac{iu}{{\text{M}}} + \frac{jv}{{\text{N}}}} \right)} \right]$$
(2)

3.2 Matrix Factorization

Matrix factorization is a linear algebra technique with various applications in a large number of domains, such as image processing, data analysis, and machine learning. There are diverse matrix factorization methods like QR factorization, Singular Value Decomposition (SVD), LU decomposition, Schur decomposition, etc. In this article, to decompose both the watermark and the host images, QR factorization is used. It is worth noting that the host image needs to be transformed by FT before using QR factorization.

QR Factorization As it was said before, one of the most popular matrix factorizations is QR decomposition (also called QR factorization). Suppose A is a matrix after using QR factorization on this matrix. In that case, an equal A = QR will achieve in which matrices Q and R are orthogonal (i.e., \({\text{Q}}^{{\text{T}}} \cdot \,{\text{Q}} = {1}\)) an upper triangular, respectively. If A is nonsingular, then this factorization is unique. There are several methods for actually computing the QR decomposition. In this factorization, \({\text{A}} \in {\mathbb{R}}^{{{\text{n}} \times {\text{k}}}}\), \({\text{Q}} \in {\mathbb{R}}^{{{\text{n}} \times {\text{k}}}}\), and \({\text{R}} \in {\mathbb{R}}^{{{\text{k}} \times {\text{k}}}}\).

4 Proposed Algorithm

Here, the watermarking method is introduced. In Figs. 1 and 2, embedding and extraction phases are illustrated, respectively.

Fig. 1
figure 1

Embedding algorithm

Fig. 2
figure 2

Extraction algorithm

4.1 Embedding Algorithm

4.1.1 Preprocessing

In the beginning, before using Fourier transformation and QR decomposition to both images, grayscale conversion and resizing operations was run on them.

4.1.2 Fourier Transform

Fourier transform is mostly used on images to enhance their visual quality. The result of such a transformation is a transformed version of the initial image with the original size. It is noticeable that in this algorithm, FT is just applied to the host image. Manipulation of selected transform coefficients results in less perceptible altering in images.

4.1.3 Matrix Decomposition

After the host image is transformed as mentioned, it has to be decomposed by QR decomposition. In the meantime, the watermark image must be decomposed by QR decomposition too.

By denoting the transformed host image with H and the watermark image with W, using QR decomposition on H and W yields \({\text{Q}}_{{\rm H}}\),\({\text{R}}_{{\rm H}}\), \({\text{Q}}_{{\rm W}}\) and \({\text{R}}_{{\rm W}}\), respectively.

4.1.4 Embedding Watermark Images

After decomposing the matrices, one of the watermark matrix components should be chosen to be embedded into the host image. We choose matrix R because it is triangular and has fewer nonzero elements, and thus, it will not alter the initial image so much. It is a better choice for the embedding phase. To do so, a coefficient of matrix \({\text{R}}_{W}\) is added to \({\text{R}}_{{\rm H}}\). As a result, an approximation of \({\text{R}}_{{\rm H}}\) is obtained, which is an upper triangular matrix. (Eq. 3).

$${\text{R}}_{new} = {\text{R}}_{{\text{H}}} + \upalpha {\text{R}}_{{\text{W}}}$$
(3)

In this equation, α is called the embedding strength, which its lower values can significantly affect a better image incomprehensibility. The value of α is obtained experimentally. The QH should be multiplied to Rnew in order to obtain the host image with a sign of the watermark image (Eq. 4).

$$H_{new} = Q_{H} + R_{new}$$
(4)

Finally, the inverse FT is applied to \({\text{H}}_{{{\text{new}}}}\), and the watermarked image will be obtained. If α is selected correctly, the watermarked image resembles the host image and the watermark image cannot be perceptible inside it.

4.2 Extraction Algorithm

While a watermarked image is sent over an insecure social channel such as the Internet, it may face various threats, which will decrease the visual quality and will even cause to create incorrect information. As mentioned before, it is necessary for some vital data such as military and medical data to understand if images are exposed to attacks. For this application, a fragile watermarking algorithm is advantageous because it is even susceptible to the feeblest attacks. In this type of watermarking algorithm, in the extraction phase, if the watermark image can be extracted properly, it is implied that the watermarked image had not been exposed to any attacks. On the other hand, if the algorithm cannot extract the host image's watermark image, it means the watermarked image has been manipulated. The information of images may have changed and can no longer be trusted. The extraction part is expressed as follows:

4.2.1 Fourier Transform

At first, the receiver should use Fourier transformation on the watermarked image to obtain its transformation.

4.2.2 QR Factorization

After Fourier transformation, QR factorization is applied to obtain two matrices, namely, QF and RF. The goal is to find an approximation of RW, which is called, RExtracted and is calculated as in Eq. (5).

$${\text{R}}_{{{\text{Extreacted}}}} = \frac{1}{\upalpha }\left( {{\text{R}}_{{\text{F}}} - {\text{R}}_{{\text{H}}} } \right)$$
(5)

4.2.3 Generate Extracted Image

The extraction image will be achieved by multiplying QW into RExtracted (Eq. 6)

$${\text{S}} = {\text{Q}}_{{\text{W}}} {\text{R}}_{\rm Extracted}$$
(6)

Here, S is the extracted watermark image. If the watermarked image has not been exposed to any attacks while being transmitted, S is very close to the watermark image. However, if the extraction part cannot extract a proper image, we conclude that the watermarked image has been manipulated and cannot be trusted.

5 Experimental Results

Medical information plays an essential role in recognition of human diseases. If these images are manipulated, it causes incorrect diagnosis of diseases, creating many problems for people's health. So realizing whether an image is manipulated is a critical point for medical images. In Fig. 3, some different medical images are illustrated.

Fig. 3
figure 3

Sample of medical images

In this paper, the simulations have been done on Matlab R2018a and the images have been chosen from the USC-SIPI image database [21]. Various experiments have been done to check out imperceptibility in the watermarking algorithm. In the preprocessing part, to achieve the grayscale of images, a suitable function is applied. The performance evaluation metrics used in this paper will be expressed in the following.

To measure our schemes’ invisibility, some quality metrics that include Peak Signal to Noise Ratio (PSNR), Root Mean Square Error (RMSE), Normalized Correlation (NC), and Structural Similarity (SSIM) are used. PSNR is calculated by Eq. (7).

$${\text{PSNR}} = 20\log_{10} \frac{255}{{{\text{RMSE}}}}$$
(7)

which RMSE (Root Mean Square Error) is calculated in Eq. (8).

$${\text{RMSE}} = { }\sqrt {\frac{1}{{{\text{MN}}}}\mathop \sum \limits_{{{\text{i}} = 1}}^{{\text{N}}} \mathop \sum \limits_{{{\text{j}} = 1}}^{{\text{M}}} \left( {{\text{H}}_{{{\text{ij}}}} - {\text{W}}_{{{\text{ij}}}} } \right)^{2} }$$
(8)

In this equation, both images have sizes of M × N, Hij is used to show the host image, and Wij is also used for the watermark image. These metrics show the degree of visual quality. It means higher PSNR, and on the other hand, lower RMSE show that the image has more visual quality. SSIM is described in Eq. (9).

$${\text{SSIM}}\left( {{\text{I}},{\text{I}}^{*} } \right) = {\text{l}}\left( {{\text{I}},{\text{I}}^{*} } \right){\text{c}}\left( {{\text{I}},{\text{I}}^{*} } \right){\text{s}}\left( {{\text{I}},{\text{I}}^{*} } \right)$$
(9)

where \({\text{l}}\left( {{\text{I}},{\text{I}}^{*} } \right)\) is luminance comparison function, \({\text{c}}\left( {{\text{I}},{\text{I}}^{*} } \right)\) is contrast comparison function and \({\text{s}}\left( {{\text{I}},{\text{I}}^{*} } \right)\) is structure comparison function. The last metric which we use is NC. It is shown in Eq. (10).

$${\text{NC}} = { }\frac{{\mathop \sum \nolimits_{{{\text{j}} = 1}}^{3} \mathop \sum \nolimits_{{{\text{x}} = 1}}^{{\text{p}}} \mathop \sum \nolimits_{{{\text{y}} = 1}}^{{\text{q}}} \left( {{\text{C}}\left( {{\text{x}},{\text{y}},{\text{j}}} \right)} \right){*}\left( {{\text{W}}^{*} \left( {{\text{x}},{\text{y}},{\text{j}}} \right)} \right)}}{{\sqrt {\mathop \sum \nolimits_{{{\text{j}} = 1}}^{3} \mathop \sum \nolimits_{{{\text{x}} = 1}}^{{\text{p}}} \mathop \sum \nolimits_{{{\text{y}} = 1}}^{{\text{q}}} \left( {{\text{C}}\left( {{\text{x}},{\text{y}},{\text{j}}} \right)} \right)^{2} } \sqrt {\mathop \sum \nolimits_{{{\text{j}} = 1}}^{3} \mathop \sum \nolimits_{{{\text{x}} = 1}}^{{\text{p}}} \mathop \sum \nolimits_{{{\text{y}} = 1}}^{{\text{q}}} \left( {{\text{W}}^{*} \left( {{\text{x}},{\text{y}},{\text{j}}} \right)} \right)^{2} } }}$$
(10)

where \(C\left( {x,y,j} \right)\) and \(W^{*} \left( {x,y,j} \right)\) show the value of pixel \(\left( {x,y} \right)\) in layer j of the original host image and watermarked image and p, q represent the row and column size of the original and watermarked images, respectively.

Our experiments are done using six images, which are shown in Fig. 4.

Fig. 4
figure 4

ae Host images, f watermark image

As it was said before, α is the embedding strength, and its different values bring various PSNRs for embedding and extraction parts. The effect of changing α on PSNR at embedding and extraction phases is shown in Fig. 5.

Fig. 5
figure 5

The effect of changing α on PSNR in the embedding phase

In the embedding phase, it is clear that an increase in α leads to a decrease in PSNR, because only a small amount of the watermark image will be added to the host image. Thus, if α is chosen small enough, PSNR will be larger, and as a result, our scheme will work well, and it means in the embedding phase, this method’s imperceptibility is sufficient.

Choosing an appropriate α also plays an important role in the extraction part. The plot shows that the value of α and PSNR have an opposite relation. It means if α is chosen large enough, the PSNR value will be large too.

As a result, choosing α, should be considered from two sides. The best value of α occurs at the intersection of two plots. At this point, both of embedding and extraction's PSNRs are near 65, and this value shows that this scheme works well in both of these phases.

By choosing a correct α, the extraction part works correctly as well as the embedding phase, and the watermark image can be extracted entirely. In Fig. 6, different watermarked images are shown, and in Fig. 7 extracted images from the watermarked images in Fig. 6 are figured.

Fig. 6
figure 6

ae Watermarked Images

Fig. 7
figure 7

ae Extracted images

As mentioned before, choosing the best α can be done by considering the intersection point. By doing experiments on different host images, we found that a specific α is achieved for each host image, and as a result, for each host image, its own α obtains the PSNR value. This result is shown in Table 1. This table shows that our scheme works well in both phases and all PSNRs are high. To obtain this result, experiments have been done on images with 512 × 512 sizes.

Table 1 PSNR (dB) of watermarked images from different sizes and different host images

We also evaluated our scheme in different sizes. The results are shown in Fig. 8. By considering this plot, we understand that the larger the image size in the embedding phase, the larger the PSNR value becomes. Nevertheless, in the extraction part, the situation is different, and the relation between the size of images and PSNR value is the opposite. It means that in order to have a better PNSR in the extraction phase, the size of the images should be smaller. By regarding this trade-off, the size of images should be chosen near 512 × 512. As a result, all of the next experiments have been done on 512 × 512 image size. It should be noted that the time required for embedding the watermark and the extraction is less than one second.

Fig. 8
figure 8

The effect of image sizes on PSNR value

As mentioned before, the amounts of α affect PSNR values. Besides, it has a significant effect on other metrics, such as SSIM and NC. α's changes on SSIM and NC from embedding and extraction phases are shown in Figs. 9 and 10. The plots of Fig. 9 are from the embedding phase of these metrics, and the plots of Fig. 10 are from the extraction phase.

Fig. 9
figure 9

SSIM and NC plots from the embedding phase

Fig. 10
figure 10

SSIM and NC plots from the extraction phase

By considering Fig. 9 in the embedding phase, larger amounts of α, lead to lower SSIM and NC. Our method's preferences are that although α is so large, these metrics’ values are close to 1.

In our scheme, to have higher PSNR in the extraction phase, α should be chosen large enough. Therefore, having a small α, leads to a decrease in PSNR, and as a result, it leads to having larger SSIM and NC. Figure 10 shows how the PSNR and SSIM values change by altering the value of α. As shown in Fig. 10, although we have chosen α very small, NC and SSIM move so fast to one, and in α = 0.01, these metrics' values are near one.

To continue our experiments, we need to have a fixed α and do the next experiments with it. To achieve this fixed α, we have done experiments on a larger dataset with 21 images. For each host image, we have found its intersection point. By calculating their average, the best alpha is equal to 0.7833. Using this amount of α, the experimental results are shown in Table 2. The results show that our scheme’s embedding phase works well.

Table 2 PSNR, SSIM, NS, and RMSE of watermarked image from different host image

This result from Tables 1 and 2 shows that this method is powerful in both embedding and extraction phases and it has a good visual quality. To illustrate this performance, we have compared our results with other methods in Table 3. The bold number in the last row of the table displays the superiority of the proposed method compared to the previous ones.

Table 3 The comparison of PSNR and SSIM with other schemes

As it is shown in Fig. 7, in the extraction phase, if the watermarked image is not exposed to any attacks, the watermark image will be extracted correctly, and when we look at the watermark and extracted images, they seem to be the same, and no one can distinguish any differences, and it means extraction phase works perfectly.

But it will be different when a watermarked image is exposed to any weak attack because this algorithm is susceptible to every kind of attack. It means, if the watermarked image is exposed to any attacks, the extraction phase does not work. So the watermark image is not accessible.

This paper uses some weak attacks to evaluate this sensitivity by using Lena as the host image. The results are shown in Fig. 10. Besides, Table. 4. shows the PSNR from these attacks for all of the host images. All of the PSNR values are so low, and these results prove the sensitivity against any attack. As a result, this algorithm is fragile, and it can help protect vital images against manipulation.

Table 4 PSNR (dB) and SSIM value of different attacks by considering different host images

The values of PSNR and SSIM in Table 4 and the visual quality of the extracted watermarks in Fig. 10, all show that the occurrence of attacks, even with minor modifications, can be recognizable (Fig. 11).

Fig. 11
figure 11

a Extracted image without any attack. b Extracted image with sharpen attack. c Extracted image with rotation attack. d Extracted image with crop attack. e Extracted image with blur attack

6 Discussion

In the proposed method, the amounts of α affect PSNR values. In addition, it has a significant effect on other metrics, such as SSIM and NC. In the embedding phase, larger amounts of α, lead to lower SSIM and NC. In our scheme, to have higher PSNR in the extraction phase, α should be chosen large enough. Therefore, having a small α, leads to a decrease in PSNR, and as a result, it leads to having larger SSIM and NC. The experimental results show that the proposed method is influential in both embedding and extraction phases, and it has an excellent visual quality. Compared our results with other methods expresses that it is superior compared to other methods.

The proposed algorithm is vulnerable to every kind of attack. It means, if the watermarked image is exposed to any attacks, the extraction phase does not work. Consequently, the watermark image is not accessible.

Since the proposed method is fragile, it is susceptible to any changes (e.g., light compression on the Internet). If a watermarked image is manipulated, the extraction process cannot extract the watermark. Accordingly, it is applicable only when the detection of changes is significant.

7 Conclusion

We proposed a fragile watermarking method based on QR decomposition and Fourier transform, which fulfills the goal of identifying manipulated images. According to the experimental results, this method works well in the embedding and extraction phases and is susceptible to the weakest attacks, so it acts beneficially in protecting valuable data and detecting any modification. Fine-tuning the parameters especially alpha is a handwork, which is directly, affects the visual quality of the watermarked and extracted images. Setting the parameters adaptively to the feature of images and evaluation the proposed method against other attacks can be considered for the future work.