The authors are not responsible for the content of any external sites linked to from digitalmultimedia.org
All material on this site is ©2009–2017 MacAvon Media and may not be reproduced without permission.
Answers to Exercises, Chapter 5
These are answers to the exercises in the 3rd edition of Digital Multimedia (published February 2009) only. Do not try to use them in conjunction with the 2nd edition.
Buy the complete book in PDF for GBP £19.75 or individual chapters for GBP £1.99 each from the authors' own Web site MacAvon Media. MacAvon Media PDF is DRM-free and can be read with any program that opens PDF.
- Greyscale images use a single byte per pixel instead of the 3 bytes per pixel in 24-bit colour, so file sizes are reduced by a factor of 3 without the complexity and compromises of indexed colour. Greyscale images cause no problems for people with defective colour vision and they are more likely to be reproduced consistently on all devices.
Greyscale would be the obvious choice for reproducing black-and-white originals, such as old photographs and movie stills. To add colour to these images is to distort the original information, and to use a 24-bit colour image for a range of greys is inefficient. Greyscale is often used on aesthetic grounds to present a clean and austere impression. Greyscale images can be used to ensure high contrast and readability and to avoid the confusion which colour may introduce.
Colour is essential when it conveys information or when reasonably accurate reproduction of a coloured original is required. For example, in an online art gallery, colour will usually be part of the art works on display. In an online clothing shop, the colour of an item will be a property that most buyers will want to see. In an instruction manual showing the meaning of different coloured lights on a piece of equipment it would be essential to show the colours.
Between the two extremes there are many situations where colour is desirable or more convenient (for conveying information by colour-coding, for example) but not essential (the same information may be presented some other way – for example, by underlining).
- The short answer is "No". Before reaching that conclusion, you might observe that there is no single definition of "red", "green" and "blue", but refer to the CIE chromaticity diagram (Figure 5.2) as a demonstration that there are colours outside the RGB gamut.
- Red, green and blue, where the cube intersects the R, G and B axes, respectively. Cyan, magenta and yellow at the corners opposite their respective complements. Black at the origin and white at the remaining corner. (Now write down the coordinates corresponding to each of those eight colours.)
- Grey could be defined as pure brightness, with no hue, in which case it becomes a tautology that colours with equal components of red, green and blue are grey – they cannot have a hue. Note that although this definition corresponds to the idea that grey is what you get by mixing varying amounts of white and black (which provides another way of answering the question), it does not cover all the different pigments known as "grey", some of which may have blue in them, for example.
- As demonstrated in the answer to test question 4 in Chapter 2, the number of distinct values that you can represent in n bits is 2n, and a colour is just a value, so you can represent 224 colours in 24 bits, which comes to 16777216 – nearly 17 million.
- The key point to understand is that colours on a monitor are generated by mixing light additively, whereas the mixing of paints and inks works subtractively, because these physical media absorb light. This is explained in more detail with diagrams on pages 171–172.
- There are far more than 256 colours in the world, so choosing a standard palette would mean that very many colours were not available, and these would have to be represented by substitutes. This not only loses the colour information, but will also lead to loss of outlines and detail, as areas that are really differently coloured merge because they have been mapped to the same colour. In reality, however, any single image is highly unlikely to contain the full range of possible colours. Indexed colour lets us associate a custom palette of 256 colours with each individual image, so the number of missing colours will be smaller and the effect of substitution will be mitigated. For some sorts of synthetic image there may be fewer than 256 colours present, so using indexed colour does not lead to any loss of information in these cases.
- Each entry in the colour table occupies 3 bytes, as it stores a complete 24-bit colour value. In the indexed case, each pixel of the image itself occupies 1 byte. In the case of direct colour, there is no colour table and each pixel occupies 3 bytes. Hence – neglecting any other data structure overhead in each case, since we can assume it will be roughly the same – indexed colour represents a net saving if there are p pixels and 3p > p + 3*256, that is p > 384. This is a very small image (e.g. 16 by 24 pixels), so it is justifiable to assume that, for realistic images, indexed colour reduces the size by a factor of 3, as we did in the answer to Question 1 (the overhead of the colour table is negligible). For the same reason, reducing the number of colours further, to 128 or 32, for example, only saves useful space if it means that each pixel can be stored in the minimum number of bits. If you have to use a full byte anyway, for efficient access to the data structure, you don't make any worthwhile savings from having a smaller colour table.
- Indexed colour would definitely be satisfactory in cases where the image contains a limited number of colours.
(a) Yes, if the image is a diagrammatic version of the flag, because flags only use a handful of different colours. However, if the image is a photograph of a flag waving in a real environment, there may be complex shading on the flag resulting in a much larger number of colours owing to the wide range of possible tones of each colour. In this latter case, dithering would probably help.
(b) Probably, because the surface is predominantly red, and images are in any case artificially enhanced from noisy original signals.
(c) No, because such a photograph will contain many different colours. People are likely to notice artefacts in skin tones so dithering probably wouldn't help much here.
(d) 256 values are considered adequate to represent the perceptible range of greys. However, indexing would be redundant in this case, since 1-byte values can be used in the image itself.
- If the image contains p pixels, it will occupy 3p bytes without sub-sampling. If we only sample 1/a pixels for colour, we will have p luminance samples, and p/a samples of each of the colour differences, hence a total of 2p/a + p samples. We want this to be half the original image size, so we need 2p/a + p = 3p/2. Solving this equation gives a = 4. That is the number of samples of each colour difference needs to be a quarter of the number of pixels (and luminance samples).
- There are two reasons why colours may be reproduced differently on two different monitors, even if a colour profile is embedded in the image. (Actually, three, since it is possible that the software being used to display the image on one or both of the monitors does not use colour management.) First, the monitors may not be calibrated correctly, so that the interpretation of the colour values derived from the image and profile may be incorrect – and perhaps incorrect in different ways on the two monitors. This is such a common situation that it should be considered "normal". Secondly, the two monitors may have different gamuts because of different manufacturing technology or materials. One monitor may therefore be physically incapable of reproducing some of the colours shown on the other. The colour profile will map these to sensible values, but will be unable to make the displays identical.
Discussion Topics: Hints and Tips
- Have a look at the range of colours produced by the manufacturers of paints for artists, and read the notes on pigments, colours and mixing provided by companies such as Winsor and Newton on their Web site. Think about the possible differences between artists' paints and those manufactured for use by children, then research how many pigments were actually available to Michelangelo. Having satisfied yourself over the question of painting the ceiling of the Sistine Chapel, consider whether the colours in that ceiling can be represented accurately on a computer monitor.
- This isn't just a straightforward question of whether all colours can be represented in the colour space. There is also the question of continued support for file formats that use the colour space.
- What makes a colour important in an image? Are there occasions when a colour could be said to be vital? Will everybody be able to recognise that colour? You may find it helpful to read the section on Visual Hierarchy in Chapter 11 and the section on Colour in Chapter 13.
- We won't offer any extra hints on this one. Try it for yourself by downloading the image to help you see what's going on.
- When storing pixel values should you be more concerned with displaying the image or manipulating it? Where do the advantages of HSL and HSV lie?
- The answer to this question will depend to some extent on the state of browser implementations at the time you answer it. For example, support for colour management in browsers is improving.
Practical Tasks: Hints and Tips
- Do try making some adjustments to a real image to test your intuition. If you cannot see why the adjustment has side effects, consider the effect on the pixels' stored values.
- This is a straightforward experimental task that you need to do for youself.
- If you can, make a point of comparing the increasingly common flat-panel displays with the rapidly disappearing CRTs. Despite their many disadvantages, the latter usually do a much better job at displaying colours accurately. Keep a record of the results of your experiments for future reference.