Sunday, February 24, 2019

How colour works

A sunset enhanced by increasing saturation.
Have a look at the sunset above.  Notice in the top right corner that there are four coloured dots, each one numbered.  One is black, 2 red, three yellow, and 4 a bluish-purple.  They are small sections of the scene which were copied and moved up to that corner.  You could, in fact, move each one to its original position, and it would disappear into the spot where it came from.  Each dot is made of a collection of pixels of very similar colour.  What is interesting is that the image is not saved as an actual picture the way a negative is, rather it is a sequence of numbers.

Any one colour on the screen under normal circumstances is made up of three sets of numbers.  One number represents the red channel, one the green channel, and one the blue channel.  There are 256 different possible shades for each colour.  Each of those numbers is stored using a byte of data; a byte is made of 8 bits.  A bit is just a 1 or a 0, but 8 of them in a row allow for 256 different combinations.  The numbers go from 0 to 255, where 0 represents the darkest shade of that colour and 255 the lightest.  It takes 3 bytes of information to store 1 pixel, each byte coding for one of the three colours (channels) making it up.

Colour 1 (black) is red (0) green (0) and blue (0).  Colour 2 (red) is made up of red (155) green (25) blue (20), so we could say it is mostly red with a bit of cyan and a titch of green in it.  Colour 3 (yellow) is red (253), blue (175), green (103).  Lastly colour 4 is red (118), blue (76), and green (140).  This seems all a little tedious and unnecessary I am sure, but what is interesting here is the fact that there can be quite a range of these colours.  It turns out that, with each colour being represented by 256 shades of three different colours, that a total of  16,777,216 different combinations are possible. 

You may think that this represents such an enormous palate that it wouldn't be a problem.  But if you look closely at the picture you would notice that the transition from one colour to another is not perfect; there is a bit of colour banding taking place.  This is because there are actually not enough colours present to allow a seamless transition between different bands.  This is why some photographers use colour with a greater bit depth.  We call the colour the above shot is in 8-bit colour for obvious reasons.  If you want more colour options then you can choose 12 bit or 16 bit colour.  16 bit colour has 281,474,976,710,656 different shades.

The reason a picture takes up so much space is because of the fact that it takes 3 bytes of memory just to code for one pixel.  A 20 megapixel image then needs 60 megabytes of room to store it.  Fortunately this space is reduced because of the compression scheme used by JPEG creation algorithms.  That 60 megabyte image may only take up 12 or so megs of space - a lot to be sure but a lot less than 60.  That pales in comparison to the 16 bit colour image, which cannot be stored as a JPEG.  If stored as a TIFF, that one image would take up a wopping 120 megabytes of space - you could only fit 5 images on a CD.  Put another way, it would take about 86 three and a half inch floppies to save it.

Anyways, I just think it is cool.


No comments:

Post a Comment