Effacer les filtres
Effacer les filtres

how to do watermarking using dct.

3 vues (au cours des 30 derniers jours)
yashi gautam
yashi gautam le 1 Fév 2016
Commenté : Ragini Gaikwad le 14 Juin 2021
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.
  1 commentaire
Karan Chandra
Karan Chandra le 22 Avr 2019
yashi can you send correct solution? please

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Fév 2016
dct2() and idct2() apply strictly to 2 dimensional matrices. Your wimg1 is 3 dimensional (RGB) so you cannot apply idct2 to it.
  4 commentaires
yashi gautam
yashi gautam le 1 Fév 2016
thanks for the help sir. :)
Ragini Gaikwad
Ragini Gaikwad le 14 Juin 2021
Can you please help on this, how to apply idct and then combine

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by