Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

normalization in image processing

What is the correct mean of normalization in image processing? I googled it but i had different definition. I'll try to explain in detail each definition.

Normalization of a kernel matrix

If normalization is referred to a matrix (such as a kernel matrix for convolution filter), usually each value of the matrix is divided by the sum of the values of the matrix in order to have the sum of the values of the matrix equal to one (if all values are greater than zero). This is useful because a convolution between an image matrix and our kernel matrix give an output image with values between 0 and the max value of the original image. But if we use a sobel matrix (that have some negative values) this is not true anymore and we have to stretch the output image in order to have all values between 0 and max value.

Normalization of an image

I basically find two definition of normalization. The first one is to "cut" values too high or too low. i.e. if the image matrix has negative values one set them to zero and if the image matrix has values higher than max value one set them to max values. The second one is to linear stretch all the values in order to fit them into the interval [0, max value].

like image 980
gvgramazio Avatar asked Nov 09 '15 14:11

gvgramazio


1 Answers

Answer by @Imanol is great, i just want to add some examples:

Normalize the input either pixel wise or dataset wise. Three normalization schemes are often seen:

  1. Normalizing the pixel values between 0 and 1:
img /= 255.0
  1. Normalizing the pixel values between -1 and 1 (as Tensorflow does):
img /= 127.5
img -= 1.0
  1. Normalizing according to the dataset mean & standard deviation (as Torch does):
img /= 255.0
mean = [0.485, 0.456, 0.406] # Here it's ImageNet statistics
std = [0.229, 0.224, 0.225]

for i in range(3): # Considering an ordering NCHW (batch, channel, height, width)
    img[i, :, :] -= mean[i]
    img[i, :, :] /= std[i]
like image 182
Milind Deore Avatar answered Sep 22 '22 03:09

Milind Deore