Exemple #1
0
mu = 5e-1
opt = cbpdn.ConvBPDNGradReg.Options({'Verbose' : True, 'MaxMainIter' : 100,
                    'HighMemSolve' : True, 'LinSolveCheck' : True,
                    'RelStopTol' : 1e-3, 'AuxVarObj' : False,
                    'rho' : 1e0, 'AutoRho' : {'Enabled' : True,
                                              'RsdlTarget' : 0.02},
                    'L1Weight' : wl1, 'GradWeight' : wgr})

# Initialise and run [email protected] object
b = cbpdn.ConvBPDNGradReg(D, img, lmbda, mu, opt)
X = b.solve()
print("ConvBPDNGradReg solve time: %.2fs" % b.runtime)

# Reconstruct representation
imgr = b.reconstruct().squeeze()
print("       reconstruction PSNR: %.2fdB\n" % spl.psnr(img, imgr))


# Display representation and reconstructed image
fig1 = plot.figure(1, figsize=(14,14))
plot.subplot(2,2,1)
plot.imview(b.Y[...,0:3].squeeze(), fgrf=fig1, cmap=plot.cm.Blues,
            title='Lowpass component')
plot.subplot(2,2,2)
plot.imview(np.sum(abs(b.Y[...,3:]), axis=b.cri.axisM).squeeze(), fgrf=fig1,
            cmap=plot.cm.Blues, title='Main representation')
plot.subplot(2,2,3)
plot.imview(imgr, fgrf=fig1, title='Reconstructed image')
plot.subplot(2,2,4)
plot.imview(imgr - img, fgrf=fig1, title='Reconstruction difference')
fig1.show()
    'rho': 2e-1,
    'LinSolveCheck': True,
    'AutoRho': {
        'Enabled': False,
        'StdResiduals': True
    }
})

# Initialise and run ConvBPDNMaskDcpl object
b = cbpdn.ConvBPDNMaskDcpl(D, S, lmbda, W, opt)
X = b.solve()
print("ConvBPDNMaskDcpl solve time: %.2fs" % b.runtime)

# Reconstruct representation
Sr = b.reconstruct().squeeze()
print("        reconstruction PSNR: %.2fdB\n" % spl.psnr(S, Sr))

# Display representation and reconstructed image
fig1 = plot.figure(1, figsize=(14, 14))
plot.subplot(2, 2, 1)
plot.imview(np.squeeze(np.sum(abs(X), axis=b.cri.axisM)),
            fgrf=fig1,
            cmap=plot.cm.Blues,
            title='Representation')
plot.subplot(2, 2, 2)
plot.imview(S, fgrf=fig1, cmap=plot.cm.Blues, title='Reference image')
plot.subplot(2, 2, 3)
plot.imview(Sr, fgrf=fig1, cmap=plot.cm.Blues, title='Reconstructed image')
plot.subplot(2, 2, 4)
plot.imview(W * Sr,
            fgrf=fig1,