Skip to content
BY 4.0 license Open Access Published by De Gruyter Open Access April 26, 2021

Digital Watermarking using Grasshopper Optimization Algorithm

Satender Sharma EMAIL logo , Usha Chauhan , Ruqaiya Khanam and Krishna Kant Singh
From the journal Open Computer Science


The advancement in computer science technology has led to some serious concerns about the piracy and copyright of digital content. Digital watermarking technique is widely used for copyright protection and other similar applications. In this paper, a technique for digital watermarking based on Discrete Cosine Transform (DCT), Discrete Wavelet Transform (DWT), and Grasshopper Optimization Algorithm (GOA) is proposed. The method computes the DWT of the cover image to obtain the sub-components of the image. The subcomponent is converted to frequency domain using DCT. The challenge is to find the optimal scaling factor to be used for watermarking. The authors have designed a GOA based technique that finds the optimized scaling factor and the coefficient for embedding the watermark. GOA makes the watermark undetectable and is invisible in the cover image. The watermark image is embedded in the cover image using these coefficients. The extraction of watermark from the cover image is done by using inverse DCT and DWT. The proposed method is compared with the other state of the art methods. The effectiveness of the proposed method is computed using Peak Signal to Noise Ratio (PSNR), Normalized Cross Correlation (NCC) and Image Fidelity (IF). The proposed method outperforms the other methods and can be effectively used for practical digital watermarking.

1 Introduction

Digital watermarking is being widely used for hiding messages by embedding them into digital content like images and videos. The technique is used in various applications like copyright protection, identity verification, and also in hidden communications. Digital watermarking is often considered similar to Steganography. Both these techniques hide messages within images, however their objectives are entirely disjoint from each other. Watermarking aims at hiding messages whereas in steganography messages are of least importance [1]. Numerous researchers have worked in the area of watermarking to develop effective watermarking techniques. The increasing innovations in the field of watermarking can be owed to its use in copyright protection.

Digital watermarking can be categorized as visible and invisible watermarks. In a visible watermark, the watermark is not fully transparent and is visible on the embedding media. This type of watermark is mostly used in copyright protection of digital content. The second type of watermarking is invisible watermarking. In this case the watermark is not visible and can be extracted by specialized algorithms only. The invisible watermark is mostly used for authentication.

2 Literature Review

In the recent years, a lot of research has been carried out in the digital watermarking field. The concept of watermarking was conceived after the year 1990 and a large number of techniques are available in the literature. Digital watermarking techniques may be classified in a number of ways like application, source type for e.g., image, video or audio watermarks or on the basis of the technique used. Since watermarks can be applied on both spatial as well as frequency domain, DWT and DCT based techniques are quite popular. These methods are widely used for image watermarking. In image watermarking there are two images: a watermark image and a cover image. The objective is to embed the watermark image into the cover image invisibly. Also, the extraction of the watermark should be difficult and must not be affected by any attacks. A novel digital image watermarking technique that uses DCT was proposed by Lin et al. [2], the proposed method used DCT for watermarking against JPEG compression. Another method used SVD and DCT for performing audio watermarking which was invisible and robust [3]. A QIM based digital watermarking is studied and analysed in [4]. The researchers further advanced the watermarking techniques by combining DWT with DCT to obtain more effective ways [5]. In [6], an improved DCT-DWT method was proposed which is a hybrid intelligent SVD-based model. Another digital watermarking technique that can be used for detection and recovery of tampered images is presented in [7]. The method is based on DCT technique for watermarking. A fusion of DCT, DWT, and SVD is used for watermarking of colour images [8]. A number of similar techniques based on combination of DCT and DWT for both image and video watermarking are available in the literature [9]. The authors presented a scheme based on DCT blocks for invisible and robust watermark by utilizing the change amid the inter-block coefficients [10]. All these methods work fine for digital watermarks but a serious limitation is the quality of the watermark. The watermark quality is highly dependent on the scaling factor. The scaling factor is defined as the ratio in which the cover image and watermark image should be combined. If the value of the scaling factor is low, the robustness of the method, i.e., the quality of the extracted image will be degraded. On the other hand, if the scaling factor has a high value, the imperceptibility, i.e., the quality of watermarked image will degrade. Therefore, there is a requirement of optimizing the scaling factor [11]. Meta-heuristic algorithms are widely used for optimization in various fields. The use of meta-heuristic algorithm for watermarking images is also available in the literature [12].

In this paper, GOA is used for optimizing the scaling factor, and a robust and invisible method for watermarking is proposed. GOA is a meta-heuristic algorithm which is inspired by the swarm behaviour of grasshoppers [13]. It has a high ability of search exploration in a given space and thus can be used effectively for digital watermarking. The proposed method combines DWT and DCT along with GOA to embed the watermark in the cover image. The proposed methodology is discussed in the following sections preceded by a background of the techniques used.

3 Discrete Cosine Transform

Discrete Cosine transform or more commonly DCT represents an image as the sum of data points. These data points are the sinusoids of different magnitudes and frequencies [14]. It is used to separate an image into sub-bands or spectral sub-bands with varying importance in terms of visual quality of the image. The DCT converts any signal or image from the spatial domain to a frequency domain. It divides the image into two frequency components, namely high frequency and low frequency. The high frequency component represents the reflectance and consists of low energy. The low frequency component represents the luminance of the image and consists of high energy. DCTs are widely used in multiple applications like image compression and watermarking.

Figure 1 represents the function of DCT. The spatial domain image is converted to frequency domain on application of DCT. It provides multiple advantages like high-compression ratio, high-computational complexity, and low error rate. The two dimensional DCT of a N × M image can be computed using Equation (1).

(1) F(u,v)=(2N)12(2M)12i=0N1j=0M1(i).(j)cos[πu2N(2i+1)]cos[πv2M(2j+1)]f(i,j)

where f(i, j) is the intensity level of the input image at location (i, j).

Figure 1 Discrete Cosine Transform
Figure 1

Discrete Cosine Transform

4 Discrete Wavelet Transform (DWT)

Wavelet theory is a relatively new theory that provides a mathematical framework for decomposition of an image into components at different scales and with different resolutions known as Multi-Resolution Analysis (MRA) of images [15]. The theory is a transform based image processing technique that makes use of Wavelet transforms. These are useful as they provide both temporal as well as frequency information for images. The result of applying a 2D wavelet transform is the representation of image as the sum of four components at each level of resolution. Multi-resolution theory represents and analyses images and signals at one or more resolutions. It is a combination of multiple techniques originating from different fields. The sub-band coding used is from digital signal processing and quadrature mirror filtering is derived from pyramidal image processing. The framework for multi-resolution theory is more commonly known as Multi-Resolution Analysis (MRA). The advantage of MRA is that those features that are undetected in one resolution may be detected in other image resolutions. A series of approximations of the given image are computed using a scaling function. A factor of 2 for resolution is applied on each level.

The discrete wavelet transform of an image f(x, y) of size M × N is then,

(2) Wφ(jo,m,n)=1MNx=0M1y=0N1f(x,y)φjo,m,n(x,y)

(3) Wψi(jo,m,n)=1MNx=0M1y=0N1f(x,y)ψj,m,ni(x,y),i={H,V,D}


(4) φj,m,n(x,y)=2j2φ(2jxm,2jyn)

(5) ψj,m,ni(x,y)=2j2ψi(2jxm,2jyn),i={H,V,D}

where, jo is an arbitrary starting scale and the Wφ (jo, m, n) coefficients define an approximation of f(x, y) at scale jo. The Wψi(j,m,n) coefficients add horizontal, vertical and diagonal details for scales greater than jo. Generally, jo = 0 is selected and N = M = 2j so that j = 0, 1, 2, . . . j − 1 and m = n = 0, 1, 2, . . . , 2j − 1. Given the Wφ and Wψi of Equation (2) and Equation (3), f(x, y) is obtained by performing inverse discrete wavelet transform. Figure 2 shows the decomposition of an image using two level DFT.

Figure 2 Two level DWT
Figure 2

Two level DWT

In this paper, the Haar Wavelet transform is used to compute the wavelet components. This transform is the simplest form of wavelets that are computed using the Haar Transform. It acts as the prototype for all other advanced forms of wavelets [16]. The Haar wavelet's mother wavelet function Ψ(t) is mathematically expressed as given in Equation (6).

(6) ψ(t)={10t<1/2112t<10Otherwise

and its scaling function φ(t) can be described as,

(7) ϕ(t)={10t<10Otherwise

The transform computes the data points by finding the sums and differences of adjacent elements. It computes both the horizontal and vertical elements. Equations (8) and (9) are used to calculate the Haar Scaling and wavelet vectors.

(8) hψ(n)={12n=012n=10Otherwise

(9) hφ(n)={12n=0,10Otherwise

5 Grass Hopper Optimization Algorithm

Grasshopper Optimization Algorithm (GOA) is a bio inspired technique. It is inspired by the swarm behaviour of the grasshoppers. These creatures are mostly seen individually however they combine together to form a large swarm. The grasshoppers damage crops by the swarm that they build by coming together. A significant feature of the grasshopper swarm is that it exists in nymph as well as adulthood stage. The grasshopper swarms hog and move in forward direction similar to rolling cylinders. They consume the vegetation that they find in the way. Thereafter they become adults and form a swarm in the air. Following this movement the grasshoppers cover long distances. The grasshoppers follow slow and small steps in their larval phase and during adulthood they take long and abrupt steps. These swarms search the food and this behaviour can be used for optimization problems for exploring search spaces. GOA works in two phases to find the optimal solution. The first stage is exploitation in which the search agents move locally similar to grasshopper movement in the larval phase. The second phase is exploration which is inspired by the grasshopper movement in the adult phase. In this stage, the search agents move abruptly to find the optimal solution. The Grasshopper movements are modelled mathematically to form the basis of the optimization algorithm. The swarming behaviour of the grasshoppers is modelled using the following equations:

(10) Xi=Si+Gi+Ai

where, Xi defines the position of the i-th grasshopper, Si is the social interaction, Gi is the gravity force of the i-th grasshopper, and Ai shows the wind advection. The random behaviour of the algorithm is achieved by adding random variables r1, r2, r3 in the range [0, 1]. Thus, Equation 1 can be rewritten as;

(11) Xi=r1Si+r2Gi+r3Ai

(12) Si=j=1j=iNs(dij)d^ij

where, dij is the distance between i-th and j-th grasshopper.

(13) dij=|XjXi|s

s is the designed function.

6 Proposed Method

Digital Image Watermarking is the method by which an image is embedded into a carrier image which is hard to extract. The watermarking method involves two steps i.e., embedding and detection. The process of watermarking comprises of embedding the watermark image on the cover image to build the watermarked image. The most important factor for developing a robust and efficient watermark is the scaling factor. The optimized value of the scaling factor is computed to make the algorithm robust and effective. In the proposed method, GOA is used to compute the scaling factor. The scaling factor is used to modify the DCT coefficients of the cover image and the water mark image for embedding. The extraction process is used to obtain the watermark with minimum loss. The extraction is done using inverse DWT and DCT. The flowchart of the proposed method is shown in Figure 3. The steps involved in the proposed method are discussed as follows:

  1. The cover image (Ic) and watermark images (Iw) are initially used for the watermarking process.

  2. The wavelet transform of the cover image is computed using Haar Wavelet transform using Equation (6). The application of two dimensional Haar Wavelet Transform produces the approximation; details in horizontal, vertical, and diagonal components are then computed. The discrete wavelet transform of the cover image (Ic) of size M × N is then;

    (14) Wφ(jo,m,n)=1MNx=0M1y=0N1f(x,y)φjom,n(x,y)

    The wavelet filter bank is computed using Equations (6)–(9)

  3. The wavelet transform is converted into the frequency domain by applying the DCT transform. This is computed as follows:

    (15) F(u,v)=σ(u)σ(v)i=0m1j=0n1g(i,j)cos[(2i+1)uπ2m]cos[(2j+1)vπ2n]

    The inverse of DCT is computed using,

    (16) G(m,n)=σ(u)σ(v)i=0M1j=0N1F(u,v)cos[(2i+1)uπ2m]cos[(2j+1)vπ2n]



  4. Grasshopper Optimization Algorithm is used to find an optimized scaling factor and the coefficient for embedding the watermark. This is computed using Equations (10)–(13). The result of applying GOA is to compute the optimal value of ‘α’, which is the weighting or invisibility coefficient.

  5. Apply the insertion additive technique of watermarking using the following insertion formula;

    (17) I'(i,j)=I(i,j)+(α×W(i,j))

    where, I′ is the DWT coefficient of the watermarked image, I is the DWT coefficient of the original image, and W is the DWT coefficient of the watermark image.

  6. To obtain the watermarked image X we compute the inverse DWT of I′.

  7. The watermark can be extracted by applying the inverse of the additive formula given in Equation (17).

    (18) W=I'(i,j)I(i,j)α

    The watermark image, Iw may be computed using the inverse DWT of W.

Figure 3 Flowchart of the proposed method
Figure 3

Flowchart of the proposed method

7 Experiments and Results

The proposed method is based on Grasshopper Optimization Algorithm for digital watermarking on images. The method is simulated using MATLAB 2017a and the results are compared with other state-of-the-art methods. The experiments are carried on three different cover images (Figure 4). The embedding message or watermark image used is shown in Figure 5.

Figure 4 Cover Images (a) Lena (b) Cameraman (c) Baboon
Figure 4

Cover Images (a) Lena (b) Cameraman (c) Baboon

Figure 5 Embedding Message
Figure 5

Embedding Message

The proposed method is compared with two other state of the art methods. The first method uses DWT, DCT and Bacterial Foraging Optimization (BFO) for watermarking [17]. The other method is an improved method that hybridizes Particle Swarm Optimization (PSO) with BFO [17]. Both of these methods are compared with the proposed method. The result of applying the various watermarking methods is shown in Figure 6.

Figure 6 Results of the watermarking approaches applied on different images
Figure 6

Results of the watermarking approaches applied on different images

The watermarking results obtained are measured using the metrics that determine the quality of the proposed method. The metrics that are used for measuring the quality are Peak Signal to Noise Ratio (PSNR), Mean Absolute Error (MAE), and Mean Square Error (MSE). In case of watermarking the best method is the one which has high PSNR values but low MSE and MAE values. PSNR, MAE and MSE may be computed as follows:

(19) PSNR=10log10(SN)

(20) MAE=m,n[I0(m,n)Iw(m,n)]M*N

(21) MSE=m,n[I0(m,n)Iw(m,n)]2M*N

where, M × N is the size of the image, I0(m,n) is the intensity of the (m,n) pixel in the original image and Iw(m,n) is the intensity of the (m,n) pixel in the watermarked image.

The comparative analysis of the proposed method is summarized in Table 1. The visualization of the comparative results is shown in Figure 7. It can be observed that the proposed method gives the best result for all the three test images. The PSNR value for the proposed method is high as compared to the other methods.

Table 1

Experimental Results

(a) Lena Image

PSNR 43.65 45.51 49.89
NCC 0.0039 0.0039 0.0039
IF −1.4664e−04 −3.8026e−05 −8.7464e−05

(b) Cameraman Image

PSNR 40.1263 44.0021 50.1064
NCC 0.0039 0.0039 0.0039
IF −1.9436e−04 −7.9619e−05 −1.9525e−05

(c) Baboon Image

PSNR 32.3226 36.1681 42.2250
NCC 0.0039 0.0035 0.0028
IF −0.0059 −0.0024 −5.9966e−04
Figure 7 Comparison of PSNR values
Figure 7

Comparison of PSNR values

8 Conclusion

This paper presents a digital watermarking technique for image watermarks using a bio inspired algorithm. Grasshopper Optimization Algorithm is used to compute the scaling factor for watermarking. The scaling factor is used to adjust the DWT and DCT coefficients for embedding the watermark on the cover image. The use of GOA provides an optimal scaling factor, thus the proposed method is robust and effective. Experiments are conducted to evaluate the performance of the proposed method. MATLAB 2017a is used for the implementation of the proposed method. The results obtained are compared with other two state-of-the-art methods. The first method combines DWT, DCT, and BFO for watermarking of images. The second method is an improved algorithm and uses a hybridized optimization algorithm. The hybridized method is a combination of PSO with BFO. The proposed method gives low MSE with high PSNR as compared to the other two methods. Thus, the developed method can efficiently be used in practical applications.


[1] Singh KK, Nigam MJ, Pal K. Detection of 2011 Tohoku tsunami inundated areas in Ishinomaki City using generalized improved fuzzy Kohonen clustering network. European Journal of Remote Sensing. 2014 Jan 1;47(1):461–75.10.5721/EuJRS20144726Search in Google Scholar

[2] Lin, S.D., Shie, S.C., Guo, J.Y.: ‘Improving the robustness of DCT-based image watermarking against JPEG compression’, Comput. Stand. Interfaces, 2010, 32, (1), pp. 54–6010.1109/ICCE.2005.1429858Search in Google Scholar

[3] Lei, B.Y., Soon, Y., Li, Z.: ‘Blind and robust audio watermarking scheme based on SVD–DCT’, Signal Process., 2011, 91, (8), pp. 1973–198410.1016/j.sigpro.2011.03.001Search in Google Scholar

[4] Phadikar, A., Maity, S.P., Verma, B.: ‘Region based QIM digital watermarking scheme for image database in DCT domain’, Comput. Electr. Eng., 2011, 37, (3), pp. 339–35510.1016/j.compeleceng.2011.02.002Search in Google Scholar

[5] Deb, K., Al-Seraj, M.S., Hoque, M.M., et al.: ‘Combined DWT-DCT based digital image watermarking technique for copyright protection’. Electrical and Computer Engineering (ICECE), 2012 7th Int. Conf. on. IEEE, 2012, pp. 458–46110.1109/ICECE.2012.6471586Search in Google Scholar

[6] Golshan, F., Mohammadi, K.: ‘A hybrid intelligent SVD-based perceptual shaping of a digital image watermark in DCT and DWT domain’, Imaging Sci. J., 2013, 61, (1), pp. 35–4610.1179/1743131X11Y.0000000049Search in Google Scholar

[7] Shivani, S., Singh, D., Agarwal, S.: ‘DCT based approach for tampered image detection and recovery using block wise fragile watermarking scheme’. Iberian Conf. on Pattern Recognition and Image Analysis, 2013, pp. 640–64710.1007/978-3-642-38628-2_76Search in Google Scholar

[8] Divecha, N., Jani, N.N.: ‘Implementation and performance analysis of DCTDWT-SVD based watermarking algorithms for color images’. Intelligent Systems and Signal Processing (ISSP), 2013 Int. Conf. on. IEEE, 2013, pp. 204–20810.1109/ISSP.2013.6526903Search in Google Scholar

[9] Panah, A.S., Schyndel, R.V., Sellis, T., et al.: ‘On the properties of non-media digital watermarking: a review of state of the art techniques’, IEEE Access, 2016, 4, pp. 2670–270410.1109/ACCESS.2016.2570812Search in Google Scholar

[10] Parah, S.A., Sheikh, J.A., Loan, N.A., et al.: ‘Robust and blind watermarking technique in DCT domain using inter-block coeflcient differencing’, Digit. Signal Process., 2016, 53, pp. 11–2410.1016/j.dsp.2016.02.005Search in Google Scholar

[11] Yusof, Y., Khalif, O.O.: Imperceptibility and robustness analysis of DWT-based digital image watermarking. In: The Proceedings of International Conference on Computer and Communication Engineering (ICCCE), vol. 12, pp. 1325–1330 (2008)10.1109/ICCCE.2008.4580820Search in Google Scholar

[12] Ansari IA, Pant M. SVD watermarking: particle swarm optimization of scaling factors to increase the quality of watermark. In Proceedings of Fourth International Conference on Soft Computing for Problem Solving 2015 (pp. 209–218). Springer, New Delhi.10.1007/978-81-322-2220-0_17Search in Google Scholar

[13] Mirjalili SZ, Mirjalili S, Saremi S, Faris H, Aljarah I. Grasshopper optimization algorithm for multi-objective optimization problems. Applied Intelligence. 2018 Apr 1;48(4):805–20.10.1007/s10489-017-1019-8Search in Google Scholar

[14] Strang G. The discrete cosine transform. SIAM review. 1999;41(1):135–47.10.1137/S0036144598336745Search in Google Scholar

[15] Gupta D, Choubey S. Discrete wavelet transform for image processing. International Journal of Emerging Technology and Advanced Engineering. 2015 Mar;4(3):598–602.Search in Google Scholar

[16] Reisenhofer R, Bosse S, Kutyniok G, Wiegand T. A Haar wavelet-based perceptual similarity index for image quality assessment. Signal Processing: Image Communication. 2018 Feb 1;61:33–43.10.1016/j.image.2017.11.001Search in Google Scholar

[17] Bharati S, Rahman MA, Mandal S, Podder P. Analysis of DWT, DCT, BFO & PBFO Algorithm for the Purpose of Medical Image Watermarking. In2018 International Conference on Innovation in Engineering and Technology (ICIET) 2018 Dec 27 (pp. 1–6). IEEE.10.1109/CIET.2018.8660796Search in Google Scholar

Received: 2020-01-26
Accepted: 2020-03-10
Published Online: 2021-04-26

© 2021 Satender Sharma et al., published by De Gruyter

This work is licensed under the Creative Commons Attribution 4.0 International License.

Downloaded on 30.11.2022 from
Scroll Up Arrow