Fundamentals of Data Representation: Bitmaps

From Wikibooks, open books for an open world
Jump to: navigation, search

UNIT 1 - ⇑ Fundamentals of Data Representation ⇑

← Images Bitmaps Vectors →

Overview[edit]

Bitmap Graphics - a collection of pixels from an image mapped to specific memory locations holding their binary colour value


Pixel - the smallest possible addressable area defined by a solid colour, represented as binary, in an image


This example shows an Bitmap image with a portion greatly enlarged, in which the individual pixels are rendered as little squares and can easily be seen. Try looking closely at your monitor or mobile phone screen to see if you can spot the pixels
Bitmaps are very good for storing things such as photographs

Resolution[edit]

Image Resolution - how many pixels an image contains per inch/cm


Screen Resolution - the number of pixels per row by the number of pixels per column


The higher the resolution, the more pixels are available. Therefore the crisper the picture
There are many different video display formats out there, with different widths and heights, and total numbers of pixels

Example[edit]

Example: Calculating screen resolutions

Using the diagram above we are going to work out how many pixels are required to display a single frame on a VGA screen.

Checking the resolution:

Height = 480
Width = 640
Area = Width * Height = Total Pixels
Area = 640 * 480 = 307200

Questions[edit]

Exercise: Calculating screen resolutions

What is a Pixel?

Answer :

The smallest possible addressable area defined by a solid colour, represented as binary, in an image.

What is Image Resolution?

Answer :

The amount of pixels an image contains per inch/cm

What is Screen Resolution?

Answer :

the number of pixels per row by the number of pixels per column

What is the resolution of a 100 pixel by 70 pixel image?

Answer :

100 * 70 = 7000 pixels

What is the resolution of a 30 pixel by 40 pixel image?

Answer :

30 * 40 = 1200 pixels

What is the resolution of HD 1080p image? (use the diagram above to help)

Answer :

1920 x 1080 = 2073600 pixels

If I have an image resolution of 700 pixels, and the height is 35, what is the width of the image?

Answer :

700 / 35 = 20 pixels

What is a benefit of having a higher resolution image?

Answer :

higher resolution images are able to display more detail, providing crisper images

What might be a draw back of having a very high resolution image

Answer :

It will require a lot of space to store it. Meaning you'll quickly run out of memory, or it'll take a long time to transmit images across the internet or other data route.

Colour Depth[edit]

Colour depth - The number of bits used to represent the colour of a single pixel


Colour depth 1 bit 2 bit 4 bit
Example 1 bit.png 2 bit.PNG 4 bit.png
Description Mono-chrome, only stores black and white stores 4 colours:
RGB(70,61,55), RGB(79,146,85)
RGB(129,111,134), RGB(149,146,166)
Stores limited colours
Number of colours
per pixel
2^1=2 2^2=4 2^4=16
Colour depth 8 bit 24 bit
Example 8 bit.png Truecolor.png
Description close to reality hard to see any difference between reality
Number of colours
per pixel
2^8=256 2^{24}=16777216

It seems pretty obvious that the higher the colour depth, the closer the picture will look to reality. Why then don't we just ramp up the colour depth on every image that we make? The answer should be obvious, for a fixed resolution, the higher the colour depth, the larger the file size.

Example[edit]

Example: Calculating file size for different colour depths

All the images above are of the same resolution:

300*225 = 67500 pixels

If the first image uses 1 bit to store the colour for each pixel, then the image size would be:

Number of Pixels * Colour Depth = Image Size
      67500      *     1 bit    = 67500 bits

For the second image uses 2 bits to store the colour for each pixel, then the image size would be:

Number of Pixels * Colour Depth = Image Size
      67500      *    2 bit    = 135000 bits

Questions[edit]

Exercise: Colour Depth

What does colour depth mean?

Answer :

The number of bits used to represent the colour of a single pixel

For a colour depth of 8 bits, how many colours could each pixel store?

Answer :

2^8 = 256

To represent 1024 colours per pixel, what colour depth would I need?

Answer :

2^{10} = 1024

For an image of 30 by 40 pixels, what would the file sizes be for the following colour depths:

4 bits

Answer :

30 * 40 * 4 = 4800 bits

6 bits

Answer :

30 * 40 * 6 = 7200 bits

2 bits

Answer :

30 * 40 * 2 = 2400 bits

How many colours can each pixel store if it has a colour depth of 4bits?

Answer :

2^4 = 16 colours

How many bits does the colour depth have to be if we want to store 64 colours per pixel?

Answer :

6 as: 2^6 = 64 colours

How many bits would an image be that has a size of 20 by 30 pixels, with each pixel able to display 8 colours?

Answer :

8 colours is 3 bits per pixel as: 2^3 = 8 colours
h * w * b = 20 * 30 * 3 = 1800 bits

When might one want to decrease the colour depth for an image?

Answer :

When you want to save file space or when you only need a specific palate of colours such a mono-chrome