Matrix dimensions must agree.

7 Ansichten (letzte 30 Tage)
Fei Teng
Fei Teng am 18 Mai 2016
Beantwortet: Chad Greene am 18 Mai 2016
I want to use the following code to do a lowpass filtering with my figure
f = imread('mri_snapshot.jpg'); PQ = 2*size(f); [U, V] = dftuv(PQ(1),PQ(2)); D = sqrt(U.^2+V.^2); D0 = 0.05*PQ(2); F = fft2(f,PQ(1),PQ(2)); H = exp(-(D.^2)/(2*(D0^2))); g = real(ifft2(H.*F)); g = g(1:size(f,1),1:size(f,2)); figure; imshow(g,[])
but g = real(ifft2(H.*F));, H.*F, the matrix dimension is not agree, because F = 956x928X3 while H= 956x928

Antworten (1)

Chad Greene
Chad Greene am 18 Mai 2016
You could do this separately for the R, G, and B components of the image, then concatenate:
gR = real(ifft2(H.*squeeze(F(:,:,1))));
gG = real(ifft2(H.*squeeze(F(:,:,2))));
gB = real(ifft2(H.*squeeze(F(:,:,3))));
g = cat(3,gR,gG,gB);

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by