Thursday, 3 February 2011

1.4 Representation of data in computer systems


1.4 Representation of data in computer systems

Images
Candidates should be able to:
  1. explain the representation of an image as a series of pixels represented in binary
  2. explain the need for metadata to be included in the file such as height, width and colour depth
  3. discuss the effect of colour depth and resolution on the size of an image file.

How can an image be represented in binary?
A digital image showing how each pixel of a bitmap image can be represented in binary using 1 bitBitmap images:
Bitmap images are made up of individual pixels and the colour of each pixel is stored as a binary code. The whole image is therefore stored as a series of binary numbers.
If more memory 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 on the right the animation zooms into the small image to show the individual pixels. The image has a 1 bit colour depth because only 1 bit is used for each pixel, giving 2 possible colours, in this case black and white. The binary code for each pixel is therefore simply 1 or 0.
Vector images:
Vector and bitmap images compared, showing the effect of magnification on eachVector images store information as mathematical instructions rather than as individual pixels. For example, to draw a vector circle the software only needs to store the coordinates of the circle centre, the radius, the line thickness, style and colour, the fill type and colour(s) and the image scale.
This information would be stored using binary codes for the instructions. The result is that the file size of a vector image would be considerably smaller than the equivalent bitmap image which would need to store the information for every pixel in the image, including the area outside the circle.
Although vector images can have graduated fills these are mathematically defined and vector images cannot represent the level of detail needed for photographic images.
As well as the smaller file sizes, vector images have the advantage that they can be scaled to any size without any loss of detail or pixilation as would occur with a bitmap image. Also, if a vector image was scaled-up and then saved it would have the same file size as the original.

Why does metadata need to be included in an image file?
Metadata is needed in a bitmap image file because the software that displays an image needs to know:
  • The height and 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 are used to represent each pixel.

An image with  the CORRECT colour depth metadata - 1 bit colour depthThe same data but the WRONG colour depth metadata - 2 bit colour depth 
An image with 1 bit colour depth and matching metadataThe same image but with metadata describing the file as having 2 bit colour depth

An image with the CORRECT size metadata - 16 x 24 pixels The same data but with the WRONG size
metadata - 24 x 16 pixels 
An image with the correct size metadata, describing the image as 16x24 pixelsAn image with the incorrect size metadata, describing the image as 24x16 pixels

The original image, before zooming in to reveal the individual pixels
The original image, before zooming
 in to reveal the individual pixels.

NOTE: 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.

What is colour depth and how does it effect the size of an image file?


Colour
depth in bits
(n)
Number
of possible
colours
(2n)
Example
binary code(s) used to
 store the colour information
about each pixel
120, 1
2400, 01, 10, 11
38000, 001, 111 etc.
4140000, 0001, 1110 etc.
825610010101, 11101101 etc.
24    16,777,216 010110101110001101001101
Colour depth describes the number of bits of memory that are used to store the colour information about each pixel in a bitmap image.
1 bit colour depth image - allowing 2 coloursWith 1 bit colour depth the number of bits used to store the information about each pixel is 1. This allows 2 colours, represented by 0 or 1.
3 bit colour depth image - allowing 8 coloursWith 3 bit colour depth the number of bits used to store the information about each pixel is 3. This allows 8 colours, represented by the binary codes 000, 001, 010, 011, 100, 101, 110 and 111.
SUMMARY: The greater the colour depth of a bitmap image, the greater the file size because more memory is used to store the colour data about each pixel.
Colour mapping, palette tables and 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;
EXPANSION TOPIC - Colour mapping and Direct colour

What is resolution depth and how does it effect the size of an image file?
The effect of zooming in on a high and a low resolution bitmap imageResolution depth is a measure of how much detail there is in an image. A detailed image can be magnified and still stay sharp.
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). A low resolution image of an object will appear smaller on screen and will become pixelated (the individual pixels will be clearly visible) when it is magnified to the same size as a high resolution image of the same object.
To physically reduce the size of a bitmap image it can be resampled. 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.
NOTE: Although resampling is usually thought of as reducing the resolution this is only true if the print size is kept constant. An image resampled in this way would lack the detail of the original when it was printed out. It is equally possible to resample an image by reducing the print size and keeping the resolution constant. In this case the printed image would still appear sharp but be smaller.
Just decreasing the resolution, without resampling the image, makes no change to the image on the screen but produces a larger printed image (there are still the same number of pixels to print out but if the PPI is lower then 1 inch of printing will have printed less of them)
SUMMARY: A high resolution bitmap image will have a greater the file size than the equivalent low resolution image because more memory is used 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.

No comments:

Post a Comment