how to do watermarking using dct.

조회 수: 1 (최근 30일)
yashi gautam
yashi gautam 2016년 2월 1일
댓글: Ragini Gaikwad 2021년 6월 14일
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
Karan Chandra
Karan Chandra 2019년 4월 22일
yashi can you send correct solution? please

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

채택된 답변

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
yashi gautam
yashi gautam 2016년 2월 1일
thanks for the help sir. :)
Ragini Gaikwad
Ragini Gaikwad 2021년 6월 14일
Can you please help on this, how to apply idct and then combine

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by