1 Introduction

Development of Internet and image editing tools has provided the ability to access, copy and edit digital images. Since copied images have the same quality as the original image, protecting their copyright has become an important challenge. Digital watermarking is a proper method for protecting copyright of digital images. Imperceptibility (transparency) and robustness (resistance) are two basic properties for evaluating watermarking algorithms. These variables are contradicting and increasing one of them reduces the other one. One of the important factors which affect transparency and robustness is the texture of image areas which are selected for embedding watermark. Embedding in smooth areas of the image makes the watermark perceptible while its robustness is increased. However, embedding watermark in areas with sharp edges increases transparency and reduces robustness (Maity and Kundu 2010). Different methods are employed for selecting suitable blocks of the image for embedding watermark. One of the most applicable methods is using visual properties of human’s visual system. To this end, concepts like variance, entropy and standard deviation are used to describe texture of blocks. Using these concepts, depending on the selected blocks might increase transparency or robustness of the watermark but does not optimize them (Ali et al. 2015; Kazemivash and Moghaddam 2017; Maity and Kundu 2010; Raihan and Gogoi 2017). Since the goal is to find the suitable blocks such that transparency and robustness are balanced and these blocks are determined dynamically for each image, this issue can be considered as an optimization problem and meta-heuristic methods can be used to solve it. However, recently researchers have employed population-based and swarm intelligence methods (FA, PSO, ACO and ABC) to find thresholds and scaling factors in watermarking techniques and have improved results significantly but so far these methods have not been used to select the proper blocks (Ali et al. 2015; Dong et al. 2015; Ishtiaq et al. 2010; Loukhaoukha et al. 2011; Mishra et al. 2014; Vahedi et al. 2012).

In this paper, a new scheme is proposed for optimal selection of blocks using a combination of entropy and firefly algorithm. Since the block numbers are distinct and discrete values, firefly algorithm should have been modified to generate distinct and discrete values. DDFA is an improved version of firefly algorithm which is proposed in this paper to generate such values.

Another factor which can increase the efficiency of a watermarking scheme is selecting suitable transform domain for embedding the watermark. Analytical and simulation methods show that Hadamard transform provides good transparency while it is robust against most attacks and processes (Maity and Kundu 2011). In embedding process of proposed scheme after selecting proper blocks watermark bits are embedded in Hadamard coefficients using average neighboring coefficients and selected blocks location saves as secret key for extraction.

Hadamard transform as frequency domain and a combination of entropy and DDFA for selecting blocks improve and balance the watermark transparency and robustness. The proposed scheme is novel in case of introducing DDFA for selecting optimal blocks and using new method for embedding watermark in Hadamard coefficients. Furthermore, this scheme achieves good imperceptibility and robustness compared to other existing schemes.

Rest of this paper is organized as follows: Sect. 2 reviews related studies. Section 3 presents employed concepts and algorithms. The proposed DDFA and watermarking method are described in Sect. 4. Section 5 presents experiments and results. Section 6 compares the results of the proposed scheme with existing schemes, and finally the paper is concluded in Sect. 7.

2 Related works

Most important part of the proposed scheme is meta-heuristic selection of blocks of the cover image for embedding watermark. This section describes some of the block-based watermarking schemes and their block selection methods.

Many researchers have used entropy for selecting blocks. In these schemes, visual entropy and edge entropy for each block are calculated using relations defined by Shannon and blocks are selected based on this information (Shannon 1948). Method proposed by Maity et al. divides image blocks based on their entropy to low, medium and high informative blocks (Maity and Kundu 2010). Watermark is once embedded in low and once again embedded in medium informative blocks. Images which are watermarked using this method do not have good transparency and in addition robustness of this method is low. Another method which has used entropy is proposed by Lai (2011). In this method, entropy is calculated for each block and blocks with lower entropy are selected for embedding. Although this scheme offers a good transparency, its robustness against different attacks is not good. Franklin et al. (2011) proposed an informed method for watermarking images using visual entropy. In this method, visual entropy and threshold for each block are calculated and blocks which their entropy is greater than threshold are selected. Robustness of this method is low but its transparency is acceptable. Ali et al. (2015) proposed a blind method for watermarking images in which proper blocks are selected using entropy. In this method, first redistributed invariant wavelet transform is applied to the cover image and its low-frequency sub-band is divided into non-overlapping blocks. Then, blocks with lower entropy are selected for embedding the watermark. SVD is applied to selected blocks, and watermark bits are embedded in first column of left singular matrix using different threshold values. Artificial bee colony algorithm is used for optimizing threshold values. This method has acceptable robustness and transparency but low payload.

In some watermarking schemes, statistical parameters like variance and standard deviation are used for selecting proper blocks. Kazemivash and Ebrahimi Moghaddam (2016) have used standard deviation for selecting proper blocks. In this scheme, after applying lifting wavelet transform to the cover image, low-frequency part of the image is divided into 3 × 3 blocks. Blocks with higher standard deviation are selected and some of them are ignored to balance transparency and robustness. Neglected blocks are selected by the firefly algorithm. Robustness of this method is good but its transparency is not acceptable. In this scheme, FA is used for finding blocks which should be eliminated and it is not directly used for selecting blocks. In another method proposed by the same authors, standard deviation is again used for selecting blocks (Kazemivash and Moghaddam 2017). In this method, like previous method, after applying lifting wavelet transform to the cover image, its low-frequency section is divided into 3 × 3 blocks but unlike previous method, blocks with smaller standard deviation are used for embedding the watermark. Transparency of this method is not good but its robustness is high. In the method proposed by Raihan, variance is used for selecting blocks (Raihan and Gogoi 2017). Walsh–Hadamard transform is applied to 8 × 8 blocks which have higher variance and two watermark bits are embedded in each block at DC coefficients. Although transparency of this method is good, its robustness has not been investigated.

In the scheme proposed by Aung et al. in order to increase transparency, blocks with low amplitude are used for embedding the watermark (Aung et al. 2011). The robustness of this method is high, but its transparency is not so good. The first best search has been employed by Sarker et al. to select a sequence of blocks for watermarking (Sarker and Khan 2013). In this method, after dividing the cover image into 8 × 8 blocks and applying Hadamard transform, BFS is used to find longest sequence of blocks with largest coefficients (except DC coefficient). Blocking and Hadamard transform are applied to the watermark image too and coefficients of these blocks are multiplied by scaling factor and then replaced by selected blocks of the cover image. Since watermark is embedded in all coefficients except DC coefficient, this method is vulnerable against different noises.

On the whole, based on the related works, given the strength of schemes proposed by Franklin et al. (2011), Ali et al. (2015) and Kazemivash and Ebrahimi Moghaddam (2016) motivate us to use entropy and a swarm intelligence method for selecting appropriate blocks for watermarking. So a powerful optimization algorithm named firefly algorithm is selected and improved for selecting blocks. It is worthwhile to say no watermarking scheme has been used combination of entropy and firefly algorithm for selecting optimum blocks till now.

3 Reviewing concepts and employed algorithms

In this section, concepts and employed algorithms are described briefly.

3.1 Hadamard transform

2D Hadamard transform is an orthogonal non-sinusoidal transform which reduces bandwidth of the signal and consequently reduces space required for storage in addition, and it is a fast transform. 2D Hadamard transform operates based on Hadamard matrix. Hadamard matrix is a \( 2^{n} \times 2^{n} \) matrix including \( + \;1 \) and \( - \;1 \) where its columns and rows are orthogonal. Due to orthogonality of rows and columns, Hadamard matrix has special properties. One of these significant properties is shown in the following equation:

$$ H_{n} = H_{n}^{\text{T}} = H_{n }^{ - 1 } = H_{n}^{*} $$
(1)

where \( H_{n} \) is Hadamard matrix, \( H_{n}^{\text{T }} \) is transpose of Hadamard matrix, \( H_{n }^{ - 1 } \) is inverse and \( H_{n }^{* } \) is complex conjugate of Hadamard matrix. For \( N = 2 \), Hadamard matrix \( H_{1} \) is called core matrix which is defined as follows:

$$ H_{1} = \left[ {\begin{array}{*{20}c} 1 & 1 \\ 1 & { - 1} \\ \end{array} } \right] $$
(2)

Hadamard matrix of degree \( n \) is constructed using Hadamard matrix of degree \( n - 1 \) and Kronecker product as follows:

$${H_{n} = H_{n - 1}} \otimes {H_{1}}$$
(3)

or

$$ H_{n} = \left[ {\begin{array}{*{20}c} {H_{n - 1} } & {H_{n - 1} } \\ {H_{n - 1} } & { - H_{n - 1} } \\ \end{array} } \right] $$
(4)

And finally, 2D Hadamard transform for an image is computed using the following equation:

$$ V = \frac{{H_{n} U H_{n} }}{N} $$
(5)

in this equation, \( U \) is the original image and \( V \) is the transformed image. Since \( H_{n} \) has \( N \) orthogonal rows, so \( H_{n} \times H_{n} = N \times I \), (\( I \) is the identity matrix) and

$$ H_{n} \times H_{n} = \, N \times H_{n} \times H_{n }^{ - 1 } \quad {\text{so}}\quad H_{n }^{ - 1 } = H_{n} /N; $$
(6)

therefore, inverse Hadamard transform is calculated as follows:

$$ U = H_{n }^{ - 1 } VH_{n}^{*} = \frac{{H_{n} V H_{n} }}{N} $$
(7)

In the proposed scheme, Hadamard transform is applied to 8 × 8 blocks using Hadamard matrix of degree 3. This matrix is represented in the following.

$$ {\text{H}}_{3} = \left[ {\begin{array}{cccccccc} 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill \\ 1 \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad { - 1} \hfill \\ 1 \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad { - 1} \hfill \\ 1 \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad 1 \hfill \\ 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad { - 1} \hfill \\ 1 \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad 1 \hfill \\ 1 \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad 1 \hfill \\ 1 \hfill & \quad { - 1} \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad { - 1} \hfill & \quad 1 \hfill & \quad 1 \hfill & \quad { - 1} \hfill \\ \end{array} } \right] $$
(8)

3.2 Entropy-based block selection

Entropy is an appropriate measure of spatial correlation of neighboring pixels. Shannon’s definition of entropy to calculate the visual entropy of an image is given by (Shannon 1948):

$$ E = - \sum \limits_{i = 1}^{n} p_{i} \log p_{i} $$
(9)

where \( p_{i} \) is the probability of occurrence of the event \( i \), \( 0 \le p_{i} \le 1 \) and \( \sum \nolimits_{i = 1}^{n} p_{i} = 1 \). In this equation, the signal is considered as a sequence of symbols. Entropy depends on the relative occurrence of the symbols, irrespective of the positions of occurrence. Obviously, it is necessary to have some information about image features to reach an imperceptible and robust watermark. Pal and Pal (1989) defined average edge information as an exponential form to calculate the entropy that can capture two-dimensional spatial correlation of images better than Shannon’s entropy. The edge entropy is defined as:

$$ E = \sum \limits_{i = 1}^{n} p_{i} e^{{1 - p_{i} }} $$
(10)

where \( 1 - p_{i} \) is the uncertainty of the pixel value \( i \). This definition of entropy gives more information about pixel dispersion and edges of an image. For each block, visual and edge entropy are calculated using Eqs. (9) and (10), respectively, and then summed together. In this study, double of the number of required blocks are selected from lower entropy blocks, and optimal blocks for embedding watermark are selected from these blocks using DDFA.

3.3 Firefly algorithm

Firefly algorithm is a meta-heuristic method, inspired by behavior of firefly which offers good optimal results in most problems. In FA, three following laws are considered as the basis: (1) fireflies are considered to be mono-sexual and each firefly is attracted to other fireflies. (2) Attraction of each firefly depends on its brightness; fireflies with less light are attracted to fireflies with more light. (3) Brightness of each firefly is determined either randomly or by the objective function. Here, performance of FA is described:

Distance between two fireflies \( i \) and \( j \) which are at location \( x_{i} \) and \( x_{j} \) is calculated using Cartesian distance:

$$ r_{ij} = \sqrt { \sum \limits_{k = 1}^{D} \left( {x_{i,k} - x_{j,k} } \right)^{2} } $$
(11)

In this equation, \( D \) indicates number of dimensions. Attractiveness of each firefly is calculated using Eq. (12):

$$ \beta \left( r \right) = \beta_{0} e^{{ - \gamma r^{2} }} $$
(12)

At \( r = 0 \), attractiveness is \( \beta_{0} \) and \( \gamma \) is light absorption. Movement of firefly \( i \) toward a brighter firefly \( j \) is calculated using Eq. (13):

$$ x_{i}^{\text{new}} = x_{i}^{\text{old}} + \beta_{0} e^{{ - \gamma r_{ij}^{2} }} \left( {x_{i}^{\text{old}} - x_{j} } \right) + \alpha \left( {{\text{rand}} - \frac{1}{2}} \right) $$
(13)

Second term of this equation indicates attractiveness of a firefly toward another firefly and randomness of firefly’s movement is calculated through parameter α which is the randomness parameter. \( {\text{rand}} \) generates random values. \( X_{i}^{\text{new}} \) is new location of the \( i{\text{th}} \) firefly and \( {\text{x}}_{\text{i}}^{\text{old}} \) is previous location of the firefly. Parameter γ attractiveness and convergence speed. Before implementation, values of α, β and γ should be determined. Pseudo-code of firefly algorithm is shown in Fig. 1.

Fig. 1
figure 1

Pseudo-code of Firefly Algorithm

4 The proposed method

In this section, first the proposed distinct discrete firefly algorithm (DDFA) and its objective function are described and then watermark embedding and extracting processes are explained.

4.1 Proposed distinct discrete firefly algorithm (DDFA)

Firefly algorithm was proposed for solving problems with continuous values while these values might be repetitious; therefore, they cannot be employed for selecting proper blocks which are distinct and discrete values. Thus, the original algorithm has been modified so that it can be used for solving this problem. In the proposed algorithm, each firefly introduces a possible sequence of blocks for embedding the watermark. Dimension of each firefly \( \left( D \right) \) is equal to number of required blocks and their values are distinct integer numbers between \( { \text{min} } \) and \( { \text{max} } \); (\( { \text{min} } \) is 1 and \( { \text{max} } \) is double of the number of required blocks). In order to initialize fireflies instead of random initialization, different permutations of blocks between \( { \text{min} } \) and \( { \text{max} } \) are generated and first \( D \) values of each permutation which have distinct values are used as initial fireflies. Using different permutations of blocks, it can be guaranteed that all dimensions are distinct and non-repetitive. β is the amount of displacement of each firefly toward the brighter firefly. In this algorithm, the following equation is used for calculating β at each round:

$$ \beta = \left( {1 + \frac{{{\text{it}}}}{{{\text{maxit}}}}} \right) \times {\text{it}} $$
(14)

\( {\text{it}} \) is the current iteration and \( {\text{maxit}} \) is maximum iteration numbers. As iterations of the program increases, value of β increases, thus in initial rounds, attraction is less so that search is performed in all spaces of the problem. But in the final rounds, attraction is increased so that solutions converge toward the optimal solution faster.

α determines random displacement of each firefly and is calculated as follows:

$$ \alpha = {\text{randi}}\left( {\alpha_{0} } \right) $$
(15)

\( {\text{randi}} \) generates random integer numbers less than \( \alpha_{0} \) and value of \( \alpha_{0} \) is considered to be 10 in this work.

Distance between two fireflies \( i \) and \( j \) is calculated using the following equation:

$$ r_{ij} = \frac{{ \sum \nolimits_{k = 1}^{D} \left| {x_{i,k} - x_{j,k} } \right|}}{D\text{max} } $$
(16)

In this equation, \( D \) is dimension of fireflies and \( D{ \text{max} } \) is calculated as follows:

$$ D{\text{max}} = \left( {\text{max} - \text{min} } \right) \times \sqrt D $$
(17)

As mentioned before, \( { \text{min} } \) is 1 and \( { \text{max} } \) is double of the number of required blocks which are selected from lower entropy blocks. Finally, displacement of firefly \( i \) toward brighter firefly \( j \) is calculated using the following equation:

$$ \begin{aligned} x_{i}^{\text{new}} = \left\{ {\begin{array}{*{20}l} {x_{i}^{\text{old}} + \beta \times r_{ij} + \alpha } \hfill & {\quad {\text{if}} x_{i}^{\text{old}} \le \text{max} - \beta \times r_{ij} + \alpha } \hfill \\ {x_{i}^{\text{old}} + \beta \times r_{ij} + \alpha - \text{max} } \hfill & {\quad {\text{else}}} \hfill \\ \end{array} } \right. \hfill \\ \hfill \\ \end{aligned} $$
(18)

In this equation, └ ┘ is the floor function. According to this equation, \( \beta \times r_{ij} + \alpha \) which is an integer value is added to all dimension of \( i{\text{th}} \) firefly. If by adding this value, some of the dimensions become greater than max, those dimensions are transferred to the beginning of the interval and will not exceed max value. Since dimensions of each firefly is initialized as distinct and discrete values, and while movement a constant integer value is added to all dimensions; it can be guaranteed that dimensions of the new firefly are distinct and discrete. Pseudo-code of DDFA is shown in Fig. 2.

Fig. 2
figure 2

Pseudo-code of proposed distinct discrete firefly algorithm (DDFA)

4.2 Objective function and evaluation metrics

Objective function of DDFA is a minimization function and is designed such that fireflies with lower objective function are more attractive. A combination of transparency and robustness is considered as objective function and is calculated using the following equation:

$$ f = \frac{\gamma }{{{\text{PSNR}}}} + \frac{1}{{{\text{SSIM}}}} + \frac{1}{{\frac{1}{{{\text{NA}}}}\sum\nolimits_{{i = 1}}^{{{\text{NA}}}} {{\text{NC}}_{i} (w,w{{\prime }} )} }} $$
(19)

In this equation, \( {\text{NA}} \) is the number of attacks applied to the watermarked image and γ is used for balancing effect of \( {\text{PSNR}} \). Normal correlation (\( {\text{NC}} \)) is a measure of similarity between watermark \( w \) and extracted watermark \( w^{\prime} \) which evaluates quality of the extracted watermark. \( {\text{NC}} \) is calculated under different attacks and their average is used in the objective function. Following equation calculates \( {\text{NC}} \):

$$ {\text{NC}} = \frac{{ \sum \nolimits_{i = 1}^{m} \sum \nolimits_{j = 1}^{n} w\left( {i,j} \right).w^{\prime}\left( {i,j} \right)}}{{ \sum \nolimits_{i = 1}^{m} \sum \nolimits_{j = 1}^{n} \left( {w\left( {i,j} \right)} \right)^{2} }} $$
(20)

\( m \) and \( n \) are dimensions of the watermark image. Value of \( {\text{NC}} \) is between \( 0 \) and \( 1 \). For two images if \( {\text{NC}} \) is 1, it means that images are completely similar (Lewis 1995).

Quality of the watermarked image is evaluated through \( {\text{PSNR}} \) and \( {\text{SSIM}} \). These measures are calculated using the watermarked image while no attack is applied to it. \( {\text{PSNR}} \) is a statistical measure of similarity between original image and the manipulated image which is measured in dB. \( {\text{RMSE}} \) and \( {\text{PS}} \)\( {\text{NR}} \) for cover image \( I \) and watermarked image \( I\prime \) are represented in Eqs. (21) and (22), respectively.

$$ {\text{RMSE}} = \sqrt {\frac{1}{MN} \sum \limits_{M,N} \left[ {I\left( {i,j} \right){-}I\prime \left( {i,j} \right)} \right]^{2} } $$
(21)
$$ {\text{PSNR }} = \, 10{ \log }\;10 \, (R^{2} /{\text{RMSE}}) $$
(22)

In this equation, \( M \) and \( N \) are dimensions of the cover image and \( R \) is the maximum possible pixel value of the image. When the pixels are represented using 8 bits per sample, this is 255.

\( {\text{SSIM}} \) is another parameter for measuring quality of an image and is designed such that if two images are more similar, this measure is closer to \( 1 \) (Zhang et al. 2011).

$$ {\text{SSIM}}\left( {I ,I\prime } \right) = l\left( {I ,I\prime } \right).c\left( {I ,I\prime } \right).s\left( {I ,I\prime } \right) $$
(23)
$$ \left\{ {\begin{array}{*{20}l} {l\left( {I,I\prime } \right) = \frac{{2\mu_{I} \mu_{I\prime } + c_{1} }}{{\mu_{I}^{2} + \mu_{I\prime }^{2} + c_{1} }}} \hfill \\ {c\left( {I ,I\prime } \right) = \frac{{2\sigma_{I} \sigma_{I\prime } + c_{2} }}{{\sigma_{I}^{2} + \sigma_{I\prime }^{2} + c_{2} }}} \hfill \\ {s\left( {I ,I\prime } \right) = \frac{{\sigma_{II\prime } + c_{3} }}{{\sigma_{I} \sigma_{I\prime } + c_{3} }} } \hfill \\ \end{array} } \right. $$
(24)

\( l\left( {I,I\prime } \right) \), \( c\left( {I ,I\prime } \right) \) and \( s\left( {I ,I\prime } \right) \) are similarity of images \( I \) and \( I\prime \) in terms of luminance, contrast and correlation coefficient, respectively. \( \mu_{I} \) and \( \mu_{I\prime } \) are mean luminance and \( \sigma_{I } \) and \( \sigma_{I\prime } \) are standard deviation of images \( I \) and \( I\prime \). \( \sigma_{II\prime } \) is covariance between two images which computes using Eq. (25) and \( c_{1} \), \( c_{2} \) and \( c_{3} \) are three positive constants for stabilizing division with small denominator and are calculated using the following equation:

$$ \sigma_{II\prime } = \frac{1}{N - 1} \sum \limits_{i = 1}^{N} (I_{i} - \mu_{I} )\left( {I\prime_{i} - \mu_{I\prime } } \right) $$
(25)
$$ c_{1} = \left( {k_{1} L} \right)^{2} $$
(26)
$$ c_{2} = \left( {k_{2} L} \right)^{2} $$
(27)
$$ c_{3} = c_{2} /2 $$
(28)

in which \( k_{1} = 0.01 \), \( k_{2} = 0.03 \) and \( L = 255 \). \( k_{1} \) and \( k_{2} \) values are somewhat arbitrary, but the performance of the SSIM is fairly insensitive to variations of these values (Wang et al. 2004).

4.3 Watermark embedding process

In order to embed a binary image of dimension \( n \times n \) in the cover image of dimension \( M \times N \), following procedure is performed.

Step 1 Cover image \( I \) is divided into \( 8 \times 8 \) non-overlapping blocks.

Step 2 According to Sect. 3.2, entropy is calculated for each block and double numbers of required blocks are selected from blocks with lower entropy. 4 bits are embedded in each block. Thus, for embedding a watermark of dimension \( n \times n \), \( \frac{{n^{2} }}{4} \) blocks are required, so \( \frac{{n^{2} }}{2} \) blocks are selected from lower entropy blocks.

Step 3 Using DDFA Most suitable blocks are selected for embedding watermark. The coordinates \( \left( {x, y} \right) \) of the selected blocks are stored in two matrices as secret key for further considerations.

In each block, four watermark bits are embedded in four Hadamard coefficients. Coefficients used in each block are shown in Fig. 3 and represented as \( c_{3,2} \), \( c_{3,6} \), \( c_{7,2} \) and \( c_{7,6} \). Steps 4–6 are repeated for each block until all bits are embedded:

Fig. 3
figure 3

Position of insertion four watermark bit (\( {\text{c}}_{3,2} \), \( {\text{c}}_{3,6} \), \( {\text{c}}_{7,2} \) and \( {\text{c}}_{7,6} \)) and their neighboring area (gray color) in a 8 × 8 block

Step 4 Hadamard transform is applied to the current selected block and Hadamard coefficients are obtained.

For each of the coefficients \( c_{3,2} \), \( c_{3,6} \), \( c_{7,2} \) and \( c_{7,6} \) step 5 is repeated:

Step 5\( {\text{avg}}_{i,j} \) is average of neighboring coefficients for each \( c_{i,j} \) and \( c'_{i,j} \) is calculated considering current bit of watermark \( w\left( k \right) \), where \( 1 \le k \le n^{2} \) :

$$ \begin{aligned} {\text{avg}}_{i,j} &= \Big( c_{i - 1,j - 1} + c_{i - 1,j} + c_{i - 1,j + 1} + c_{i,j - 1}\\ &\quad + c_{i,j + 1} + c_{i + 1,j - 1} + c_{i + 1,j} + c_{i + 1,j + 1} \Big)/8\end{aligned} $$
(29)
$$ c '_{i,j} = \left\{ {\begin{array}{*{20}l} {{\text{avg}}_{i,j} + {\text{Th}} \quad {\text{if}}\quad w\left( k \right) = 1} \hfill \\ {{\text{avg}}_{i,j} - {\text{Th}}\quad {\text{if }}\quad w\left( {\text{k}} \right) = 0} \hfill \\ \end{array} } \right. $$
(30)

In this equation, \( {\text{Th}} \) is a constant threshold value, \( i = 3,\;7\;{\text{and}}\; j = 2,\;6 \). Then, \( c_{i,j} \) is replaced by \( c'_{i,j} . \)

Step 6 Inverse Hadamard transform is applied to the current block.

Step 7 8 × 8 blocks are put together to get watermarked Image \( I_{\text{w }} \).

Embedding processes are depicted in Fig. 4.

Fig. 4
figure 4

Watermark embedding process

4.4 Watermark extraction

In proposed scheme, the extraction process is done blindly and does not require the cover image. Only watermarked image \( I_{\text{w}}^{'} \) (which might be affected by different attacks) and secret key which determines the coordinates \( \left( {x, \;y} \right) \) of the embedded blocks are required. Watermark extraction steps are as follows:

Step 1 Watermarked image \( I_{\text{w}}^{'} \) is divided into \( 8 \times 8 \) equal and non-overlapping blocks.

Step 2 Using the secret key generated at embedding stage which is transferred via a secure channel, indexes of embedded blocks is obtained. For each block, steps 3 and 4 are repeated until all watermark bits are detected:

Step 3 Hadamard transform is applied to the current block and Hadamard coefficients are obtained.

Step 4 For each coefficient \( c\prime \prime_{3,2} \), \( c\prime \prime_{3,6} \), \( c\prime \prime_{7,2} \) and \( c\prime \prime_{7,6} \); average of neighboring coefficients \( {\text{avg}}\prime_{i,j} \) is calculated using Eq. 29 and watermark bits are detected using the following equation:

$$ \begin{aligned} w^{\prime}\left( k \right) = \left\{ {\begin{array}{*{20}l} 1 \hfill & {\quad {\text{if \; avg}}\prime_{i,j} \le c\prime \prime_{i,j} } \hfill \\ 0 \hfill & {\quad {\text{if\;avg}}\prime_{i,j} > c\prime \prime_{i,j} } \hfill \\ \end{array} } \right. \hfill \\ \hfill \\ \end{aligned} $$
(31)

In this equation,\( 1 \le k \le n^{2} \) for a watermark of dimension n × n, \( i = 3,\;7 \;{\text{and}} j = 2,\;6 \).

Step 5\( w^{\prime}\left( k \right){\text{s}} \) is located beside each other and creates the detected watermark image \( w\prime \).

Extraction processes are depicted in Fig. 5.

Fig. 5
figure 5

Watermark extraction process

5 Experimental results

This section evaluates performance of the proposed watermarking scheme. To this end, 10 standard grayscale images of size 512 × 512 are used as test images and two binary images of size 64 × 64 are used as watermark. All test images are adopted from USC-SIPI database(USC-SIPI 2016) and first watermark is logo of University of Jiroft. Figure 6a–j shows test images and (k − l) watermark images. In all executions of DDFA, \( \alpha_{0} \) = 10, number of initial fireflies is 10 and maximum number of iteration is 100. Length of each firefly is one-fourth of watermark bits, that is \( \frac{{n^{2} }}{4} \), for \( n \times n \) watermark. Firefly dimensions are initialized using distinct block indexes between 1 and \( \frac{{n^{2} }}{2} \) which is double of the number of required blocks with lower entropy. Entropy block selection and DDFA are described in Sects. 3.2 and 4.1, respectively. Also, parameter γ which is used in objective function (Eq. 19) is set to 10. DDFA has been executed 30 times for each image and best results have been selected for experimental analysis. In this paper, a constant threshold value is used for all blocks. Threshold value for each image is selected experimentally; such that mean NC be more than 0.8, the PSNR be greater than 45 and the SSIM be more than 0.99.

Fig. 6
figure 6

Standard grayscale test images (aj), watermark images (kl)

In order to evaluate imperceptibility of the proposed scheme, test images are watermarked using two watermark images Fig. 6k, l. PSNR and SSIM are calculated using Eqs. 22 and 23, respectively, while no attack has been applied on the images. Table 1 shows the obtained results. High values of PSNR and SSIM show good quality of the watermarked image.

Table 1 Experimental values of PSNR and SSIM for 10 watermarked test images

Quality of the extracted watermark is evaluated using NC. In order to evaluate robustness of the proposed method, 25 attacks are applied to the watermarked image and after extracting the watermark, NC values are calculated. Tables 2 and 3 represent values of NC obtained for 10 test images using two watermarks under various attacks. Considering the obtained results, robustness of the proposed method against most attacks is good which is confirmed by high values of NC. Minimum value of NC is associated with mean filter and since embedding watermark is performed using average neighboring coefficients, robustness against this filter is less than other attacks. Additionally, values of NC without applying attacks are equal to 1 in all cases, which confirm the accuracy of proposed watermark extraction process.

Table 2 Experimental values of NC obtained by taking over the Boat, Lena, Opera, Baboon and Man test images corresponding to the 25 distortion attacks
Table 3 Experimental values of NC obtained by taking over the Sailboat, Cameraman, Couple, F16 and Peppers test images corresponding to the 25 distortion attacks

In order to investigate the effect of DDFA algorithm on optimization of robustness and transparency, proposed method run using three different cases of block selection:

Case 1:

blocks are selected using DDFA from lower entropy blocks. This method is called DDFA block selection

Case 2:

lower entropy blocks are selected for embedding. This method is called entropy block selection

Case 3:

random blocks are selected for embedding. This method is called random block selection

Comparing PSNR and SSIM for these cases of selecting blocks for 10 cover images and watermark k of Fig. 6 is shown in Fig. 7a and b. Minimum values are obtained when blocks are selected randomly but using entropy and DDFA has improved the results. When DDFA is used, values of PSNR and SSIM are higher compared to two other cases which indicate that transparency of watermark using DDFA is increased. Figure 7c shows comparison of mean NC for different cases. Robustness of the watermark against attacks when blocks are selected randomly is low. In most cases, results of DDFA are better than entropy with a small difference. In fact, using blocks with low entropy generates good values of NC and optimizing using DDFA does not affect robustness significantly but it increases transparency by preserving robustness. In Sect. 4.2, it was mentioned that the objective function employed in DDFA is a combination of PSNR and SSIM values before applying attacks and mean NC after applying attacks and it is a minimization function. Value of the objective function for three aforementioned cases is calculated and results are shown in Fig. 7d. When DDFA is used for selecting blocks, objective function has minimum value which verifies that transparency and robustness are increased. Random block selection gives maximum values of the objective function. In general, results show that DDFA block selection is more efficient and effective than two other cases.

Fig. 7
figure 7

a PSNR, b SSIM, c mean of NC and d objective function values of watermarked test images for three cases of block selection (DDFA, entropy and random)

6 Comparison and discussion

In the following, results obtained from the proposed scheme using DDFA are compared with results of schemes proposed by Ali et al. (2015), Kazemivash and Moghaddam (2016), Lai (2011), Sarker and Khan (2013). These schemes are briefly described in Sect. 2, and their summarization is given in Table 4. In the schemes proposed by Ali et al. and Lai, entropy is used for selecting blocks (Ali et al. 2015; Lai 2011). Kazemivash and Ebrahimi have used a combination of standard deviation and FA for selecting the blocks and best-first search has also been used by Sarker et al. for block selection (Kazemivash and Moghaddam 2016; Sarker and Khan 2013). For experimental analysis, all cover images are considered to be grayscale of size 512 × 512 and watermark image is shown in Fig. 6k which is a binary image of size 64 × 64. In order to compare robustness of the proposed scheme with other schemes, 25 different attacks are used. Parameters used for simulation are the same as values mentioned in corresponding papers.

Table 4 Summarization of the schemes

Table 5 shows values of NC against various attacks, mean of NC, PSNR, SSIM and Objective function of the proposed scheme compared to four other schemes for Lena test image. Table 6 indicates mean values of PSNR, SSIM, mean of NC and objective function of the proposed scheme comparing with existing schemes for 10 test images (Ali et al. 2015; Kazemivash and Moghaddam 2016; Lai 2011; Sarker and Khan 2013).

Table 5 Comparison of NC for various attacks and PSNR, SSIM and Objective function values, with existing methods (Ali et al. 2015; Lai 2011; Kazemivash and Moghaddam 2016; Sarker and Khan 2013) for Lena test image
Table 6 Mean values of PSNR, SSIM, mean of NC and objective function of the proposed scheme comparing with existing schemes (Ali et al. 2015; Kazemivash and Moghaddam 2016; Lai 2011; Sarker and Khan 2013) for 10 test images

High values of PSNR, SSIM and mean of NC indicate high imperceptibility and robustness of watermark using the proposed scheme. Considering the obtained results, mean NC values of the schemes proposed by Sarker et al. and Kazemivash and Ebrahimi are somewhat better than our proposed scheme (Kazemivash and Moghaddam 2016; Sarker and Khan 2013). Objective function of test images is calculated to compare efficiency of the proposed method with other methods in balancing robustness and transparency. Since the objective function is a minimization function, its lower values indicate higher quality. The proposed method generates minimum value of objective function so it can be concluded that, the performance of the proposed scheme in balancing robustness and transparency is better than other schemes.

7 Conclusion

In this paper, a robust watermarking scheme in Hadamard domain is proposed which Selects blocks of the image for embedding watermark through combining entropy and DDFA. In order to embed watermark, cover image is divided into 8 × 8 non-overlapping blocks, then double of the number of required blocks from lower entropy blocks are selected. Among these blocks, required blocks are selected using DDFA algorithm. Each four watermark bits are embedded in one selected blocks of the cover image using mean neighboring coefficients and a constant threshold. Watermark extraction is blind and objective function of DDFA is a combination of transparency and robustness of watermark. Block selection using entropy and DDFA increases transparency and robustness of the watermark. Proposed scheme is novel in case of using entropy and DDFA for selecting optimal blocks. Also, DDFA as an improved version of firefly algorithm which generates distinct and discrete values is proposed in this paper for first time. Robustness of this method is investigated through 25 different attacks, and the results indicate that robustness and transparency of the proposed method are better than other similar schemes. Despite good resistance of watermark against most attacks, its robustness can be improved using multiple threshold values for each block instead of a single value. Improving robustness using this feature and generalizing this method for video can be investigated in future works.