MATLAB: What will the image look like

fft2fftshift

A = abs(fftshift(fft2(A)));
B = angle(fftshift(fft2(B)));
C = A .* exp(i * B);
D = abs(ifft2(ifftshift(C)));
What will image D look like? Image A is of an eagles face, Image B is a woman.
Thanks for the help, just trying to study

Best Answer

Why don't you try it and see. You'll learn more that way. I've provided code for you to begin your discoveries with:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in cameraman.
grayImage = imread('cameraman.tif');
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
subplot(2, 3, 1);
imshow(grayImage, []);
axis on;
title('Image #1', 'FontSize', fontSize);
% Read in another image.
% Read in a standard MATLAB gray scale demo image.

folder = fullfile(matlabroot, '\toolbox\images\imdemos');
button = menu('Use which demo image?', 'CameraMan', 'Moon', 'Eight', 'Coins', 'Pout');
if button == 1
baseFileName = 'cameraman.tif';
elseif button == 2
baseFileName = 'moon.tif';
elseif button == 3
baseFileName = 'eight.tif';
elseif button == 4
baseFileName = 'coins.png';
else
baseFileName = 'pout.tif';
end
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage2 = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage2);
if numberOfColorBands > 1
% It's not really gray scale like we expected - it's color.
% Convert it to gray scale by taking only the green channel.
grayImage2 = grayImage2(:, :, 2); % Take green channel.
end
% Make it the same size as cameraman.
grayImage2 = imresize(grayImage2, size(grayImage));
subplot(2, 3, 2);
imshow(grayImage2, []);
axis on;
title('Image #2', 'FontSize', fontSize);
A = abs(fftshift(fft2(grayImage)));
subplot(2, 3, 4);
imshow(log(A), []);
axis on;
title('Mag of Image #1', 'FontSize', fontSize);
B = angle(fftshift(fft2(grayImage2)));
subplot(2, 3, 5);
imshow(B, []);
axis on;
title('Phase angle of Image #2', 'FontSize', fontSize);
C = A .* exp(i * B);
D = abs(ifft2(ifftshift(C)));
subplot(2, 3, 6);
imshow(D, []);
axis on;
title('Product', 'FontSize', fontSize);
Related Question