Error using .* Matrix dimensions must agree

clc
close all
clear all % convert the image to grey
% frequency scaling
I = imread('c.jpg');
I1=rgb2gray(I);
ed=edge(I1,'canny',0.4);
[gx gy]=gradient(double(ed),0.5);
figure;
imshow(I);
gm=sqrt(gx.^2+gy.^2);
gdp=atan2(gy,gx);
%figure;
%imshow(gm);
figure; imshow(gdp);
A = fft2(double(I)); % compute FFT of the grey image
A1=fftshift(A); % frequency scaling
% Gaussian Filter Response Calculation
[M N]=size(A); % image size
R=10; % filter size parameter
X=0:N-1;
Y=0:M-1;
[X Y]=meshgrid(X,Y);
Cx=0.5*N;
Cy=0.5*M;
Lo=exp(-((X-Cx).^2+(Y-Cy).^2)./(2*R).^2);
Hi=1-Lo; % High pass filter=1-low pass filter
% Filtered image=ifft(filter response*fft(original image))
J=A1.*Lo;
J1=ifftshift(J);
B1=ifft2(J1);
%----visualizing the results----------------------------------------------
figure(3)
imshow(abs(B1),[12 290]), colormap gray
title('low pass filtered image','fontsize',14)
i am doing processing on image i found the gradient and then appy FFT2 on image and trying to appy low pass filter on image i have this error can anyone help me

1 个评论

Error using .* Matrix dimensions must agree.
Error in v1 (line 37) J=A1.*Lo; this is error

请先登录,再进行评论。

 采纳的回答

You have
A = fft2(double(I)); % compute FFT of the grey image
However, I is not your grayscale image: I1 is your grayscale image.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Color and Styling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by