# What is zero mean and unit variance in terms of image data?

I am new to deep learning. I am trying to understand some concepts. I know "mean" is an average value and "variance" is deviation from mean.I have read some research papers, all say that we pre-process our data first. But how these concepts are related to image pre-processing? Why these concepts are used as pre-processing of image data?
Actually i am unable to understand that how these techniques contribute towards classification.I searched it on google but may be i searched with less descriptive keywords
Please bear my very basic question,

• Actually variance is the average of the squares of differences from the mean. Are you asking about "standardisation" or "rescaling"as preprocessing step? It is designed to avoid a single explanatory variable dominating the others just because it has a wide range of numerical values. May 2, 2016 at 21:41
• This is usually referred to as image normalization, and you can find reasons for it in the link. May 2, 2016 at 21:52
• Excellent answer for why we normalize feature vectors, from wikipedia: "Since the range of values of raw data varies widely, in some machine learning algorithms, objective functions will not work properly without normalization. For example, the majority of classifiers calculate the distance between two points by the Euclidean distance. If one of the features has a broad range of values, the distance will be governed by this particular feature. Therefore, the range of all features should be normalized so that each feature contributes approximately proportionately to the final d." Feb 22, 2019 at 17:07
• That comment would be stronger if it elaborated on how 0-mean unit variance rescaling is related to images.
– Sycorax
Feb 22, 2019 at 17:13
• @Sycorax Images are treated as regular feature vectors that are fed to the model. There is nothing special about images, all statements regarding normalization apply equally to images and other feature vectors. Feb 22, 2019 at 17:17

This is a very good question and you need to understand this to gain more understanding into deep learning.

Basically, you have raw images, lets take one image. This image has 3 channels and in each channel pixel values range from 0 to 255.

Our goal here is to squash the range of values for all the pixels in the three channels to a very small range. This is where Preprocessing comes in. But dont think preprocessing only involves the mean and std devtn techniques there are many other like PCA, whitening etc.

1) Using mean: By computing the mean of say, the first red pixel values across all the training images will get you the average red color value that is present across all the training images at the first position. Similarly you find this for all the red channel values, green channel values. Finally you get an average image from all the training images.

Now if you subtract this mean image from all the training images you obviously transform the pixel values of the images, the image is no longer interpretable to the human eye, the pixal values now lie in range from positive to negative where the mean lies at zero.

2) Now if you again divide these by std deviation you essentially squash the pixel value range before to a small range.

BUT WHY ALL THIS? I will say from my experience that doing this preprocessing on the images and then giving these transformed images to the classifier model will run faster and better. That's why.

As you are into deep learning, look into batch normalization after you understand this normalization concept

• Batch normalisation is related to internal shift in distribution and have nothing to do what we are talking. Feb 24, 2017 at 0:05
• "from my experience the model runs faster and better", doesn't sound that convincing. Feb 22, 2019 at 17:20
• I would argue with the why part: it won't "run faster". It will learn faster, but inference time is of course constant. Jun 30, 2020 at 11:02
• The reason unit variance pixel inputs learn better is that the initial weights of a NN are sampled from a normal distribution with unit variance (plus some tricks). With input and weights on the same scale, the gradients are on the same scale too. This means the NN gradients straight away model the data, rather than first finding the correct scale to model the data. Jan 29, 2023 at 6:31