how to do watermarking using dct.

1 visualización (últimos 30 días)
yashi gautam
yashi gautam el 1 de Feb. de 2016
Comentada: Ragini Gaikwad el 14 de Jun. de 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 comentario
Karan Chandra
Karan Chandra el 22 de Abr. de 2019
yashi can you send correct solution? please

Iniciar sesión para comentar.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by