def samplewise_norm(x, rescale=None, samplewise_center=False, samplewise_std_normalization=False, channel_index=2, epsilon=1e-07):
 if rescale:
  x *= rescale
 if (x.shape[channel_index] == 1):
  if samplewise_center:
   x = (x - np.mean(x))
  if samplewise_std_normalization:
   x = (x / np.std(x))
  return x
 elif (x.shape[channel_index] == 3):
  if samplewise_center:
   x = (x - np.mean(x, axis=channel_index, keepdims=True))
  if samplewise_std_normalization:
   x = (x / (np.std(x, axis=channel_index, keepdims=True) + epsilon))
  return x
 else:
  raise Exception(('Unsupported channels %d' % x.shape[channel_index]))

def samplewise_norm ( x , rescale = None , samplewise_center = False , samplewise_std_normalization = False , channel_index = 2 , epsilon = 1e-07 ) : if rescale : x *= rescale if ( x . shape [ channel_index ] == 1 ) : if samplewise_center : x = ( x - np . mean ( x ) ) if samplewise_std_normalization : x = ( x / np . std ( x ) ) return x elif ( x . shape [ channel_index ] == 3 ) : if samplewise_center : x = ( x - np . mean ( x , axis = channel_index , keepdims = True ) ) if samplewise_std_normalization : x = ( x / ( np . std ( x , axis = channel_index , keepdims = True ) + epsilon ) ) return x else : raise Exception ( ( 'Unsupported channels %d' % x . shape [ channel_index ] ) )
normalize an image by rescale .