Digitizing Colours
Computers are digital machines. They operate on digits (well, specifically on electrical signals, but the best way our human brains can understand those on/off switches is in the numbers of 1 and 0). Everything they work with (software, emails, documents, music, pictures, videos …everything) needs to be represented by numbers: digitally.
For example, every colour that the computer works with (whether that’s a colour inside an image, coloured text, colour video, or any coloured aspect) must be represented by a number. There are a number of ways that this can be done, and there are several ways that colours are represented by numbers.
Original computers had limited colours, and the system could have been simple. If there were only 16 colours in a computer system (such as early systems had), then you could simply say white was 1, red was 2, orange was 3, etc. However the computer scientists of the day anticipated the need for more, so they set up systems that could be expanded.
The most commonly used and recognized system is called RGB. This means that any different colour is defined as containing a combination of Red, Green, and Blue light. This is what’s known as additive colours: different colours are created by adding different amounts of lights in those three colours.
Originally, each channel (red or green or blue) was represented by one or two bits. More recently, each channel is typically represented by eight bits, or one byte. This means that each channel can have up to 256 different values, resulting in over 16 million different colours.
For example: to display something in pure red, the red channel should be set at the maximum with no green or blue light. That would be represented by the largest possible byte (11111111) for red, and zero (00000000) for each of green or blue. 11111111 is a binary number, which can be represented by the denary number 255 or the hexadecimal number FF. To display something as orange, we would combine bright red (11111111 or 255 or FF) with some green (10100101 or 165 or A5), and no blue (0). Different combinations of each colour channel would result in different colours or shades.
Here’s a table that shows a few common colours. The names are standard HTML codes (and standard web notation is to use the hexadecimal values). Notice that a full green channel results in the colour “Lime,” resulting from a bright green light. (The more common, and standard, shade of Green would come from using 80 in the green channel.)
This system is often expanded upon. There can be an extra channel, called alpha, that represents the opacity of the colour (how much it blocks whatever is behind it). Also, some systems might use more than 8 bits for each channel.
There are other colour schemes as well. HSV (hue, saturation, value) or HSL (hue, saturation, lightness) are both used, especially when using a colour wheel or palette. When working with printers, the CMY system is often used. CMY uses cyan, magenta, and yellow to mix together to create different shades. This is a subtractive method, where a filter is used to remove a certain colour. (For example, cyan is the complement of red, so a cyan filter absorbs red light and subtracts it from the result.) CMY also works the same way as physical paints mix, so printers tend to use CMY, or CMYK which also includes black.
In summary: whenever a computer shows a colour, whether in an image or a document or software interface, that colour is determined by a number: a series of binary digits. These are made up of 8 binary digits for the red channel, 8 for green, and 8 for blue. Put them together and you’ll get a specific colour.
For more information on representing things digitally, check out my online course “Conquer Computer Science: Data Representation”
Leave a Reply