필터 지우기
필터 지우기

Image reconstruction only by its phase or magnitude

조회 수: 4 (최근 30일)
Mithra
Mithra 2013년 11월 17일
답변: mugambi ndwiga 2017년 4월 20일
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