Commit eb0c791b authored by alexander.dornheim's avatar alexander.dornheim
Browse files

Added Siemens_processor not yet working

parent d89c86f5
# data reader/processor
import numpy as np
from numpy.linalg import norm
from numpy.fft import fft2, ifft2
from numpy.random import rand
import proxtoolbox.Utilities as Utilities
def Siemens_processor(config):
data_ball = config['data_ball']
noise = config['noise']
snr = config['data_ball']
print('Loading data file: Siemens_star_200px.mat')
S = np.loadtxt('../InputData/phase_retrieval/Siemens_star_200px.mat')
S=Utilities.ZeroPad(S)
dim =np.shape(S)
config['Nx'] = dim[1]
config['Ny'] = dim[0]
if config['object'] == 'real' or config['object'] == 'nonnegative':
M=abs(fft2(S))
# config['data_ball']=config['Nx']*config['Ny']*data_ball
config['rt_data']=M
# standard for the main program is that
# the data field is the magnitude SQUARED
# in Luke.m this is changed to the magnitude.
config['data']=M**2
config['norm_rt_data']=norm(S,'fro')
config['norm_data']=config['norm_rt_data']^2
config['data_zeros'] = np.where(M==0)
# below, we make the support too small to increase the inconsistency
# Stmp=zeros(size(S))
# Stmp((m/2-m/4):(m/2+m/4),(n/2-n/4):(n/2+n/4))=S((m/2-m/4):(m/2+m/4),(n/2-n/4):(n/2+n/4))
# S=Stmp
config['supp_ampl'] = npnonzero(S)
# use the abs_illumination field to represent the
# support constraint.
config['abs_illumination'] = config['norm_rt_data']*S/(norm(S,'fro'))
config['abs_illumination'] = config['abs_illumination']/norm(config['abs_illumination'],'fro')*config['norm_rt_data'][0]
config['supp_phase'] = find(ones(m,n))
config['illumination_phase'] = find(ones(m,n))
elif config['object'] == 'complex':
# put some phase across S
points = config['Nx']
config['norm_rt_data']=norm(S,'fro')
config['norm_data']=config['norm_rt_data']**2
# use the abs_illumination field to represent the
# support constraint.
config['abs_illumination'] = config['norm_rt_data']*S/(norm(S,'fro'))
# input.abs_illumination = input.abs_illumination/norm(input.abs_illumination,'fro')*input.norm_rt_data(1)
G=np.zeros(S.shape)# Gaussian(points,10,[points/2+1,points/2+1])
W=S*np.exp(1j*2*np.pi*G)
M=abs(fft2(W))
# config['data_ball']=config['Nx']*config['Ny']*data_ball
config['rt_data']=M
# standard for the main program is that
# the data field is the magnitude SQUARED
# in Luke.m this is changed to the magnitude.
config['data']=M**M
config['data_zeros'] = np.where(M==0)
config['supp_ampl'] = np.nonzero(S)
elif config['object'] == 'phase':
# put some phase across S
points = config['Nx']
# use the abs_illumination field to represent the
# support constraint.
config['abs_illumination'] = ones(S.shape)
G=Gaussian(points,10,[points/2+1,points/2+1])
W=np.exp((1j*2*pi)*S*G)
config['norm_rt_data']=norm(W,'fro')
M=abs(fft2(W))
# config['data_ball=config['Nx*config['Ny*data_ball
config['rt_data']=M
config['norm_data']=config['norm_rt_data']**2
# standard for the main program is that
# the data field is the magnitude SQUARED
# in Luke.m this is changed to the magnitude.
config['data']=M**M
config['data_zeros'] = np.where(M==0)
config['supp_ampl'] = np.nonzero(W)
config['supp_phase'] = S
config['illumination_phase'] = S
# initial guess
config['u_0'] = ifft2(M*np.exp(2*np.pi*1j*rand(dim[0],dim[1])))
# config['u_0 = ifft2(M.*exp(2*pi*1i*Gaussian(N,N/2,[N/2+1,N/2+1]))).*S
# config['u_0 = config['u_0/norm(config['u_0,'fro')*config['abs_illumination
config['product_space_dimension'] = 1
config['truth'] = S
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment