# applying Ideal low-pass with Gaussian noise image

5 views (last 30 days)
Maitha Ahmad on 20 Apr 2021
Answered: Pratyush Roy on 27 Apr 2021
why we are not getting the right result of the filterd one?
figure(1);
original=imshow(I)
title('original image');
J = imnoise(I,'gaussian',40/255,(20/255)^2)
figure(2);
imshow(J)
title('Gussain noise');
% Saving the size of the input_image in pixels-
% M : no of rows (height of the image)
% N : no of columns (width of the image)
[M, N] = size(J);
% Getting Fourier Transform of the input_image
% using MATLAB library function fft2 (2D fast fourier transform)
FT_img = fft2(double(J));
% Assign Cut-off Frequency
r0 = 30;
% Designing filter
u = 0:(M-1);
idx = find(u>M/2);
u(idx) = u(idx)-M;
v = 0:(N-1);
idy = find(v>N/2);
v(idy) = v(idy)-N;
% MATLAB library function meshgrid(v, u) returns
% 2D grid which contains the coordinates of vectors
% v and u. Matrix V with each row is a copy
% of v, and matrix U with each column is a copy of u
[V, U] = meshgrid(v, u);
% Calculating Euclidean Distance
D = sqrt(U.^2+V.^2);
% Comparing with the cut-off frequency and
H = double(D <= r0);
% Convolution between the Fourier Transformed
G = H.*FT_img;
% Getting the resultant image by Inverse Fourier Transform
% of the convoluted image using MATLAB library function
% ifft2 (2D inverse fast fourier transform)
output_image = real(ifft2(double(G)));
% Dispaly result
figure(3);
imshow(output_image);
title(' Result r0=30 ');

Pratyush Roy on 27 Apr 2021
Hi,
You can use the mat2gray function to map the output image values between 0 and 1, where 0 represents black, 1 represents white and the intermediate values represent various shades of gray. The code snippet below illustrates how to use the function:
% Dispaly result
figure(3);
imshow(mat2gray(output_image));
title(' Result r0=30 ');
Hope this helps!