Exemplo n.º 1
0
"""
Load a reference image.
"""

img = util.ExampleImages().image('monarch.png',
                                 zoom=0.5,
                                 scaled=True,
                                 gray=True,
                                 idxexp=np.s_[:, 160:672])
"""
Create random mask and apply to reference image to obtain test image. (The call to ``numpy.random.seed`` ensures that the pseudo-random noise is reproducible.)
"""

np.random.seed(12345)
frc = 0.5
msk = signal.rndmask(img.shape, frc, dtype=np.float32)
imgw = msk * img
"""
Define pad and crop functions.
"""

pn = 8
spad = lambda x: np.pad(x, pn, mode='symmetric')
zpad = lambda x: np.pad(x, pn, mode='constant')
crop = lambda x: x[pn:-pn, pn:-pn]
"""
Construct padded mask and test image.
"""

mskp = zpad(msk)
imgwp = spad(imgw)
Exemplo n.º 2
0
S5 = exim.image('tulips.png', idxexp=np.s_[:, 30:542])
S = np.dstack((S1, S2, S3, S4, S5))
"""
Highpass filter training images.
"""

npd = 16
fltlmbd = 5
sl, sh = signal.tikhonov_filter(S, fltlmbd, npd)
"""
Create random mask and apply to highpass filtered training image set.
"""

np.random.seed(12345)
frc = 0.25
W = signal.rndmask(S.shape, frc, dtype=np.float32)
shw = W * sh
"""
Construct initial dictionary.
"""

D0 = np.random.randn(8, 8, 32)
"""
Set regularization parameter and options for dictionary learning solver.
"""

lmbda = 0.1
opt = onlinecdl.OnlineConvBPDNMaskDictLearn.Options({
    'Verbose': True,
    'ZeroMean': False,
    'eta_a': 10.0,
Exemplo n.º 3
0
 def test_02(self):
     msk = signal.rndmask((16, 17), 0.25)
     assert msk.shape == (16, 17)
Exemplo n.º 4
0
 def test_03(self):
     msk = signal.rndmask((16, 17), 0.25, dtype=np.float32)
     assert msk.dtype == np.float32
Exemplo n.º 5
0
exim = util.ExampleImages(scaled=True, zoom=0.25, gray=True)
S1 = exim.image('barbara.png', idxexp=np.s_[10:522, 100:612])
S2 = exim.image('kodim23.png', idxexp=np.s_[:, 60:572])
S = np.dstack((S1, S2))
"""
Construct initial dictionary.
"""

np.random.seed(12345)
D0 = np.random.randn(8, 8, 32)
"""
Create random mask and apply to training images.
"""

frc = 0.5
W = signal.rndmask(S.shape[0:2] + (1, ), frc, dtype=np.float32)
Sw = W * S
"""
$\ell_2$-TV denoising with a spatial mask as a non-linear lowpass filter.
"""

lmbda = 0.1
opt = tvl2.TVL2Denoise.Options({
    'Verbose': False,
    'MaxMainIter': 200,
    'DFidWeight': W,
    'gEvalY': False,
    'AutoRho': {
        'Enabled': True
    }
})