Matrix dimensions must agree.

5 Ansichten (letzte 30 Tage)
John rayedshahin
John rayedshahin am 18 Nov. 2020
Kommentiert: John rayedshahin am 18 Nov. 2020
I have this code here, where I try to generate a final image for a spectum of one image and phase of another image, and the vice versa, as shown below:
but I am getting an error: Matrix dimensions must agree.
girl = imread('girl.tif');
a = imread('letterA.tif');
F = fft2(girl);
A = fft2(a);
sgirl = abs(F);
sA = abs(A);
phigirl = angle(F);
phiA = angle(A);
%generate an image by using the spectrum of the letter image and the phase of the girl image.
g = sA.*exp(1i*phigirl);
%Form an image from the spectrum of the girl and the phase of the letter.
h = sgirl.*exp(1i*phiA);
subplot(1,2,1);
imshow(g);
title('sA and phigirl');
subplot(1,2,2);
imshow(h);
title('sgirl and phiA');

Akzeptierte Antwort

KALYAN ACHARJYA
KALYAN ACHARJYA am 18 Nov. 2020
Bearbeitet: KALYAN ACHARJYA am 18 Nov. 2020
May be both image are not having equal size, please modify. As there are elementwise multiplication in g and h lines.
girl = imread('girl.tif');
[r,c,ch]=size(girl);
a = imread('letterA.tif');
a=imresize(a,[r,c]);
....same code
  2 Kommentare
John rayedshahin
John rayedshahin am 18 Nov. 2020
Yes it worked, thank you
John rayedshahin
John rayedshahin am 18 Nov. 2020
I completely forgot they're different sizes.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by