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

Sean de Wolski
Sean de Wolski 2011년 6월 8일
Could you please give us a piece of code so we can see what you've done? Perhaps sample images to show the issues you're seeing as well.
Halil
Halil 2011년 6월 9일
편집: Walter Roberson 2019년 4월 6일
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 2018년 3월 27일
are you using image watermark or text as watermark i mean u r embed text in image or image in image?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 6월 9일

0 개 추천

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

Halil
Halil 2011년 6월 13일
thanks
Bhavneet Sharma
Bhavneet Sharma 2019년 4월 6일
while executing you code i got an error given below:
Error in dct (line 6)
image2(:,:,ii) = reshape(idct(dct(vec(image1(:,:,ii)))),m,n);
can you suggest me how to sove this error?
Walter Roberson
Walter Roberson 2019년 4월 6일
Please show the complete error message.
vec = @(x) double(x(:));
Bhavneet Sharma
Bhavneet Sharma 2019년 4월 6일
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 2019년 4월 6일
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 .

댓글을 달려면 로그인하십시오.

질문:

2011년 6월 8일

댓글:

2019년 4월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by