Matrix Dimensions Must Agree

1 vue (au cours des 30 derniers jours)
Mesita Widia Cahyaning
Mesita Widia Cahyaning le 15 Sep 2019
Commenté : per isakson le 16 Sep 2019
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;

Réponses (1)

per isakson
per isakson le 15 Sep 2019
Modifié(e) : per isakson le 15 Sep 2019
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 commentaires
Walter Roberson
Walter Roberson le 16 Sep 2019
What is your current code?
per isakson
per isakson le 16 Sep 2019
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by