matlab matrices error for image analysis

1 view (last 30 days)
NiI133
NiI133 on 6 Aug 2015
Commented: NiI133 on 6 Aug 2015
Trying to apply low pass filter to a black and white checkerboard following FFT, but don't understand why I continue to get this matrices error? Thank you in advance for your help!
a=imread(checkerboardbwlarge.jpg); %Image is 276 x 276
af=fftshift(fft2(a));
figure,imshow(af);
fftshow(af);
[x,y]=meshgrid(-138:137,-138:137);
z=sqrt(x.^2+y.^2);
c=z<15
af1=af.*c;
Error using .*
Matrix dimensions must agree.

Answers (1)

Walter Roberson
Walter Roberson on 6 Aug 2015
.jpg images are never 2 dimensional; .jpg always uses RGB. You need
af=fftshift(fft2(a(:,:,1)));
  1 Comment
NiI133
NiI133 on 6 Aug 2015
the image is a checkerboard so i assumed I did not have to change it to grayscale. Will try this and see if it works. Thank you!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!