permfl / dictlearn

Dictionary Learning for image processing
http://dictlearn.readthedocs.io/
33 stars 11 forks source link

Tutorial on dl.ksvd has incorrect syntax #6

Open NickiShaw opened 3 years ago

NickiShaw commented 3 years ago

I am having trouble with dl.ksvd, using the tutorial code below (trying to train on my own image - 'image_rescaled'). Here is my code:

1. image_patches = dl.Patches(image_rescaled.astype(float), 8)
2. dictionary_a = dl.dct_dict(256, 8)
3. dictionary_b = dl.ksvd(image_patches, dictionary_a, 1, n_nonzero=8, n_threads=4, verbose=True)
4. dl.visualize_dictionary(dictionary_b, 16, 16)

And the error: AttributeError: 'tuple' object has no attribute 'shape'

The problem occurs when I try visualize_dictionary, but changing line 4 to: dl.visualize_dictionary(dictionary_b[0], 16, 16) solves this problem. The code looks fine but the tutorial is a bit misleading - since dictionary_a is not the same as dictionary_b (dictionary_b is a tuple).