Image reconstruction only by its phase or magnitude

4 次查看(过去 30 天)
I have an image, I separate its phase and magnitude using fft2 , then I try to reconstruct it
  1. Only by magnitude
  2. Only by phase
Here is my code:
image = rgb2gray(imread('pillsetc.png'));
F = fft2(double(image));
F_Mag = abs(F);
F_Phase = exp(1i*angle(F));
% reconstructin
I_Mag = ifft2(log(F_Mag+1));
I_Phase = ifft2(F_Phase);
% Calculate limits for plotting
I_Mag_min = min(min(abs(I_Mag)));
I_Mag_max = max(max(abs(I_Mag)));
I_Phase_min = min(min(abs(I_Phase)));
I_Phase_max = max(max(abs(I_Phase)));
% Display reconstructed images
subplot(121),imshow(abs(I_Mag),[I_Mag_min I_Mag_max]), colormap gray
title('reconstructed image only by Magnitude');
subplot(122),imshow(abs(I_Phase),[I_Phase_min I_Phase_max]), colormap gray
title('reconstructed image only by Phase');
But I don't know what is the problem with reconstruction by magnitude that it only shows a totally black image!!! What's wrong with the code? How can I fix it?
Thanks in advance

回答(1 个)

mugambi ndwiga
mugambi ndwiga 2017-4-20
Try using "imagesc" instead of "imshow"

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by