Write a Matlab program that enables you to specify and keep only a proportion of
ID: 3108771 • Letter: W
Question
Write a Matlab program that enables you to specify and keep only a proportion of the Fourier Transforms of largest magnitude from an image representation. You should make use of the inbuilt 2D Fast Fourier Transform functions in Matlab. Write a Matlab program that enables you to specify and keep only a proportion of the Fourier Transforms of largest magnitude from an image representation. You should make use of the inbuilt 2D Fast Fourier Transform functions in Matlab. Write a Matlab program that enables you to specify and keep only a proportion of the Fourier Transforms of largest magnitude from an image representation. You should make use of the inbuilt 2D Fast Fourier Transform functions in Matlab.Explanation / Answer
Solution :
The Matlab code for reading in an image file, computing the magnitude spectrum, and plotting the requested images is as follows:
% plot_image_transform
%
% f=imread(’shuttle.tif’,’tiff’);
% f=imread(’xray.tif’,’tiff’);
f=imread(’hardware.tif’,’tiff’);
% plot original image in first quadrant
figure(1),subplot(221),imshow(f);
stitle=sprintf(’original tif file’);
title(stitle);
% compute image spectrum magnitude and plot in second quadrant
F=abs(fftshift(fft2(f)));
subplot(222),imshow(F, [ ]);
stitle1=sprintf(’abs of 2D FFT’);
title(stitle1);
% axis([-1 1 1 -1]);
xlabel(’horizontal frequency’),ylabel(’vertical frequency’);
% determine minimum and maximum of spectrum magnitude, print results
Fmin=min(min(F));
Fmax=max(max(F));
fprintf(’Fmin, Fmax: %f %f ’,Fmin,Fmax);
% scale magnitude based on Fmin and Fmax and plot in third quadrant
subplot(223),imshow(F, [1.5*Fmin, Fmax*1.e-3]);
stitle2=sprintf(’clipped/scaled abs of 2D FFT’);
title(stitle2);
xlabel(’horizontal frequency’),ylabel(’vertical frequency’);
% log scale magnitude and plot in fourth quadrant
subplot(224),imshow(log(1+F), [ ]);
stitle3=sprintf(’log transformed abs of 2D FFT’);
title(stitle3);
xlabel(’horizontal frequency’),ylabel(’vertical frequency’);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.