Exam card
- Light = the part of the EM spectrum the eye senses. The colour we see = the light reflected. Monochromatic = grey level only. Chromatic adds radiance (W), luminance (lm), brightness.
- Acquisition: single sensor (moves in x and y) · sensor strip (a line at a time) · sensor array (2-D grid, cameras).
- Image formation model:
f(x,y) = i(x,y) · r(x,y), illumination × reflectance. - Sampling digitises the coordinates. Quantization digitises the intensity. Rounding to the nearest level causes quantization error. Result = a 2-D array; 8-bit = 256 levels (0 black, 255 white).
- Histogram h(rk) = nk, the pixel count per intensity level. Its shape shows dark, bright and low- or high-contrast images.
- Contrast stretching: Iout = (Iin−c)(b−a)/(d−c)+a. Outliers spoil it, so use the 5th/95th percentiles or a cut-off. Equalisation: sk = Σ ni/n, new = round(sk·m).
Key diagram
Key terms
What this topic covers
- Light and the electromagnetic spectrum
- Image sensing and acquisition
- Sampling and quantization
- The intensity histogram
- Enhancement 1: contrast stretching
- Enhancement 2: histogram equalisation (worked example from the slides)
Deep summary
Everything here follows the Topic 2 slides; each part shows its slide numbers. Parts marked added are study aids we wrote, not lecture content.
1 · Light: the part of the spectrum we can see Topic 2 · slides 3–5
The electromagnetic spectrum can be described by wavelength, frequency or energy (slide 4). Going left on slide 3 (towards gamma rays) means shorter wavelength, higher frequency and higher energy; going right (towards radio) the opposite. Light is the small band the human eye can sense.
The colour we see in an object is set by the light reflected from it (slide 4). Slide 5 then splits light in two: monochromatic light has no colour, and its intensity is given as a grey level. Chromatic (colour) light needs frequency plus three quantities: radiance (watts), luminance (lumens) and brightness.
The slides give only the names and units of the three quantities, so learn them as a list of three.
2 · Sensors, and the simple image formation model Topic 2 · slides 6–9
Image acquisition transforms illumination energy into a digital image (slide 6). Slide 6 lists three arrangements: (1) a single sensor, which has to move in x and y to build up the 2-D image (slide 7: energy passes a filter onto the sensing material, which gives out a voltage waveform); (2) sensor strips; (3) sensor arrays, sensors arranged as a 2-D array (slide 8).
Formation model (slide 9): intensity values are proportional to the energy radiated from the physical source, written f(x,y) = i(x,y) r(x,y). Worked: i = 200 and r = 0.5 give f = 200 × 0.5 = 100. A darker surface (r = 0.2) gives 40; halving the light (i = 100) gives 50.
Calling i “illumination” and r “reflectance” is the usual reading; slide 9 gives only the formula. The numbers are our example.
3 · Sampling: digitise the coordinates, get a 2-D array Topic 2 · slides 10–13, 19–20
A sensor outputs a continuous waveform, so making a digital image takes two processes: sampling and quantization (slide 10). The image is continuous in x, y and in amplitude; sampling digitises the x and y coordinates (slide 11).
Step by step (slide 12): 1. lay a grid over the image, 10 on x and 10 on y. 2. take one value per cell: 10 × 10 = 100 samples = 100 pixels. 3. more pixels means more samples, so finer detail. Slide 13 shows the same idea: a smooth shape becomes blocks.
The result is the image as a 2-D array (slide 19): f(x,y) has rows f(0,0) … f(0,N−1) down to f(M−1,0) … f(M−1,N−1), so M × N samples. For a 10 × 10 grid, x and y each run 0…9. Slide 20 shows a digit drawn on a grid next to its numbers (0.0 = black, 1.0 = white).
4 · Quantization, and the error it leaves Topic 2 · slides 14–18
Quantization digitises the amplitude. Slides 14–16 take the intensity along a line A–B through the image: the profile is continuous, sampling picks points along it, and each point is then put on a grey scale.
Step by step (slide 17): 1. divide the range from black to white into equal parts. 2. each continuous value is given one of the discrete values. 3. which one depends on the vertical proximity of the sample to the levels, so take the nearest. Worked with levels 0–7: 0.8 → 1, 2.3 → 2, 4.6 → 5, 6.1 → 6, 5.2 → 5.
The gap between the true value and the level it gets is the quantization error (slide 18 shows it as a staircase hugging a smooth curve, with binary codes 0000, 0001 … on the levels). Here the errors are 0.2, 0.3, 0.4, 0.1, 0.2.
added With nearest-level rounding the error is never more than half a step; more levels means smaller steps and smaller error.
5 · The histogram: count the pixels at each level Topic 2 · slides 21–27
For levels in [0, L−1] the histogram is h(rk) = nk: rk is the k-th intensity and nk is how many pixels have it (slide 21). The x-axis is the intensity level and the y-axis is the number of pixels (slides 22–23). An 8-bit grey image has 256 levels, 0 = black and 255 = white (slide 23).
Step by step on a 4 × 4 image with levels 0–7: 1. go through all 16 pixels. 2. tally each value: level 0 → 1, level 1 → 3, level 2 → 7, level 3 → 4, level 7 → 1, the rest 0. 3. check: 1 + 3 + 7 + 4 + 1 = 16 = number of pixels. 4. draw a bar per level.
Reading the shape (slides 24–27): bunched at the low end = dark image; at the high end = bright; squeezed into a narrow band = low contrast; spread across 0–255 = high contrast. Our image sits mostly on levels 1–3, so it is dark and low in contrast, with one lone pixel at 7.
6 · Contrast stretching, one pixel at a time Topic 2 · slides 28–30
Contrast stretching stretches the range of intensities from its original range [c, d] to span the desired range [a, b] (slides 28–29): Iout = (Iin − c)(b − a)/(d − c) + a. On slide 29, c and d mark where the histogram starts and ends, and a = 0, b = 255 are the ends of the scale.
Worked (c = 60, d = 120, a = 0, b = 255): 1. scale = (b − a)/(d − c) = 255/60 = 4.25. 2. for each pixel subtract c, multiply by 4.25, add a. Iin = 72: (72 − 60) × 4.25 = 51. Iin = 90: 30 × 4.25 = 127.5. Iin = 108: 48 × 4.25 = 204. The ends go 60 → 0 and 120 → 255.
Problem: outliers (slide 30). Add one pixel at 0 and one at 255: if c and d are the min and max, then c = 0, d = 255, the scale is 1 and nothing changes. Fixes: take c and d at the 5th and 95th percentiles of the histogram, or take the histogram peak, define a cut-off and ignore the data below it.
added Values below c or above d are usually clipped to a and b (the grey dashed ends).
7 · Histogram equalisation on the slide 34 table Topic 2 · slides 31–34
Equalisation spreads out the most frequent intensities through the intensity range (slide 31: the dull car photo becomes clear). Notation (slide 32): n pixels, grey levels 0…m, nk pixels at level k, probability nk/n. Transform (slide 33): sk = Σi=0..k ni/n, and the new value is round(sk × m).
Step by step on slide 34: 1. n = 790 + 1023 + … + 81 = 4096; levels 0–7, so m = 7. 2. running total of nk: 790, 1813, 2663, 3319, 3648, 3893, 4015, 4096. 3. divide by 4096: s0 = 0.193, s1 = 0.443, s2 = 0.650 … s7 = 1. 4. × 7 and round: 0.193 × 7 = 1.35 → 1; 0.443 × 7 = 3.10 → 3; 0.650 × 7 = 4.55 → 5; and so on (full table above).
5. move the counts: level 6 gets 656 + 329 = 985 and level 7 gets 245 + 122 + 81 = 448. The bars now use levels 1–7, and the busy dark levels are pushed apart.
8 · Exam traps Topic 2 · slides 11, 17, 21, 23, 28, 33 added
- Sampling vs quantization: sampling digitises the coordinates (how many pixels); quantization digitises the amplitude (how many grey levels). Don’t swap them (slides 11, 17).
- 8-bit = 256 levels numbered 0–255, 0 black and 255 white (slide 23), not 1–256.
- nk is a count of pixels, not an intensity. The bars of a histogram add up to n (slide 21).
- Stretching: subtract c (the input low end), divide by (d − c), then add a (slide 28). Mixing up a/c is the usual slip.
- Equalisation: use the running sum of ni/n, and multiply by m, the top level (7 for levels 0–7), not by the number of levels 8 (slide 33).
- Equalisation can merge levels (3 and 4 both go to 6) but never splits one level into two.
9 · Quick check Topic 2 · slides 12, 23, 28, 33–34 added
Q1. A 16 × 16 sampling grid with 4-bit levels: how many samples, and how many grey levels?
Q2. Stretch [c, d] = [20, 70] to [a, b] = [0, 250]. What is Iout for Iin = 45?
Q3. In the slide 34 example, why does level 0 become 1 and not stay 0?
Exam questions · 15 Practise these 15
Q1Explain image sampling and quantization. What is quantization error?
Q2Describe the three ways of acquiring an image and the simple image formation model.
f(x,y) = i(x,y)·r(x,y), the illumination falling on the scene times the reflectance of the surface. Intensities are proportional to the energy radiated from the source.Q3Define the intensity histogram. What does it tell you about an image?
Q4Apply contrast stretching: input range [50, 150] mapped to [0, 255]. What is the output for 100? What is the weakness of the method, and how is it fixed?
Q5Histogram-equalise an 8-level image (n = 4096) with nk = 790, 1023, 850, 656, 329, 245, 122, 81.
Q6Calculate · Using the simple image formation model, a surface with r(x,y) = 0.6 is lit with i(x,y) = 150. What is f(x,y)? What is f if the light is halved?
Q7Classify · Sampling or quantization? (a) choosing a 10 × 10 grid of pixels (b) using 256 grey levels (c) digitising the x and y coordinates (d) giving each value the level it is vertically closest to (e) the difference between the true value and the stored level.
Q8Outline · Outline the difference between monochromatic and chromatic light, naming the quantities used to describe a chromatic light source.
Q9Calculate · A 0–255 range is quantized to four equal levels: 0, 85, 170, 255. Quantize the samples 30, 100, 140 and 240 and give the quantization error of each.
Q10Match · Match each histogram shape to an image: (A) piled up at the left (B) piled up at the right (C) a narrow hump in the middle (D) spread over the whole range. Images: bright, high contrast, dark, low contrast.
Q11Calculate · A 3 × 3 image has rows (0, 0, 1), (1, 1, 2), (3, 1, 0) with levels 0–3. Give h(rk) for each level and the probability nk/n.
Q12Apply · An image only uses intensities 40–200. Stretch it to 0–255 and find Iout for Iin = 80 and Iin = 120.
Q13Explain · A photo has almost all its pixels between 90 and 160, but one stuck pixel is 0 and one is 255. Explain why plain contrast stretching fails here and how the slides fix it.
Q14Calculate · Equalise a 16-pixel image with levels 0–3 (m = 3) and nk = 6, 6, 3, 1.
Q15Compare · Compare contrast stretching and histogram equalisation: what each uses from the histogram, the shape of the mapping, and one weakness.
Quick MCQs · 14 MCQs in Practise
Not the exam format: quick checks that you understood the topic. Choose 1 or all that apply, then Check.