global contrast normalization implementation
I'm trying to understand figure 12.1 in Goodfellow available here. I'm not able to reproduce figure 12.1, and I'm wondering what is it I'm missing. The denominator of equation 12.3 is a constant, and thus equation 12.3 reduces to a subtraction and a scaling. I'm finding it hard to believe that it will map the points to a sphere/circle as shown in figure 12.1. I'd expect something non-linear in order to do that. What am I missing?
My code is:
import numpy as np
import matplotlib.pyplot as plt
nn = 32
sigma = 1.0
mu = 0
def global_contrast_normalization(X,eps,lamb,ss):
mean_ = np.mean(X)
Xnew = X - mean_
ni,nj,nk = X.shape
denom = (1/(ni*nj*nk))*np.sum((X-mean_)**2)
denom = lamb + denom
denom = np.sqrt(denom)
denom = np.maximum(eps,denom)
Xnew = (ss*Xnew)/denom
return Xnew
img = np.random.normal(mu,sigma,size=(nn,nn,2))
imgnew = global_contrast_normalization(img,eps=1e-8,lamb=0,ss=1.0)
fig,(ax1,ax2) = plt.subplots(nrows=1,ncols=2)
ax1.set_aspect('equal')
ax2.set_aspect('equal')
pts1 = img.reshape((nn*nn,2))
ax1.scatter(pts1[:,0],pts1[:,1])
ax1.set_title('Data')
pts2 = imgnew.reshape((nn*nn,2))
ax2.scatter(pts2[:,0],pts2[:,1])
ax2.set_title('After GCN')
Topic question-answering image-preprocessing self-study
Category Data Science