Bitmapped+Graphic+Calculations

Introduction
Calculating the number of pixels, and file sizes of uncompressed bitmapped files is straightforward if thought is given to the process.

Calculating the total number of pixels in an image
Resolution is often given in dots per inch e.g. an image is 72 dots per inch. This means that there are 72 dots in each inch running horizontally, and 72 dots in each inch running vertically. Therefore in the image below which is of 1 inch x 1 inch, there would be 72 x 72 = 5184 pixels

**Formula** Number of pixels = image width x resolution x image height x resolution

**Example** Calculate the number of pixels in 4 inch by 5 inch photograph scanned which has a resolution of 600 dots per inch. Pixels = 4 x 600 x 5 x 600 = 7,200,000

Calcluating colour depth
The colour depth is the number of bits used to represent the colour of a single pixel. 1 bit can be used to represent 2 colours 2 bits can be used to represent 4 colours 3 bits can be used to represent 8 colours 4 bits can be used to represent 16 colours

Number of colours = 2 bit depth
 * Formula**

Calculate the number of colours which can be represented using 16 bits Colours = 2 16 = 65536
 * Example**

Calculating file size (Higher only)
The number bits in an image can be calculted by multiplying the total number of pixels in an image by the bit depth of each pixel. In order to get the answer in bytes, this must be divided by 8.

Note that this assumes the file is uncompressed, and does not take into account the colour look-up table (if there is one)

File size(bytes) = total number of pixels x colour depth per pixel / 8
 * Formula**

An image is of size 1,000 x 1,000 pixels and uses 24 bits to store the colour for each pixel. What would be the file size in bytes of this image? Total pixels = 1,000 x 1,000 = 1,000,000 File size (bytes) = 1,000,000 x 24 / 8 = 3,000,000 bytes
 * Example**

Questions (Int 2)
1. How many colours can be stored using 8 bits? 2. How many colours can be stored using 12 bits? 3. How many colours can be stored using 24 bits? 4. How many bits are required to store 16 colours? 5. How many bits are required to store 128 colours? 6. How many bits are required to store 1024 colours? 7. Explain the difference between lossy and lossless compression 8. An image file is 2097152 bytes in size. How many megabytes is this? 9. An image file is 51200 bytes in size. How many kilobytes is this?

Questions (Higher)
Calculate the sizes of the following files. Use the most appropriate units in your answer

1. 600 x 300 pixels, 24 bit colour depth

2. 600 x 400, 16 bit colour depth

3. 600 x 600, 24 bit colour depth

4. An image is 6 inches by 8 inches, and has a resolution of 1200 dpi. It has a bit depth of 20. (a) How many colours can the image store? (b) What will be the file size of the image?

5. A photograph measures 10 inches by 7 inches, and has a resolution of 400 dpi. The number of colours each pixel can store is 65536. (a) What is the bit depth of the image? (b) What will be the file size of the image?