low pass filter for image analysis
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Jordan Ross
2016년 9월 23일
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).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!