You need to perform the following steps to implement image restoration with dictionary learning using the scikit-learn library functions:
- Read the Lena image and degrade the lower half of the image with random Gaussian noise while keeping the upper half as it is:
lena = rgb2gray(imread('images/lena.png'))height, width = lena.shapeprint('Distorting the lower half of the image...')distorted = lena.copy()distorted[height // 2:, :] += 0.085 * \ np.random.randn(height // 2, width)
- Extract all 7x7 reference patches from the upper half of the image. Compute the mean and standard deviation of the extracted patches and normalize the extracted patches:
print('Extracting reference patches...')patch_size = (7, 7)data = extract_patches_2d(distorted[height ...