Untitled
unknown
plain_text
5 months ago
2.4 kB
5
Indexable
Frequency Domain 1. Fourier Transform and Frequency Domain: Implement a MATLAB script to compute the 2D Fourier Transform of a grayscale image, shift the zero-frequency component to the center, and display the magnitude spectrum. img = imread('image.jpg'); gray_img = rgb2gray(img); fft_img = fftshift(fft2(double(gray_img))); magnitude_spectrum = log(1 + abs(fft_img)); imshow(magnitude_spectrum, []); 2. Smoothing Frequency Domain Filters: Write a MATLAB script to apply an ideal low-pass filter in the frequency domain to a grayscale image. Display the original and filtered images. img = imread('image.jpg'); gray_img = rgb2gray(img); fft_img = fftshift(fft2(double(gray_img))); [M, N] = size(gray_img); [X, Y] = meshgrid(1:N, 1:M); D0 = 50; % Cut-off frequency H = sqrt((X - N/2).^2 + (Y - M/2).^2) <= D0; filtered_img = ifft2(ifftshift(H .* fft_img)); imshow(real(filtered_img), []); 3. High-Pass Filtering: Implement a script to apply an ideal high-pass filter to an image in the frequency domain. img = imread('image.jpg'); gray_img = rgb2gray(img); fft_img = fftshift(fft2(double(gray_img))); [M, N] = size(gray_img); [X, Y] = meshgrid(1:N, 1:M); D0 = 50; H = sqrt((X - N/2).^2 + (Y - M/2).^2) > D0; filtered_img = ifft2(ifftshift(H .* fft_img)); imshow(real(filtered_img), []); 1. Image Degradation and Restoration Process Question: Write a MATLAB script to simulate an image degradation process using a motion blur function and then restore the image using inverse filtering. % Simulate Image Degradation img = imread('image.jpg'); psf = fspecial('motion', 21, 11); % Motion blur PSF degraded_img = imfilter(img, psf, 'conv', 'circular'); % Restore Image using Inverse Filtering F_degraded = fft2(degraded_img); F_psf = fft2(psf, size(img, 1), size(img, 2)); restored_img = ifft2(F_degraded ./ F_psf); % Display Results imshowpair(degraded_img, restored_img, 'montage'); 2. Noise Models and Spatial Filtering Question: Implement a MATLAB script to add Gaussian noise to an image and then apply a 5x5 median filter to reduce the noise. % Add Gaussian Noise img = imread('image.jpg'); noisy_img = imnoise(img, 'gaussian', 0, 0.01); % Apply 5x5 Median Filter filtered_img = medfilt2(noisy_img, [5 5]); % Display Results imshowpair(noisy_img, filtered_img, 'montage');
Editor is loading...
Leave a Comment