Unit 4.4 Representing Images Candidates should be able to: a) Explain the representation of an image as a series of pixels represented in binary b) Explain the need for metadata to be included in the file such as height, width and colour depth c) Discuss the effect of colour depth and resolution on the size of an image file Pixels, Bitmaps & Binary A pixel (short for picture element) is the smallest unit of data that can be represented in an image. Each pixel can represent a single, solid block of colour. If we use lots and lots of pixels, we can represent more detailed images. Bitmap (or Raster) images are groups of pixels. The colour of each pixel is stored as a binary code. For instance, the picture of the space invader below could be represented as: 0000000000000 0001000001000 0000100010000 0001111111000 0011011101100 0111111111110 0101111111010 0101000001010 0000110110000 0000000000000 OR If more bits are used to represent each pixel then more combinations of binary numbers are possible... so more colours are possible in the image. In the example above, there is only 1 bit per pixel, giving 2 possible colours (1 or 0). This means that it has a Colour Depth of 1 pixel. In contrast, a colour depth of 24 bits would allow us to use more than 16 million colours! 1
Bitmap vs Vector Graphics Bitmap images are collections of pixels. When you enlarge a bitmap image, you simply enlarge each pixel. If you enlarge the image too far, it will Pixelate... Vector images store a set of instructions about HOW to draw each shape. These are great for simple geometric shapes, logos and text, but not so good for very detailed pictures or photographs. A line could be stored as starting from a certain coordinate, having a certain thickness and colour, and extending for a certain proportion of the whole picture. When a vector image is enlarged, the entire image is redrawn, therefore no pixellation occurs. As well as smooth rescaling, Vector graphics also tend to have smaller file sizes. Each start and end point of a line is the same as an x,y coordinate on a graph. We can manipulate and transform the position of these points very easily... File Compression We can reduce the amount of memory required to store an image by compressing it. Let s look at the space invader again to demonstrate... for example: The first 16 pixels are all the same colour. Instead of using 16 bits to store each pixel individually, we could use 6 bits... the first 5 bits could represent the number of pixels (10000) and the last pixel the colour (0). We could then repeat this process for the entire image... Obviously this sort of compression will work better on larger images that use more than 2 colours! 2
Colour Depth We have seen that the more bits you have, the more colours you can represent: Colour Depth Number of Colours Represented 1 bit 2 (1, 0) 2 bit 4 (00, 01, 10, 11) 4 bit 16 (0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111) 8 bit 256 16 bit 65,536 24 bit 16,777,216 And this in turn, means bigger file sizes... Colour Depth Approximate Size of 100 x 200 pixel Image 1 bit 2.4 Kb ((100 * 200) / 8) / 1024 2 bit 4.8 Kb ((100 * 200 * 2) / 8) / 1024 4 bit 10 Kb ((100 * 200 * 4) / 8) / 1024 8 bit 20 Kb ((100 * 200 * 8) / 8) / 1024 16 bit 40 Kb ((100 * 200 * 16) / 8) / 1024 24 bit 60 Kb ((100 * 200 * 24) / 8) / 1024 3
Colour Mapping, Palette Tables & Direct Colour Colour mapping - With low colour depths (up to 8 bit) it is practical to map every colour to a binary code because there are not too many colours involved. This is called colour mapping and an example might be the binary code 110 representing yellow. Palette tables - The GIF file format uses 8 bits for each pixel so it can display 256 different colours. However, every GIF image can have a different set of 256 colours because they are stored as part of the file in a palette table. This table stores each of the 256 colours using 24 bit direct colour so there are 16,777,216 possibilities. Each of the 256 colours in the palette is indexed using 8 bits so it is the index value that is actually stored for each pixel in a GIF file. Direct colour - As the colour depth increases colour mapping and palettes become impractical due to the number of simultaneous colours that the image can display. In higher colour depths (8 bit and above) a system called direct colour is therefore used. In this the bits allocated to each pixel directly encodes the relative brightness of Red, Green and Blue to specify what is called an RGB colour. For example, if 24 bit direct colour was used then the code for a yellow pixel (maximum red and green and zero blue) would be: 255, 255, 0 in denary 11111111 11111111 00000000 in binary (note the use of 24 bits) FF FF 00 in hexadecimal Resolution Resolution measures the amount of detail in an image. An image with a high resolution will stay sharp when you zoom in An image with a low resolution will pixelate when you zoom in 4
In a bitmap image this depends on the pixel density, the number of pixels per unit of distance (not the total number of pixels in the image). The resolution depth of a screen image is usually measured in pixels per inch (PPI). Obviously, the more PPI you have, the larger the file size! Re-sampling To physically reduce the size of a bitmap image it can be re-sampled. This results in a smaller file size as pixels are discarded and the image therefore appears smaller on the screen. If it is then magnified back to the original size it will appear pixelated. Just decreasing the resolution, without re-sampling the image, makes no change to the image on the screen but produces a larger printed image (there is still the same number of pixels to print out but if the PPI is lower than 1 inch of printing will have printed less of them) A high resolution bitmap image will have a greater file size than the equivalent low resolution image as more memory is required to store the colour data of the extra pixels. NOTE: Because vector images are only stored as a set of mathematical instructions, halving the size of a vector image would effectively make no difference to the file size. However, halving the size of a bitmap image would effectively make the file size 1/4 of the original. Metadata Metadata, for our purposes, is data about data. Think about an mp3 audio track... ID3 tags are used to store data about the track e.g. Artist Album Name Track Name Track Number Sample rate Etc.. In this instance, it is information about an image. As well as storing the image itself, other information is stored that tells any appropriate software how to display the image. The height & width of the image - so each line of the image starts in the right place. The resolution depth - so the image displays at the correct size. The colour depth - so the correct number of bits is used to represent each pixel. 5
Height: 10px Height: 13px Width: 13px Width: 10px In this example you can see what happens if incorrect metadata is stored with an image. In this instance, the width and height values have been mixed up, resulting in a random pattern, instead of a recognisable shape. An image file may also contain metadata describing the type and amount of compression in the image, the software used to create the file and, if it is a digital photograph, the date and time the image was taken and the camera/lens settings. 6