d. add gaussian noise with parameters m=0, v=0.04 to your image. you will see the added noise in frequency space at low filter with a pass filter. in matlab

To add Gaussian noise with parameters m=0, v=0.04 to an image in MATLAB, you can use the imnoise function as follows:

main.m
img = imread('path_to_image');
noisy_img = imnoise(img,'gaussian', 0, 0.04);
77 chars
3 lines

This will add Gaussian noise with mean m=0 and variance v=0.04 to the image.

To visualize the added noise in frequency space, you can take the Fourier Transform of the original and noisy image using fft2, and then visualize the resulting magnitude spectra using mat2gray and imshow functions.

main.m
img_freq = fft2(img);
noisy_img_freq = fft2(noisy_img);

img_mag = mat2gray(log(1+abs(img_freq)));
noisy_img_mag = mat2gray(log(1+abs(noisy_img_freq)));

subplot(1,2,1), imshow(img_mag), title('Original Image')
subplot(1,2,2), imshow(noisy_img_mag), title('Noisy Image')
271 chars
9 lines

To filter the noise in frequency space using a low pass filter, you can create a filter using fspecial function in MATLAB and then apply it to the noisy image frequency domain. For example, to apply a Gaussian filter with standard deviation of 5 pixels, you can use the following code:

main.m
filter = fspecial('gaussian', [size(noisy_img,1) size(noisy_img,2)], 5);
noisy_img_filtered_freq = noisy_img_freq .* fft2(filter);

noisy_img_filtered = real(ifft2(noisy_img_filtered_freq));
191 chars
5 lines

Now, you can visualize the filtered image and its frequency spectrum as above using mat2gray and imshow functions.

related categories

gistlibby LogSnag