Why do we always divide RGB values by 255?

Viewed 71092

Why do we always divide our RGB values by 255? I know that the range is from [0-1]. But why dive only by 255? Can anyone please explain me the concepts of RGB values?

6 Answers

Given that each Ocket is nowadays made of 8 bits ( binary digit)

Suppose we have an Ocket filled like this :

1   0   1   0   0   1   0   1

for each bit you get 2 possibilities : 0 or 1

2 x 2 x 2 x 2 x 2 x 2 x 2 x 2    = 2^8 = 256

total : 256

And for hexadecimal colors :
given that you have 3 couples of characters, dash excluded => ex: #00ff00
0, 1, 2, 3, 4 , 5, 6, 7, 8, 9, a, b, c, d, e, f = 16 possibilities 

16 x 16 = 256

R      V     B   = color
256  x 256 x 256 = 16 777 216 colors)

It makes the vector operations simpler... Imagine you have image and you want to change its color to red. With vectors you can just take every pixel and multiply it by (1.0, 0.0, 0.0)

P * (1.0, 0.0, 0.0)

Otherwise it just adds unnecessary steps (in this case dividing it by 255)

P * (255, 0, 0) / 255

And imagine using more complex filters, the unnecessary steps would stack up...

Related