-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHIO.m
More file actions
27 lines (22 loc) · 763 Bytes
/
HIO.m
File metadata and controls
27 lines (22 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function [rs_output] = HIO(init_input,support,F0,beta, n_iter)
%% Hybrid input output algorithm, [Fienup, 1982]
%Inputs:
% init_input: initial diffraction pattern
% support: support mask
% F0: original diffraction pattern
% beta: feedback parameter
% n_iter: number of iterations
%Ouputs:
% rs_output: the real space estimatation of the object
g = ifftshift(ifft2(ifftshift((init_input)))); %initial i
for iter = 1:n_iter
F = fftshift(fft2(fftshift((g))));
F_satis = F0.*exp(1j.*angle(F));
g_dash = ifftshift(ifft2(ifftshift((F_satis))));
violate_cond = ~support | (real(g_dash)<0);
g_next = g_dash;
g_next(violate_cond) = g(violate_cond) - beta.*g_dash(violate_cond);
g = g_next;
end
rs_output = g_dash;
end