Fourier Transform from a computer generated hologram / Phase Mask

조회 수: 6 (최근 30일)
Simon
Simon 2014년 2월 25일
편집: Miloth 2017년 6월 30일
I am trying to perform a fourier transform of a phase mask to reconstruct my original image after having performed the fourier transform and extracting its phase. I am able to get a reconstructed image but it seems that the original image is overlayed with a x and y mirror image of the original image.
Does anyone know how I can get rid of this or what I am doing wrong?
My code is as follows:
clear all; close all;
I = imread('batman.gif', 'gif');
I = double(I);
I = I./max(max(I));
avgl=mean(mean(I));
figure; imshow(mat2gray(I));
title('Original Object');
figure;
axis([0 , 101, 0, 1]);
xlabel ('Number of Iterations')
ylabel ('RMSE')
hold on
I1 = I;
for n=1:101; %Iterations to optimize the phase hologram
H = fftshift((fft2(fftshift(I1))));
I2 = fftshift(fft2(fftshift(exp(1j.*angle(H)))));
avg2=mean(mean(abs(I2)));
I2=(I2./avg2).*avgl;
rmse=mean(mean((abs(I2)-I).^2))^0.5;
plot(n,rmse,'o');
pause(0.00001); %To see the error in each iteration.
I1=I.*exp(1j*angle(I2));
end
figure; imshow(H);
colormap gray
ti = get(gca,'TightInset')
set(gca,'Position',[ti(1) ti(2) 1-ti(3)-ti(1) 1-ti(4)-ti(2)]);
set(gca,'units','centimeters')
pos = get(gca,'Position');
ti = get(gca,'TightInset');
set(gcf, 'PaperUnits','centimeters');
set(gcf, 'PaperSize', [pos(3)+ti(1)+ti(3) pos(4)+ti(2)+ti(4)]);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition',[0 0 pos(3)+ti(1)+ti(3) pos(4)+ti(2)+ti(4)]);
imwrite(H, 'SupermanPhaseMask2.gif')
hold off
I2=I2./max(max(abs(I2)));
figure; imshow(abs(I2));
title('Reconstucted Image')
Any help would be amazing. Thanks in advance.
  댓글 수: 1
Patrick Bevington
Patrick Bevington 2016년 2월 26일
Hi, I realise you asked this question some time ago but the issue is that you are using:
imshow
If you use:
pcolor
this should fix it.
Thanks for the code you have provided, this has been very useful to me.

댓글을 달려면 로그인하십시오.

답변 (1개)

Miloth
Miloth 2017년 6월 30일
편집: Miloth 2017년 6월 30일
Hi, you used the fast Fourier transform fft2 in the first line inside the for cicle. You should use the inverse transform ifft2 instead:
H = fftshift((ifft2(fftshift(I1))));

카테고리

Help CenterFile Exchange에서 Digital Filter Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by