<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> from scipy . cluster . vq import kmeans2 <EOL> from scipy import ndimage as ndi <EOL> import matplotlib . pyplot as plt <EOL> from skimage import data <EOL> from skimage import color <EOL> from skimage . util . shape import view_as_windows <EOL> from skimage . util . montage import montage2d <EOL> np . random . seed ( <NUM_LIT> ) <EOL> patch_shape = <NUM_LIT:8> , <NUM_LIT:8> <EOL> n_filters = <NUM_LIT> <EOL> astro = color . rgb2gray ( data . astronaut ( ) ) <EOL> patches1 = view_as_windows ( astro , patch_shape ) <EOL> patches1 = patches1 . reshape ( - <NUM_LIT:1> , patch_shape [ <NUM_LIT:0> ] * patch_shape [ <NUM_LIT:1> ] ) [ : : <NUM_LIT:8> ] <EOL> fb1 , _ = kmeans2 ( patches1 , n_filters , minit = '<STR_LIT>' ) <EOL> fb1 = fb1 . reshape ( ( - <NUM_LIT:1> , ) + patch_shape ) <EOL> fb1_montage = montage2d ( fb1 , rescale_intensity = True ) <EOL> astro_dog = ndi . gaussian_filter ( astro , <NUM_LIT> ) - ndi . gaussian_filter ( astro , <NUM_LIT:1> ) <EOL> patches2 = view_as_windows ( astro_dog , patch_shape ) <EOL> patches2 = patches2 . reshape ( - <NUM_LIT:1> , patch_shape [ <NUM_LIT:0> ] * patch_shape [ <NUM_LIT:1> ] ) [ : : <NUM_LIT:8> ] <EOL> fb2 , _ = kmeans2 ( patches2 , n_filters , minit = '<STR_LIT>' ) <EOL> fb2 = fb2 . reshape ( ( - <NUM_LIT:1> , ) + patch_shape ) <EOL> fb2_montage = montage2d ( fb2 , rescale_intensity = True ) <EOL> fig , axes = plt . subplots ( <NUM_LIT:2> , <NUM_LIT:2> , figsize = ( <NUM_LIT:7> , <NUM_LIT:6> ) ) <EOL> ax0 , ax1 , ax2 , ax3 = axes . ravel ( ) <EOL> ax0 . imshow ( astro , cmap = plt . cm . gray ) <EOL> ax0 . set_title ( "<STR_LIT>" ) <EOL> ax1 . imshow ( fb1_montage , cmap = plt . cm . gray , interpolation = '<STR_LIT>' ) <EOL> ax1 . set_title ( "<STR_LIT>" ) <EOL> ax2 . imshow ( astro_dog , cmap = plt . cm . gray ) <EOL> ax2 . set_title ( "<STR_LIT>" ) <EOL> ax3 . imshow ( fb2_montage , cmap = plt . cm . gray , interpolation = '<STR_LIT>' ) <EOL> ax3 . set_title ( "<STR_LIT>" ) <EOL> for ax in axes . ravel ( ) : <EOL> ax . axis ( '<STR_LIT>' ) <EOL> fig . tight_layout ( ) <EOL> plt . show ( ) </s>
