Digital Image Watermarking using Optimized DWT-DCT

(81 customer reviews)


Total downloads: 574

This repository is for the free code of digital image watermarking .  This code is for the invisible digital image watermarking using combination of three methods: Discrete Wavelet Transform (DWT), Discrete Cosine transform (DCT) and Bacterial Foraging optimization (BFO). You need to run the file ‘main.m’ in MATLAB and follow the steps shown in video

Download Code  Discuss Code


The digital image watermarking is based on the fact that a message is hide into the image such that image doesn’t get disturbed and message can be retrieved easily. The method should be robust. For this purpose, this repository is implementing the discrete wavelet transform (DWT) and discrete cosine transform (DCT) in cascade so that more robustness and security can be achieved. These methods divide the image into different frequency regions so that watermark message can be embedded into lowest frequency region which will not disturb the image. DCT is applied first which is similar to Fourier transform and divides the image into two parts of lower and higher frequency region. Lower frequency region has most of the image information.

DCT frequency coefficient of image

Figure: (a) original image (b) low frequency component of DCT (c) high frequency component of DCT

Similarly, DWT using haar  wavelet transform split the images into four different frequency coefficients: approximation coefficients, horizontal , vertical and detailed frequency component.

DWT frequency coefficient for image

Figure: DWT frequency components of image

Horizontal coefficient is used to insert the watermark image and DCT transform is further applied to cH1 component of DWT transformed image. The embedding of watermark image needs a optimal gain factor which sets the robustness of the message. If this value is too high then security will be increased but retrieval of message will be difficult and vice-versa. So trade off gain factor has to be used for embedding of watermark in it. We used Bacterial Foraging optimization (BFO) for this purpose at

Embedding of Watermark

  1. Take the message and reformulate the message into sequence of 1 and 0.
  2. Encode the message using convolution and this encoded message is further used for processing
  3. Take the key and generate a PN sequence by that key. This PN sequence is kept same during all embedding process.
  4. Generate two highly uncorrelated PN sequence pn_sequence_1 and pn_sequence_0.
  5. Perform DWT on the host image to decompose it into four non-overlapping multi resolution coefficient sets: cA1, cH1, cV1 and cD1.
  6. Choose block size and a mid band coefficients matrix for DCT. In our paper block size of 8 is chosen and a mid band matrix of 8*8 is chosen from literature review.
  7. Now perform DCT on cH1 and embed both PN sequence with a gain factor ‘k’ depending on the bit value of message. The algorithm for embedding PN sequence is shown as

    X = x + k * PN0 if b = 0

    X = x + k * PN1 if b = 1


                  x = is the cover image

                  b = is the watermarked bit

                 X = is the embedded image

  8.  Now perform IDCT on cH1.
  9. Repeat step6 and 7 for cV1.
  10. Perform IDWT on updated values of cA1, cH1, cV1, cD1 and name this image as watermarked image.
  11. PSNR and Normalized cross correlation is found out to determine robustness and image quality of watermarked image.
  12. Now follow steps from 1 to 10 for embedding next watermark using separate key for PN sequence. The size of watermark is determined by hit and trial method and that comes less than the previous watermark size.
  13. Number of watermarks embedded depends upon retrieval process because watermark should be retrieved properly that is without any distortion.

Retrieval of Watermark

The joint DWT-DCT algorithm is a blind watermarking algorithm, and thus the original host image is not required to extract the watermark.

  1. Step 1: Steps from 1 to 5 of embedding process are same using same key for PN sequence generation.
  2. Now perform DCT on cH1 and generate a sequence at condition where mid band matrix element is 1. Correlate that sequence to pn_sequenc_0 and to pn_sequence_1.
  3. Repeat the step 2 with cV1.
  4. Take the mean of correlation value for pn_sequence_1 of cH1 and cV1 and correlation value for pn_sequence_0 of cH1 and cV1.
  5. If correlation value for 0 is greater than the correlation value of 1, put the message vector element equal to 0 otherwise 1.correlation_0>correlation_1Message vector = 0


    Message vector = 1

  6. Apply viterbi decoder on message vector to deocde message vector into original.
  7. Reshape the message vector and that will be similar to message embedded.
  8. Same steps are repeated for next watermark message retrieval.

Fitness Function Calculation

To set the optimum value of gain factor bacterial foraging optimization is used in our work. The BFO minimizes the objective function value to get the best location of E.Coli bacteria. So the task is to formulate the objective function to achieve the best gain value. For this purpose inverse of normalized cross correlation has been considered the parameter which is to be minimized. Initially random gain value is selected and that is passed to the embedding and retrieval process of message using DWT and DCT watermarking process. At the watermarked image by this process various noises like Gaussian noise, salt & pepper noise, speckle noise and poisson noise have been added and message is recovered from these noisy images. NCC between the original message and recovered from these noisy watermarked images have been found out. Then the inverse of sum of all these NCCs is considered as the objective function of BFO.

Image watermarking objective function

Result Discussion

We tested the algorithm at three different kind of images which are low,high and medium key images. This category is suggested on the basis of computer graphics literature where the image with more number of histogram bins are aligned to left for low key image, to right for hugh key image and in middle  for medium key image.

low key image for image watermarking

Figure: histogram plot for low and high key image

A gui to compare the three different watermarking algorithms is also designed in MATLAB. It makes easy to run the algorithm and analyse. On the criteria of PSNR, NCC and IF parameters, we found the gain factor tuning by BFO gives best performance.

Image Watermarking GUI

admin is an innovative and first of its kind platform created by Vidhilekha Soft Solutions Pvt Ltd, a Startup recognized by the Department For Promotion Of Industry And Internal Trade, Ministry of Commerce and Industry, Government of India recognised innovative research startup.

81 reviews for Digital Image Watermarking using Optimized DWT-DCT

  1. fodayj25 (verified owner)

    I am working on my thesis using DWT-SVD and I have embedded in different sub-band of the DWT. I came across your work. It has really helped me. The reason is that my supervisor wants me to compare DWT with other watermarking techniques and see the results. I really appreciate the work done with this code. It very neat and easy to understand.
    Thank you!

    • admin (verified owner)

      We are glad, it helped you.

  2. pratuisha.koripilli (verified owner)


  3. azlina.mahad (verified owner)


  4. qq.qq (verified owner)


  5. imjoy (verified owner)


  6. anshuman.prakash (verified owner)


  7. kumarraghav (verified owner)

    very good

  8. raillon.georges (verified owner)

    Très interresentes approche

  9. ashishsoni (verified owner)


  10. venkat.reddy (verified owner)


  11. venkat.reddy (verified owner)


  12. rohit.bumo (verified owner)


  13. mieszko.nowicki (verified owner)


  14. nikhil (verified owner)


  15. nikhil (verified owner)


  16. anilkumar.katharotita (verified owner)

    Good !!!!

  17. ankush.chaudhary (verified owner)


  18. (verified owner)


  19. vvp.vvpiet (verified owner)


  20. vvp.vvpiet (verified owner)


  21. blade.runner (verified owner)

    good experince

  22. sameer.kumthekar (verified owner)


  23. vankani.arjun (verified owner)

    Nice project !!

  24. jyoti.khandelwal (verified owner)


  25. anshuman.vishwakarma (verified owner)


  26. SHENXIAOXIAO (verified owner)

    well done

  27. namit.gupta (verified owner)


  28. sandeep.reddy (verified owner)


  29. (verified owner)


  30. muhammad.luki (verified owner)


  31. mehrab.hosain (verified owner)

    That good one

  32. Manikanta (verified owner)


  33. akshad.singh (verified owner)


  34. aditya.anugrah (verified owner)

    nice brooo

  35. aditya.anugrah (verified owner)


  36. hanaa.hamouda (verified owner)

    i like this website

  37. deeraj.kumar (verified owner)


  38. rishu.singh (verified owner)


  39. rishu.singh (verified owner)


  40. dheeraj.dang (verified owner)

    jnfam ma

  41. tom.thomas (verified owner)


  42. rasheed.shake (verified owner)


  43. brown.charlie (verified owner)

  44. arpita.kuntageri (verified owner)


  45. Pranayasahu (verified owner)

    very good service

  46. chou_aib (verified owner)


  47. tung2310 (verified owner)


  48. muhammad.rosyadi (verified owner)


  49. ashishsoni (verified owner)


  50. alaoui.alaoui (verified owner)


  51. krisma.ziliwu (verified owner)


  52. nandan.kumar (verified owner)


  53. hashim almosawi (verified owner)


  54. samoua.alsamoua (verified owner)

    Thank you very much

  55. akash.tureha (verified owner)

    Give code

  56. Kaushik5650 (verified owner)


  57. shivangi.panda (verified owner)


  58. shivangi.panda (verified owner)


  59. velan.s (verified owner)


  60. raripi.das (verified owner)


  61. nguyen.minh luc (verified owner)


  62. nguyen.minh luc (verified owner)


  63. nguyen.minh luc (verified owner)


  64. nguyen.minh luc (verified owner)


  65. rania.hamami (verified owner)


  66. aditi (verified owner)


  67. saiteja.gurjala (verified owner)


  68. melvin.monachan (verified owner)


  69. ali.broumandnia (verified owner)


  70. mu.yu (verified owner)


  71. gege.kittie (verified owner)


  72. shivam.rai (verified owner)


  73. 1.1 (verified owner)


  74. htf.gnfn (verified owner)


  75. htf.gnfn (verified owner)


  76. park.hungsik (verified owner)

    Very helpful

  77. (verified owner)


  78. nazwa.auliarahman (verified owner)


  79. 652957296 (verified owner)


  80. tiffeny joy.jankins (verified owner)

    fast process

  81. asryil.azhim (verified owner)


Only logged in customers who have purchased this product may leave a review.