How to implement Gaussian filter spectrum?
Mostra commenti meno recenti
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))
Risposta accettata
Più risposte (1)
Image Analyst
il 30 Apr 2021
0 voti
Did you try imgaussfilt()?
2 Commenti
Mahabba Almheiri
il 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
Categorie
Scopri di più su Image Filtering in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
