def test_04(self): img = np.random.randn(64, 64) blk = util.imageblocks(img, (8, 8))
from sporco import plot """ Load training images. """ 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]) S3 = exim.image('monarch.png', idxexp=np.s_[:, 160:672]) S4 = exim.image('sail.png', idxexp=np.s_[:, 210:722]) S5 = exim.image('tulips.png', idxexp=np.s_[:, 30:542]) """ Extract all 8x8 image blocks, reshape, and subtract block means. """ S = util.imageblocks((S1, S2, S3, S4, S5), (8, 8)) S = np.reshape(S, (np.prod(S.shape[0:2]), S.shape[2])) S -= np.mean(S, axis=0) """ Load initial dictionary. """ D0 = util.convdicts()['G:8x8x64'] D0 = np.reshape(D0, (np.prod(D0.shape[0:2]), D0.shape[2])) """ Compute sparse representation on current dictionary. """ lmbda = 0.1 opt = bpdn.BPDN.Options({ 'Verbose': True,