in admm2.py [0:0]
def cs_baseline(m, n, f, mask, mu, beta, n_iter):
"""
Recovers an image from a subset of its frequencies without any FFTs.
Reconstructs an m x n image from the subset f of its frequencies specified
by mask, using ADMM as in function adm (with regularization parameter mu,
coupling parameter beta, and number of iterations n_iter).
Unlike function cs_fft, this cs_baseline avoids any FFTs, so runs slowly.
_N.B._: mask[0, 0] must be True to make the optimization well-posed.
Parameters
----------
m : int
number of rows in the image being reconstructed
n : int
number of columns in the image being reconstructed
f : ndarray
potentially nonzero entries (prior to the inverse Fourier transform)
mask : numpy.ndarray
boolean indicators of the potential nonzeros in the full m x n array
-- note that the zero frequency entry must be True in order to make the
optimization well-posed
mu : float
regularization parameter
beta : float
coupling parameter for the ADMM iterations
n_iter : int
number of ADMM iterations to conduct
Returns
-------
ndarray
reconstructed m x n image
float
objective value at the end of the ADMM iterations (see function adm)
"""
assert mask[0, 0]
# Index the True values in mask.
mask_nnz = mask.nonzero()
# Sample the discrete Fourier transform.
Kx = scipy.linalg.dft(m) / np.sqrt(m)
Ky = scipy.linalg.dft(n) / np.sqrt(n)
# Initialize K to be a complex ndarray.
K = np.zeros((len(mask_nnz[0]), m * n))
K = K + 0j * K
# Fill K with the appropriate outer products.
for k in range(len(mask_nnz[0])):
outerprod = np.outer(Kx[mask_nnz[0][k], :], Ky[mask_nnz[1][k], :])
K[k, :] = outerprod.reshape((m * n))
# Form the forward finite-difference matrices.
fdx = scipy.linalg.circulant([1, -1] + [0] * (n - 2))
fdy = scipy.linalg.circulant([1, -1] + [0] * (m - 2))
# Form the matrix taking finite differences horizontally in an image.
Dx = np.kron(np.eye(m), fdx)
# Form the matrix taking finite differences vertically in an image.
Dy = np.kron(fdy, np.eye(n))
# Stack the horizontal and vertical finite-difference matrices.
D = np.vstack((Dx, Dy))
# Run n_iter iterations of ADMM with coupling beta.
return adm(f, K, D, mu, beta, n_iter)