Borrar filtros
Borrar filtros

Matrix Dimensions Must Agree

2 visualizaciones (últimos 30 días)
Ishtiaq Bercha
Ishtiaq Bercha el 6 de Mzo. de 2012
I have the following code and am trying to apply the Gaussian filter: I do not know how the fix the matrix dimensions mismatch problem in this case and in general. Can I request some help. I wasnt able to fix this on my own.
CODE:
clc;
I = imread('C:\Documents and Settings\122244\Desktop\CT.JPG');
figure, imshow(I,[]);
J = fftshift(fft2(I));
L = log(1+abs(J));
figure, imshow(mat2gray(L),[]);
[j,k] = size(J);
gs=zeros(j,k);
sig=20;
for m=1:j;
for n=1:k;
gs(m,n)=exp(-((m-366)^2+(n-366)^2)/(2*sig^2));
end
end
gs = fftshift(fft2(gs));
M = log(1+abs(gs));
figure, imshow(M,[]);
FLT = gs.*J;% Error line where I get matrix dimension error.
FI = abs((ifft2(FLT)));
figure,imshow(FI,[]);
I couldnt find any help online as well.
Regards, ---Ish

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 6 de Mzo. de 2012
dbstop if error
then run your file
what is?
size(gs)
size(J)
It should be obvious at this point.
  5 comentarios
Sean de Wolski
Sean de Wolski el 6 de Mzo. de 2012
So it's being read in as rgb with all three slices (r,g,b) being the same? If this is the case:
gs = gs(:,:,1); % keep only first slice.
Ishtiaq Bercha
Ishtiaq Bercha el 6 de Mzo. de 2012
I did that to the original image and it seems to have resolved the issue! Thanks a bunch!
---Ish

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by