Home > Net >  Feature Whitening generates same image
Feature Whitening generates same image

Time:02-10

I am looking at the feature whitening example shown here: enter image description here

CodePudding user response:

Whitening is performed on zero-mean data. This means, that the matrices are computed on the zero-mean data and that they should also be applied on the zero-mean data. If you don't do that, you will essentially see the transformed mean vector W*mean_imagein all images. If that dominates in magnitude, the pictures all look identical due to rounding effects. However, they aren't if you compute the differences between your images.

In code, you can see all that with

combined_data = np.array(puppies_vectors).T
my_zca_transformer_image_stuff = zca_whitening_matrix(combined_data)
mean_image = np.mean(combined_data,axis=1)
without_mean = (combined_data-mean_image[:,None])
xZCAMatrix = np.dot(my_zca_transformer_image_stuff, without_mean)
reshaped_pics = [xZCAMatrix[:,i].reshape(new_size,new_size) for i in range(4)]
for i in reshaped_pics:
    plt.imshow(i, cmap='gray')
    plt.show() # Should look good now
## What you essential saw is this transformed mean image
i = np.dot(my_zca_transformer_image_stuff, mean_image).reshape(new_size,new_size)
plt.imshow(i, cmap='gray')
plt.show() 
  • Related