Пример #1
0
 def test_06(self):
     x = np.random.randn(9, 8)
     y = interp.bilinear_demosaic(x)
     assert np.array_equal(x[1::2, 1::2], y[1::2, 1::2, 0])
     assert np.array_equal(x[0::2, 1::2], y[0::2, 1::2, 1])
     assert np.array_equal(x[1::2, 0::2], y[1::2, 0::2, 1])
     assert np.array_equal(x[0::2, 0::2], y[0::2, 0::2, 2])
Пример #2
0
 def demosaic(cfaimg):
     return bilinear_demosaic(cfaimg)
Пример #3
0
"""
Define proximal operator of (implicit, unknown) regularisation term for PPP problem. In this case we use BM3D :cite:`dabov-2008-image` as the denoiser, using the [code](https://pypi.org/project/bm3d) released with :cite:`makinen-2019-exact`.
"""

bsigma = 6.1e-2  # Denoiser parameter


def proxg(x, rho):
    return bm3d_rgb(x, bsigma)


"""
Construct a baseline solution and initaliser for the PPP solution by BM3D denoising of a simple bilinear demosaicing solution. The `3 * nsigma` denoising parameter for BM3D is chosen empirically for best performance.
"""

imgb = bm3d_rgb(bilinear_demosaic(sn), 3 * nsigma)
"""
Set algorithm options for PPP solver, including use of bilinear demosaiced solution as an initial solution.
"""

opt = PPP.Options({
    'Verbose': True,
    'RelStopTol': 1e-3,
    'MaxMainIter': 12,
    'rho': 1.8e-1,
    'Y0': imgb
})
"""
Create solver object and solve, returning the the demosaiced image ``imgp``.
"""