How to implement Gaussian filter spectrum?
Mostrar comentarios más antiguos
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))
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 30 de Abr. de 2021
0 votos
Did you try imgaussfilt()?
2 comentarios
Mahabba Almheiri
el 30 de Abr. de 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
Categorías
Más información sobre Image Filtering en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
