Azzera filtri
Azzera filtri

applying Ideal low-pass with Gaussian noise image

2 visualizzazioni (ultimi 30 giorni)
Maitha Ahmad
Maitha Ahmad il 20 Apr 2021
Risposto: Pratyush Roy il 27 Apr 2021
why we are not getting the right result of the filterd one?
title('original image');
J = imnoise(I,'gaussian',40/255,(20/255)^2)
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
% determining the filtering mask
H = double(D <= r0);
% Convolution between the Fourier Transformed
% image and the mask
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
title(' Result r0=30 ');

Risposte (1)

Pratyush Roy
Pratyush Roy il 27 Apr 2021
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
title(' Result r0=30 ');
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by