Hello I'm new to mathlab and I'm facing this issue. I'm gonna making image watermarking using dct method and this is my code, hope i can find the solution of this, thankyou beforeee
clc;
clear all
I=imread('Sunset.jpg'); I=imresize(I,[300 300]);
if size(I,3)==3
I=rgb2gray(I);
end
figure,imshow(I), title('CITRA Penampung')
W=imread('copyright1.png'); I=imresize(I,[300 300]);
if size(W,3)==3
W=rgb2gray(W);
end
figure,imshow(W), title('CITRA Watermark')
alpha = 0.02;
A = dct2(double(I));
B = dct2(double(W));
C = A + alpha*B;
Iw = round(real(idct2(C)));
IIw = uint8(Iw)
figure,imshow(IIw), title('CITRA Terwatermark')
I=imread('Sunset.jpg'); I=imresize(I,[300 300]);
if size(I,3)==3
I=rgb2gray(I);
end
A=dct2(double(I));
C1=dct2(double(Iw));
B1=(C1-A)./alpha;
W1=uint8(idct2(B1));
figure,imshow(W1), title('CITRA Watermark Hasil Ekstraksi')
%this is the error I get
Matrix dimensions must agree.
Error in dctcoba (line 19)
C = A + alpha*B;

답변 (1개)

per isakson
per isakson 2019년 9월 15일
편집: per isakson 2019년 9월 15일

0 개 추천

Is this a copy&paste error?
W=imread('copyright1.png'); I=imresize(I,[300 300]);
Replacing the line by
W=imread('copyright1.png'); W=imresize(W,[300 300]);
might help.

댓글 수: 7

ohmygod.. my eyes:( thankyou! been replacing the line but now im facing another error:( what is this, can you help me:(
Matrix dimensions must agree.
Error in dct (line 76)
b = W .* fft(y);
Error in dct2 (line 49)
b = dct(dct(arg1).').';
Error in dctcoba (line 17)
A = dct2(double(I));
per isakson
per isakson 2019년 9월 15일
편집: per isakson 2019년 9월 15일
Run dbstop if error in the command window and start your script.
I failed to reproduce your error with R2018b. I used the first jpg-file I found on my computer. Your script produced four figures and ended without any messages.
Here all variable values are <300x300 double> (except for alpha) after the script finished!
Mesita Widia Cahyaning
Mesita Widia Cahyaning 2019년 9월 16일
Hello! Thankyou for trying out my codes! (: but I dont know why I still get the same error and also get different values for every variable.. What im supposed to do then:(
Walter Roberson
Walter Roberson 2019년 9월 16일
Put a breakpoint in at dctcoba line 17, at the call to dct2. Run. Then tell us what size(I) is
Question: why do you read in Sunset twice ?
Mesita Widia Cahyaning
Mesita Widia Cahyaning 2019년 9월 16일
Oh yes, I think I dont really need to re-read Sunset in line 24, and now I'm deleting it.
Done put a breakpoint and this is the values I get:
I = 300x300x3 uint8
W = 512x512 uint8
Walter Roberson
Walter Roberson 2019년 9월 16일
What is your current code?
per isakson
per isakson 2019년 9월 16일
The line number and the code of the error message doesn't agree with the code of your question. We are thus running diffent codes.

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2019년 9월 15일

댓글:

2019년 9월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by