Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean to normalize an array?

I need to normalize an array that contains values between 0 to 1024 into an array that will contain values between 0-255. I am doing this in Java but I am wanting to understand what exactly does it mean to "normalize an array" rather than asking for exact code.

like image 659
Lucas Alanis Avatar asked Dec 26 '22 09:12

Lucas Alanis


2 Answers

To normalize a vector in math means to divide each of its elements
to some value V so that the length/norm of the resulting vector is 1.
Turns out the needed V is equal to the length (norm) of the vector.

Say you have this array.

[-3, +4]

Its length (in Euclid metric) is: V = sqrt((-3)^2 + (+4)^2) = 5

So its corresponding normalized vector is:

[-3/5, +4/5]

Its length is now: sqrt ( (-3/5)^2 + (+4/5)^2 ) which is 1.

You can use another metric (e.g. I think Manhattan distance)
but the idea is the same. Divide each element of your array
by V where V = || your_vector || = norm (your_vector).

So I think this is what is meant here.

See also:

http://www.fundza.com/vectors/normalize/

http://mathworld.wolfram.com/NormalizedVector.html

like image 116
peter.petrov Avatar answered Dec 28 '22 05:12

peter.petrov


Normalize in this case essentially means to convert the value in your original scale to a value on a different scale. Something like this will do it:

x = origVal / 1024;
xNorm = 255 * x;

You will have to decide how you want to handle rounding.

So for example:

.5 = 512 / 1024;
127.5 = 255 * .5;
like image 45
Cliff Ribaudo Avatar answered Dec 28 '22 06:12

Cliff Ribaudo