MATLAB Answers

Bandpass filter applied to an image

11 views (last 30 days)
so my question is how do I make a bandpass filter. I have never used one. Bandpass docs online show only a version of sinals. how do I use it for a picture? thanks

  0 Comments

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 2 Dec 2019
Hints. One way is to fft2() the image, then zero out some portion of the spectrum, then ifft2().
A second way is to do a difference of Gaussians filter -- check out fspecial() and conv2().

  2 Comments

Smit Patel
Smit Patel on 2 Dec 2019
%% Problem 4
a=imread('bookshelf.jpg');
a1=double(rgb2gray(a));
figure(1)
a2=fft2(a1);
imshow(a2,[0 10000]);
figure(2)
a3=imgaussfilt(a1,200);
imshow(a3,[0 100]);
a4=a2-a3;
figure(3)
imshow(a4,[0 10000]);
figure(4)
a5=ifftshift(a4);
imshow(a5,[0 10000]);
I tried but I don't get the desired image. can you tell me what I am doing wrong? pls? thanks!
Image Analyst
Image Analyst on 3 Dec 2019
You're trying to combine both methods that I told you into one. Don't do that. Do just one or the other. If you want to do the fft method, just zero out parts of the a2 arrays. Don't do anything with gaussian kernels for that method. Something like
ra2 = real(a2); % Get real part
ia2 = imag(a2); % Get imaginary part
ra2(row1:row2, col1:col2) = 0; % Repeat for other ranges. You determine the rows and columns.
% Same for ia2, then combine ra2 and ia2 back into complex array and call ifft2
See what you can do with that.

Sign in to comment.

More Answers (0)

Sign in to answer this question.