Matrix dimensions must agree.

7 visualizaciones (últimos 30 días)
Fei Teng
Fei Teng el 18 de Mayo de 2016
Respondida: Chad Greene el 18 de Mayo de 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

Respuestas (1)

Chad Greene
Chad Greene el 18 de Mayo de 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);

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by