Having trouble getting my gaussian filter to display filtered image.
Show older comments
I believe my issue is with image sizing but I can't seem to solve the issue I am having with outputting the filtered image. Any help would be greatly appreciated.
% Load the image and convert it to grayscale if necessary
img = imread('cameraman.tif');
if size(img1, 3) == 3
img = rgb2gray(img);
end
% Compute the size of the image
[m,n] = size(img);
% Define the standard deviation of the Gaussian filter
sigma = 10;
% Create the Gaussian low pass filter in the frequency domain
H = fspecial('gaussian',[m n],sigma);
% Apply the filter to the image in the frequency domain
Fimg = fft2(img);
Fimg = Fimg .* H;
% Transform the filtered image back to the spatial domain
filtered_img = ifft2(Fimg)
% Display the original and the filtered image
subplot(1, 2, 1);
imshow(img);
title('Original image');
subplot(1, 2, 2);
imshow(real(filtered_img));
title('Filtered image');
Accepted Answer
More Answers (0)
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!