MATLAB Answers


Gaussian High Pass Filter

Asked by lina
on 27 Jul 2013
Latest activity Commented on by islam habeeb on 11 Feb 2015

Hello, I try to apply Gaussian High Pass Filter function

a=imread('img'); figure(1) imshow(a) [m n]=size(a); f_transform=fft2(a); f_shift=fftshift(f_transform); p=m/2; q=n/2; d0=70; for i=1:m for j=1:n distance=sqrt((i-p)^2+(j-q)^2); low_filter(i,j)=exp(-(distance)^2/(2*(d0^2))); end end filter_apply=f_shift.*low_filter; image_orignal=ifftshift(filter_apply); image_filter_apply=abs(ifft2(image_orignal)); figure(2) imshow(image_filter_apply,[])

but I got this error

??? Error using ==> times Matrix dimensions must agree.

can someone help me

  1 Comment

Implement non Gaussian for IPCA in Matlab | Crunch Modo

Log in to comment.

1 Answer

Answer by Youssef Khmou
on 27 Jul 2013
Edited by Youssef Khmou
on 27 Jul 2013
 Accepted Answer

hi lina,

I tried your program and it works fine, replace the first command with :


I think the error you get is due to the nature of the sample you use, maybe its RGB image, if so you need to change it to grayscale image or process each channel individually, try this as first attempt :



Well done thank you brother :)

if format of my picture is .jpg, can I use this program? or I must convert to .tif??? thankyou

No, that has nothing to do with it. No matter what format the image is stored in on disk, once imread gets done with it, it's just a regular array of numbers.

Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!