示例#1
0
 def test_11(self):
     N = 63
     M = 4
     Nd = 8
     D = np.random.randn(Nd, Nd, M)
     X0 = np.zeros((N, N, M))
     xr = np.random.randn(N, N, M)
     xp = np.abs(xr) > 3
     X0[xp] = np.random.randn(X0[xp].size)
     S = np.sum(ifftn(
         fftn(D, (N, N), (0, 1)) * fftn(X0, None, (0, 1)), None,
         (0, 1)).real,
                axis=2)
     lmbda = 1e-2
     L = 1e3
     opt = cbpdn.ConvBPDN.Options({
         'Verbose': False,
         'MaxMainIter': 2000,
         'RelStopTol': 1e-9,
         'L': L,
         'Backtrack': BacktrackStandard()
     })
     b = cbpdn.ConvBPDN(D, S, lmbda, opt)
     b.solve()
     X1 = b.X.squeeze()
     assert sl.rrs(X0, X1) < 5e-4
     Sr = b.reconstruct().squeeze()
     assert sl.rrs(S, Sr) < 2e-4
示例#2
0
 def test_05(self):
     N = 16
     Nd = 5
     K = 2
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, K)
     lmbda = 1e-1
     b = cbpdn.ConvBPDN(D, s, lmbda)
     assert b.cri.dimC == 0
     assert b.cri.dimK == 1
示例#3
0
 def test_03(self):
     N = 16
     Nd = 5
     Cd = 3
     M = 4
     D = np.random.randn(Nd, Nd, Cd, M)
     s = np.random.randn(N, N, Cd)
     lmbda = 1e-1
     b = cbpdn.ConvBPDN(D, s, lmbda)
     assert b.cri.dimC == 1
     assert b.cri.dimK == 0
示例#4
0
 def test_01(self):
     N = 16
     Nd = 5
     Cs = 3
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, Cs)
     lmbda = 1e-1
     b = cbpdn.ConvBPDN(D, s, lmbda, dimK=0)
     assert b.cri.dimC == 1
     assert b.cri.dimK == 0
示例#5
0
 def test_02(self):
     N = 16
     Nd = 5
     Cs = 3
     K = 5
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, Cs, K)
     lmbda = 1e-1
     b = cbpdn.ConvBPDN(D, s, lmbda)
     assert b.cri.dimC == 1
     assert b.cri.dimK == 1
示例#6
0
 def test_09(self):
     N = 16
     Nd = 5
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N)
     try:
         b = cbpdn.ConvBPDN(D, s)
         b.solve()
     except Exception as e:
         print(e)
         assert 0
示例#7
0
 def test_12(self):
     N = 16
     Nd = 5
     Cs = 3
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, Cs)
     lmbda = 1e-1
     L = 1e3
     opt = cbpdn.ConvBPDN.Options({'L': L})
     b = cbpdn.ConvBPDN(D, s, lmbda, opt=opt, dimK=0)
     b.solve()
     assert np.array(b.getitstat().Rsdl)[-1] < 1e-3
示例#8
0
 def test_18(self):
     N = 16
     Nd = 5
     Cs = 3
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, Cs)
     lmbda = 1e-1
     L = 1e3
     try:
         opt = cbpdn.ConvBPDN.Options({'Monotone': True, 'L': L})
         b = cbpdn.ConvBPDN(D, s, lmbda, opt=opt, dimK=0)
         b.solve()
     except Exception as e:
         print(e)
         assert 0
     assert np.array(b.getitstat().Rsdl)[-1] < 1e-3
示例#9
0
 def test_06(self):
     N = 16
     Nd = 5
     K = 2
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, K)
     dt = np.float32
     opt = cbpdn.ConvBPDN.Options({
         'Verbose': False,
         'MaxMainIter': 20,
         'Backtrack': BacktrackStandard(),
         'DataType': dt
     })
     lmbda = 1e-1
     b = cbpdn.ConvBPDN(D, s, lmbda, opt=opt)
     b.solve()
     assert b.X.dtype == dt
     assert b.Xf.dtype == fft.complex_dtype(dt)
     assert b.Yf.dtype == fft.complex_dtype(dt)
示例#10
0
"""

lmbda = 1e-1
L = 1e1
opt = cbpdn.ConvBPDN.Options({
    'Verbose': True,
    'MaxMainIter': 250,
    'RelStopTol': 8e-5,
    'L': L,
    'Backtrack': BacktrackStandard(maxiter=15)
})
"""
Initialise and run CSC solver.
"""

b = cbpdn.ConvBPDN(D, sh, lmbda, opt)
X = b.solve()
print("ConvBPDN solve time: %.2fs" % b.timer.elapsed('solve'))
"""
Reconstruct image from sparse representation.
"""

shr = b.reconstruct().squeeze()
imgr = sl + shr
print("Reconstruction PSNR: %.2fdB\n" % sm.psnr(img, imgr))
"""
Display low pass component and sum of absolute values of coefficient maps of highpass component.
"""

fig = plot.figure(figsize=(14, 7))
plot.subplot(1, 2, 1)
示例#11
0
"""

lmbda = 5e-2
L = 1.
opt = cbpdn.ConvBPDN.Options({
    'Verbose': True,
    'MaxMainIter': 250,
    'RelStopTol': 1e-4,
    'L': L,
    'Backtrack': BacktrackStandard(maxiter=15)
})
"""
Initialise and run CSC solver.
"""

b = cbpdn.ConvBPDN(D, sh, lmbda, opt, dimK=0)
X = b.solve()
print("ConvBPDN solve time: %.2fs" % b.timer.elapsed('solve'))
"""
Reconstruct image from sparse representation.
"""

shr = b.reconstruct().squeeze()
imgr = sl + shr
print("Reconstruction PSNR: %.2fdB\n" % psnr(img, imgr))
"""
Display low pass component and sum of absolute values of coefficient maps of highpass component.
"""

fig = plot.figure(figsize=(14, 7))
plot.subplot(1, 2, 1)