Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need the code only .. You have to choose 2 images at same size to apply the in

ID: 2085566 • Letter: I

Question

I need the code only .. You have to choose 2 images at same size to apply the instruction using 2 images . Please apply the code only Using MATLaAB
Project 1: Combining phase of one image with magnitude of other Image (DFT) Instructions: Read image of your choice by using imread function Convert it to grayscale if it is in RGB by using rgb2gray function Apply fourier transform on both the images by using FFT2 function Plot magnitude and phase spectrums Apply log transformation in order to enhance the high frequency components in magnitude spectrum Combine the phase of one image with magnitude of other Plot all the figures and comment them by using matlab Use subplot function in order to plot the image and its corresponding 2 ' spectrums .Please use "publish" to get all the figures in word document

Explanation / Answer

% image_comp.m

clc;
close all;
clear all;

X1 = imread('lenna.jpg');
%image(x1);

X2 = imread('lenna.jpg');
%image(X2);

GRAY_X1 = rgb2gray(X1);
%image(GRAY_X1);

GRAY_X2 = rgb2gray(X2);
%image(GRAY_X2);

FFT_GRAY_X1 = fft2(GRAY_X1);
figure
subplot(3,1,1);
plot(abs(FFT_GRAY_X1));grid;
title('MAGNITUDE SPECTRUM');
subplot(3,1,2);
plot(angle(FFT_GRAY_X1));grid;
title('PHASE SPECTRUM');
subplot(3,1,3);
plot(log_tran(abs(FFT_GRAY_X1),10));grid;
title('LOG TRANSFORM');


FFT_GRAY_X2 = fft2(GRAY_X2);
figure
subplot(3,1,1);
plot(abs(FFT_GRAY_X2));grid;
title('MAGNITUDE SPECTRUM');
subplot(3,1,2);
plot(angle(FFT_GRAY_X2));grid;
title('PHASE SPECTRUM');
subplot(3,1,3);
plot(log_tran(abs(FFT_GRAY_X2),10));grid;
title('LOG TRANSFORM');


%COMBINING PHASE OF IMAGE1 WITH MAGNITUDE OF IMAGE2
COMBN = abs(FFT_GRAY_X1).*exp(i*angle(FFT_GRAY_X2));
IFFT_COMBN = ifft2(COMBN);
figure
plot(IFFT_COMBN);
title('COMBINED IMAGE');
image(abs(IFFT_COMBN));


copyfile(fullfile(matlabroot,'image_comp.m'),'.','f');
my_doc = publish('image_comp.m','doc');

%log_tran.m

function z = log_tran( g,c )
[M,N]=size(g);
for x = 1:M
for y = 1:N
m=double(g(x,y));
z(x,y)=c.*log10(1+m); %#ok<AGROW>
end
end
% return z;
end