DCT digital watermarking

3 views (last 30 days)
Halil
Halil on 8 Jun 2011
Commented: Walter Roberson on 6 Apr 2019
Hi Everyone,
I am working on a digital watemarking project. this is my first matlab project. So I really need help. I can embed and extract watermark from bmp or jpg. however because of that I do not change domain, watermarks are not robust in jpgs against compression.
I tried to get DCT block, then I quantized it, after that I tried to embed my watermark, at the end I tried to dequantize and inverseDCT. I could not successfully do it.
Can you please give a piece of code to show how can I do it
  3 Comments
Halil
Halil on 9 Jun 2011
Edited: Walter Roberson on 6 Apr 2019
code is here:
function z = DCT2(filename)
image = imread(filename); % define your image
[m,n, k] = size(image); % get size of your image
imvector = reshape(image, m*n*k, 1); % reshape image
zeros(imvector);
imdct = dct(imvector); % compute DCT
imagedct = reshape(imdct,m, n, k); % reshape result bacl
%%embedding will be here
imdct2 = reshape(imagedct, m*n*k, 1);
imvector2 = idct(imdct2);
image2 = reshape(imvector2, m,n,k);
figure(1)
imshow(image, [])
title('Original Image')
figure(2)
imshow(image2, [])
title('Image2')
end
What is the problem about codes. I want to embed watermark in the middle, but even without embbeding anythingimage2 is too corrupted.
SHIREESHA THADKAPALLY
SHIREESHA THADKAPALLY on 27 Mar 2018
are you using image watermark or text as watermark i mean u r embed text in image or image in image?

Sign in to comment.

Answers (1)

Sean de Wolski
Sean de Wolski on 9 Jun 2011
Hi Halil,
The reason you're seeing the corrupted image is because you're working on all three channels (R,G,B) at once. These are three independent channels and thus need to be dealt with independently.
Here's your code modified to work with each channel independently. It doesn't actually do anything, but shows that the image will not be corrupted:
vec = @(x)reshape(x,numel(x),1);
image1 = imread('peppers.png'); % IPT sample image (don't call it image, MATLAB stock function)
[m,n,k] = size(image1); % get size of your image
image2 = zeros(m,n,k,class(image1)); %preallocate second image
for ii = 1:3;
image2(:,:,ii) = reshape(idct(dct(vec(image1(:,:,ii)))),m,n);
%vector of channel -> dct -> idct -> reshaped to original size
end
figure(1)
imshow(image1, [])
title('Original Image')
figure(2)
imshow(image2, [])
title('Image2')
Good Luck!
  6 Comments
Bhavneet Sharma
Bhavneet Sharma on 6 Apr 2019
Attempt to execute SCRIPT dct as a function:
C:\Users\Downloads\IMAGE WATERMARKING\DCT\dct.m
Error in dct (line 6)
image2(:,:,ii) = reshape(idct(dct(vec(image1(:,:,ii)))),m,n);
this is the complete error messgae.
Walter Roberson
Walter Roberson on 6 Apr 2019
You created a script named dct.m that attempts to call upon the MATLAB provided dct() function, but gets confused because its own name is also dct .
Rename your script to something else, such as try_dct.m
You will probably also need the change I give above to define vec .

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!