How to implement Gaussian filter spectrum?
Show older comments
I have a problem in the code. I want to plot the spectrum of the Gaussian filter but I got wrong spectrum. Can you please help me to correct the following code :
I=imread('cameraman.tif');
figure(1);
original=imshow(I)
title('original image');
SP = imnoise(I,'salt & pepper',0.1);
figure(2);
imshow(SP)
title('salt & pepper noise');
h=fspecial('gaussian',[256 256] ,10/256);
result = imfilter(SP,h,'replicate');
figure(3)
imshow(result);
title('Result sigma=10 ');
figure(4)
H = abs(fft2(h));
mesh(x,y,(H))
Accepted Answer
More Answers (1)
Image Analyst
on 30 Apr 2021
0 votes
Did you try imgaussfilt()?
2 Comments
Mahabba Almheiri
on 30 Apr 2021
I'm guessing you probably want to center the spectrum with fftshift()
Your x and y are undefined, so you'll either have to define them or just let them be implicit.
figure(4)
H = abs(fftshift(fft2(h)));
mesh(H)
I also don't know why you need [256 256] worth of support for a filter with a sigma of 0.0392
Categories
Find more on Image Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!