low pass filter for image analysis

25 visualizzazioni (ultimi 30 giorni)
Snowleopard
Snowleopard il 16 Set 2016
Commentato: Snowleopard il 24 Set 2016
I am doing low pass filtering of an image.After applying mask and I need to get filtered image but instead I am getting I6 as attached. I have tried with different mask sizes but still unable to get the same image back with low frequency content. Can you plz check the code and point the mistake in code or methodology.
Thanks in advance,
if true
% code
clc
close all
clear all
I1 = imread('C:\User\Desktop\taken\s3.jpg');
I1 = imresize(I1,[128 128]);
I2 = rgb2gray(I1)
I2=double(I2);
figure, imshow(uint8(I2));
I3=fft2(I2);
I3=fftshift(I3);
figure
I4=log(1+abs(I3));
imshow(mat2gray(I4));
[r,c]=size(I2);
orgr=r/2;
orgc=c/2;
mf= zeros(r,c);
D0= 40;
for i=1:r
for j=1:c
if((i-orgr)^2+(j-orgc)^2)^(0.5)<=D0
mf(i,j)=1;
end
end
end
figure
imshow(uint8(255*mf));
title('frequency domain filter used');
I5=I3*mf;
figure,
I4=log(1+abs(I5));
imshow(mat2gray(I4));
title('filtered image in frequency domain');
I6=ifft2(ifftshift(I5));
figure,
imshow(uint8(abs(I6)));
title('filtered gray scale image');
end

Risposta accettata

Jordan Ross
Jordan Ross il 23 Set 2016
Hi,
It seems you have an error in your code. The following line:
I5=I3*mf;
Should be:
I5=I3.*mf;
After making this change I was able to retrieve the image back (see the attached file).

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by