RSS

Feeling out of your bit depth?

07 Jan

So you’re a photographer but the phrase ‘bit depth’ makes you want to look around for a convenient excuse to do something else. And yet you know bit depth must be important because you’ve been hearing about it since you picked up your first digital ‘point and shoot,’ and the phrase still won’t go away.

"It's not easy being made up of millions of bits of pixels that are mostly green."

“It’s not easy being
made up of millions of bits of pixels that are
mostly green.”

Worse still, now that you’re thinking of scanning in your (or your grandparents’) old film photos, you’ve discovered that the scanner is actually demanding you set the bit depth before it will deign to run its light wand over the photograph and do its digital magic.

Happily, bit depth isn’t too hard to understand.

Computers (and digital cameras) speak a very simple language of bits, each of which can, like a light switch, be either ‘on’ or ‘off’ (better known as ‘one’ or ‘zero’). Your digital photographs are formed from millions of these switches.

Now at this point I should be telling you about how we normally think of bits in groups of eight, known as bytes, which in their millions are the supporting infrastructure for the megapixels of our photos. However, for the purpose of understanding bit depth, it is actually more helpful to first think of bits as ungrouped – an endless stream of bits one after another:

10010101101100011010110011011100010110100010110…

Now suppose that you have a photo with a bit depth of 1.  This means that the complete information for every pixel in your photo is stored in only 1 bit.  Since we know that a bit can only be either “on” or “off” (either “1” or “0“), this means that each pixel in your photo can be only one of two colours.  Normally this would be black or white as we will use in this example, but it could be any two colours you wish. Applying this logic to the stream of bits above, the computer would interpret the pixel colours as being white (1), black (0), black (0), white (1), black (0) and so on to the end of the image. In an image with a bit depth of 1 using black and white, the computer must interpret each pixel as either black or white.  It has no choice.

1 bit image (black or white)

Bobby, 1 bit image (black or white)

Let’s look at an example: a photo of my nephew Bobby.  Bobby is standing in front of a pavilion fountain in a white shirt and red bow-tie. Behind him, below a clear blue sky, are a low wall and a tree. The sun is streaming in from the right of the photo and reflecting off his face, shirt, a bank of white chairs in the background and the water shining on his hand. Now, despite my description, this is a pretty unsatisfactory photo, isn’t it? I set the bit depth to 1, and the computer hasn’t much with which to work.

Images with a bit depth of 2 aren’t much better. Because two bits are used for each pixel, the computer can only choose from a small palette of 4 colours. Perhaps this could be black, white, dark gray and light gray, corresponding to 00, 11, 10, and 01 respectively. If we applied this logic to the stream of bits that appears above, then the order of pixel colours would be dark gray (10), light gray (01), light gray (01), light gray (01), dark gray (10), white (11), black (00) and so on.

That would obviously give us more visible detail in our photo. From there on, the math is easy. A bit depth of 3 means 8 different colours (2 x 2 x 2), a bit depth of 4 means 16 different colours (2 x 2 x 2 x 2), etc. As we increase bit depth, we also increase file size because more bits are used for each pixel.

8 Bits (256 shades of grayscale)

Bobby, 8 Bits
(256 shades of grayscale)

Let’s stop at a bit depth of 8. This is a rather magic number in bit depth for a few reasons.

First, 8 bits equal a byte. Bytes are very convenient for computer programmers, and in fact the accepted grid of ‘websafe’ colours is limited by the number of colours available in an 8-bit byte. Using our earlier example string of bits, here they are arranged as bytes:

1001010  11011000  11010110  01101110  00101101  00010110 …

Second, at a bit depth of 8 we have 256 colours from which to choose. If we set all 256 colours to grayscale, then we have enough colour choices for a fairly creditable black and white photo as you can see by the second version of Bobby’s photo.

Thirdly, when image quality is less important, we can use the 8 bits to create something called an indexed colour image. You might recall that above I mentioned that a one bit image doesn’t have to use black and white only, but any two colours you wish. This idea comes in handy when you want to use the maximum number of colours in the smallest file size possible.

8 Bit indexed colour

Bobby, 8 Bit indexed colour

Instead of reserving set colours for each of the 256 bit combinations (regardless of the colours actually found in your photos) computers can assign a list of colours that best fits each photo. After all, how many shades of purple are needed in a photo of Kermit the Frog? And how many shades of green?

Let’s see a version of Bobby’s photo using indexed colour. Now we can see the image I described above in most of its colourful glory.  And perhaps this version it is good enough for web use.

However, the current standard for bit depth is something called 24 bit colour, also known as ‘true color.’  In true color, the computer uses one 8-bit byte for each of three colour channels: red, green and blue. Computer monitors then mix these three colours to create the colour of each pixel.

As we learned above, 8 bits provide a combination of 256 colours. That means that true color offers 16 million colours (256 shades of red x 256 shades of green x 256 shades of blue), which is enough to handle almost any type of photographic use.

24 Bits (8 each of Red, Green and Blue)

Bobby, 24 Bits
(8 each of Red, Green and Blue)

This last version of Bobby’s photo uses true color.  That means that for every pixel in the image, there is one byte of 8 bits each of red, green and blue information.  Each pixel therefore requires three bytes to store its colour information.  This is a bigger file size, but if you compare the 8 bit indexed colour image above to the 24-bit colour image to the right, you can see a significant difference in picture quality, even in these small display sizes.

There are even higher bit depths in use for special photographic uses.  It is possible to have photographs with 16 bits per red, green and blue channel, which means that each pixel requires 48 bits, or 6 bytes to store its colour information. In theory, a 48 bit photograph has access to over 281 trillion colours (65,536 shades of red x 65,536 shades of green x 65,536 shades of blue) but you have to ask yourself, “Do I really need more than 16 million colours?”

There are also 32 bit files such as some .png formats in which one byte is reserved for transparency. (Though you might feel you’ve learned quite enough about bits for pixels you can see, let alone ones you can’t.)

So to summarise, bit depth is simply a measure of the number of bits per pixel your photo is using to record colour information.  Most photos these days use 24-bit ‘true color’ comprising one byte each of red, green and blue colour information. There are reasons you might use a smaller bit depth, such as for black and white photography or indexed colour images, and there are reasons you might use a greater bit depth, such as 48 bits for very large, finely shaded images or 32 bits to allow parts of your image to be transparent.

Now, that didn’t hurt a bit, did it?

_______________

References
Photograph of Bobby by Brian Bleecker, iterations in different bit depths by Sabrina Caldwell
Digital image bit depth, http://www.pixmonix.com/tutorials/tutorial-scanning-bit-depth.php, accessed January 2014
Photo of Kermit and Walter at http://thedisneyblog.com/2013/06/11/disney-is-working-on-a-muppets-musical/, accessed January 2014. No ownership information provided. Used under ‘fair use’ provisions of copyright act. Contact blog owner if any problems. Caption by Sabrina Caldwell 7 Jan 2014.
Advertisements
 
3 Comments

Posted by on January 7, 2014 in Digital photography

 

Tags: , , , , ,

3 responses to “Feeling out of your bit depth?

  1. Cindy

    January 7, 2014 at 2:28 pm

    Thanks for the post! As a software developer and amateur photographer, I knew most of this about bit depth, but I didn’t know what indexed color was. Thanks for the explanation!

     
    • sabrinacaldwell

      January 7, 2014 at 2:34 pm

      Thanks Cindy, I’m very glad I could help. Your comment helped me too; upon reading it I realised that I should add ‘indexed color’ to my tags on this post and I did!
      Cheers, Sabrina

       

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: