Matrix dimensions must agree.

7 vues (au cours des 30 derniers jours)
Fei Teng
Fei Teng le 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

Réponses (1)

Chad Greene
Chad Greene le 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);

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by