how to do watermarking using dct.

1 次查看(过去 30 天)
Respected sir,
I have made the following code for watermarking in dct domain.
org_img= imread('lena.jpg');
img4x4 = mat2cell( org_img, size(org_img,1)/2 * ones(1,2), size(org_img,2)/2 * ones(1,2), size(org_img,3) );
% upper left
red_1= img4x4{1,1}(:,:,1);
green_1= img4x4{1,1}(:,:,2);
blue_1= img4x4{1,1}(:,:,3);
%dct to upper left
img1_r= dct2(red_1);
img1_g= dct2(green_1);
img1_b= dct2(blue_1);
%watermark one
w1= imread('cousins.jpg');
wtr_img1= imresize(w1, 1/2);
red1= wtr_img1(:,:,1);
green1= wtr_img1(:,:,2);
blue1= wtr_img1(:,:,3);
%dct to w1
wtr1_r= dct2(red1);
wtr1_g= dct2(green1);
wtr1_b= dct2(blue1);
%embedding of watermark
fimgr1= img1_r+ 0.01*wtr1_r;
fimgg1= img1_g+ 0.01*wtr1_g;
fimgb1= img1_b+ 0.01*wtr1_b;
%combining first block
wimg1= cat(3, fimgr1, fimgg1, fimgb1);
%first output block
rgb1= idct2(wimg1);
imwrite(uint8(rgb1),'DCTWatermarked1.jpg');
figure;imshow(uint8(rgb1));title('Watermarked Image 1');
It shows the error:
Error using .*
Matrix dimensions must agree.
Error in idct (line 74)
y = ifft(W.*bb);
Error in idct2 (line 53)
a = idct(idct(arg1).').';
kindly guide me how to correct it.

采纳的回答

Walter Roberson
Walter Roberson 2016-2-1
dct2() and idct2() apply strictly to 2 dimensional matrices. Your wimg1 is 3 dimensional (RGB) so you cannot apply idct2 to it.
  4 个评论
Ragini Gaikwad
Ragini Gaikwad 2021-6-14
Can you please help on this, how to apply idct and then combine

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by