What a digital image is, sampling and quantization with a real graph, bits/levels/size arithmetic, image types, and nearest-neighbour zooming with a step-by-step simulator. Fall 2024 is left out.
Slides 3–9. An image is a two-dimensional light-intensity function f(x, y): x and y are spatial coordinates, and the value (amplitude) of f at a point is its intensity or gray level. When x, y and the amplitude are all finite, discrete quantities, the image is a digital image. A pixel is the smallest element of a digital image; each pixel has an intensity (gray level in a gray image, an R, G, B vector in a colour image). Formats: JPEG, PNG, BMP, TIFF, GIF. f(x,y) for photos, f(x,y,z) for 3-D (CT), f(x,y,t) for movies.
Slides 11–13. Why process images: enhance visual quality, restore degraded images, compress for storage/transmission, analyse for recognition. Elements of a DIP system: acquisition, storage, processing, display. Levels: low (image in → image out), mid (image in → measurements/attributes out), high (attributes in → description/understanding out).
Slides 15–16. Key stages of DIP (start from the problem domain):
| stage | one line |
|---|---|
| image acquisition | capture the image with a sensor (camera, scanner); may include preprocessing such as scaling |
| image enhancement | improve visual quality (brightness, contrast) for a specific application |
| image restoration | repair degraded images (noise, blur) |
| morphological processing | manipulate shapes with set operations (erosion, dilation, opening, closing) |
| segmentation | split the image into regions (objects / background) |
| representation & description | turn regions into a form for computers (boundary or region) and describe them |
| object recognition | label objects by shape, texture and other features |
| compression | reduce storage and transmission size while keeping quality |
| colour image processing | work with colour models, conversions and corrections |
Slide 12. Computers use a discrete form of pictures; transforming the continuous analog image into a discrete approximation is digitization, in two steps: sampling and quantization.
| step | digitizes | decides |
|---|---|---|
| sampling | the coordinate values (x, y) | the spatial resolution M × N (number of pixels) |
| quantization | the amplitude (intensity) values | the number of gray levels L (usually a power of 2) |
Slides 16–19. A digital image is always only an approximation of the scene. It is stored as an M × N matrix with the origin (0,0) at the top-left, x down the rows and y across the columns (MATLAB numbers from 1 instead).
(i) Mention two techniques that made the digital representation of the analog world possible. (ii) “The more intensity levels used, the finer the level of detail discernible in an image.” Explain why.
(i) Sampling: measuring the continuous scene only at a grid of points, which digitizes the coordinates and fixes the spatial resolution M × N. Quantization: rounding each sampled brightness to one of L discrete levels (L = 2k), which digitizes the amplitude. Together they turn the analog picture into a matrix of integers.
(ii) With more levels the step between neighbouring gray values is smaller, so small brightness differences (soft shading, fine texture) get different numbers and stay visible. With few levels, many different intensities are rounded to the same value; smooth areas turn into flat bands with visible jumps between them (false contouring, slides 30–34), and fine detail is lost.
Slide 20. f(x,y) = i(x,y) · r(x,y), with illumination 0 < i < ∞ and reflectance 0 < r < 1. The gray level l = f(x,y) lies in [Lmin, Lmax] (the grayscale): a scalar measure of intensity from black through grays to white.
Slides 21–22. Intensity (gray-level) resolution = the number of intensity levels L used. It is usually given as bits per pixel: k bits give L = 2k levels; 8 bits give 256 levels, range [0, 255].
| bits k | levels L = 2k | range |
|---|---|---|
| 1 | 2 | 0 – 1 |
| 2 | 4 | 0 – 3 |
| 3 | 8 | 0 – 7 |
| 4 | 16 | 0 – 15 |
| 5 | 32 | 0 – 31 |
| 6 | 64 | 0 – 63 |
| 7 | 128 | 0 – 127 |
| 8 | 256 | 0 – 255 |
| 9 | 512 | 0 – 511 |
| 10 | 1,024 | 0 – 1,023 |
| 16 | 65,536 | 0 – 65,535 |
Slide 23. Spatial resolution = M × N (rows × columns). A 2048 × 1536 image has 3,145,728 pixels, a 3.1-megapixel image.
Q1 1 bit → 21 = 2 levels (0, 1). Q2 2 bits → 4 levels. Q3 p bits → 2p levels. Q4 256 intensities → log2 256 = 8 bits.
Q5 3-bit 5×5 image: gray-level resolution L = 2³ = 8 levels (range 0–7); spatial resolution 5 × 5 = 25 pixels; size b = 5 × 5 × 3 = 75 bits; bit depth 3.
How many shades of gray are possible in a 10-bit grayscale image? Show their numeric range. Illustrate the expression of intensity resolution.
L = 2k = 210 = 1024 shades; range [0, L − 1] = [0, 1023]. Intensity resolution of a k-bit image is L = 2k levels: more bits → more levels → finer steps between grays, less false contouring.
F22: define sampling and quantization; bits for 512 intensities; spatial resolution and bit size of a 7×5 image. F21: a 256×256 image with 64 gray levels: bit depth and size in bytes; Mach band effect; index image; why more levels show finer detail.
F22: sampling digitizes coordinates, quantization digitizes amplitude. 512 intensities → k = log2 512 = 9 bits. A 7×5 image has spatial resolution 7 × 5 = 35 pixels; with 9 bits per pixel, b = 7 × 5 × 9 = 315 bits.
F21: 64 levels → k = log2 64 = 6 bits; b = 256 × 256 × 6 = 393,216 bits = 393,216 / 8 = 49,152 bytes (48 KB). Mach band effect: at the boundary between two flat bands of different brightness the eye sees a darker strip on the dark side and a brighter strip on the light side (overshoot/undershoot) that is not in the image. Index image: each pixel stores an index into a colour table (palette) holding the actual RGB values. The last part is the same as SP22 (ii) above.
| type | each pixel holds | example |
|---|---|---|
| intensity / gray (monochrome) | one value: light intensity, a gray level | [10 10 16 28; 9 6 26 37; …] |
| colour / RGB | a vector of three values (red, green, blue) | [99, 65, 10] |
| binary (black and white) | one bit: 1 = white, 0 = black | [0 0 0 0; 1 1 1 1] |
| index | an index number pointing to a colour in a colour table | pixel 4 → table row 4 = (0.5, 0.5, 0.5) |
Slide 37. Choosing size and depth: for images of the same size, a low-detail image may need more pixel depth; as image size grows, fewer gray levels may be needed.
Slides 43–45. Pixel replication: to double the size, duplicate each row, then each column (any integer factor works the same way). New pixels are exact copies of old ones.
| 3 | 2 |
| 4 | 1 |
| 3 | 2 |
| 3 | 2 |
| 4 | 1 |
| 4 | 1 |
| 3 | 3 | 2 | 2 |
| 3 | 3 | 2 | 2 |
| 4 | 4 | 1 | 1 |
| 4 | 4 | 1 | 1 |
Slides 46–48. Interpolation uses known data to estimate unknown values (zooming, shrinking, rotating, geometric correction). Types: nearest neighbour, bilinear, bicubic. Nearest neighbour: mapping (find each target pixel's location in the source), selection (take the source pixel closest to it), assignment (copy its value): fast, but blocky “stair-step” edges.
Step 1 · ratios: Ratiorow = 3/6, Ratiocol = 3/6.
Step 2 · positions = ratio × [1 … 6], rounded up (ceil):
Step 3 · copy: output pixel (i, j) = old pixel (row position i, column position j).
| 10 | 4 | 22 |
| 2 | 18 | 7 |
| 9 | 14 | 25 |
| 10 | 10 | 4 | 4 | 22 | 22 |
| 10 | 10 | 4 | 4 | 22 | 22 |
| 2 | 2 | 18 | 18 | 7 | 7 |
| 2 | 2 | 18 | 18 | 7 | 7 |
| 9 | 9 | 14 | 14 | 25 | 25 |
| 9 | 9 | 14 | 14 | 25 | 25 |
Try it, step by step: the slide example. Change the new size (e.g. 5×5, 7×7, 9×9) to see how the positions change; the class-work matrices are solved just below.
Slide 52. Rounding choice matters: for 4 → 7 the positions are floor [0 1 1 2 2 3 4], ceil [1 2 2 3 3 4 4], round [1 1 2 2 3 3 4]. The slides use ceil (1-indexed).
2×2 → 5×5
Step 1 · ratios: Ratiorow = 2/5, Ratiocol = 2/5.
Step 2 · positions = ratio × [1 … 5], rounded up (ceil):
Step 3 · copy: output pixel (i, j) = old pixel (row position i, column position j).
| 1 | 4 |
| 3 | 7 |
| 1 | 1 | 4 | 4 | 4 |
| 1 | 1 | 4 | 4 | 4 |
| 3 | 3 | 7 | 7 | 7 |
| 3 | 3 | 7 | 7 | 7 |
| 3 | 3 | 7 | 7 | 7 |
3×3 → 9×9
Step 1 · ratios: Ratiorow = 3/9, Ratiocol = 3/9.
Step 2 · positions = ratio × [1 … 9], rounded up (ceil):
Step 3 · copy: output pixel (i, j) = old pixel (row position i, column position j).
| 1 | 4 | 3 |
| 7 | 2 | 3 |
| 5 | 6 | 0 |
| 1 | 1 | 1 | 4 | 4 | 4 | 3 | 3 | 3 |
| 1 | 1 | 1 | 4 | 4 | 4 | 3 | 3 | 3 |
| 1 | 1 | 1 | 4 | 4 | 4 | 3 | 3 | 3 |
| 7 | 7 | 7 | 2 | 2 | 2 | 3 | 3 | 3 |
| 7 | 7 | 7 | 2 | 2 | 2 | 3 | 3 | 3 |
| 7 | 7 | 7 | 2 | 2 | 2 | 3 | 3 | 3 |
| 5 | 5 | 5 | 6 | 6 | 6 | 0 | 0 | 0 |
| 5 | 5 | 5 | 6 | 6 | 6 | 0 | 0 | 0 |
| 5 | 5 | 5 | 6 | 6 | 6 | 0 | 0 | 0 |
4×4 → 7×7
Step 1 · ratios: Ratiorow = 4/7, Ratiocol = 4/7.
Step 2 · positions = ratio × [1 … 7], rounded up (ceil):
Step 3 · copy: output pixel (i, j) = old pixel (row position i, column position j).
| 1 | 4 | 3 | 7 |
| 2 | 3 | 4 | 5 |
| 2 | 6 | 4 | 3 |
| 4 | 7 | 1 | 0 |
| 1 | 4 | 4 | 3 | 3 | 7 | 7 |
| 2 | 3 | 3 | 4 | 4 | 5 | 5 |
| 2 | 3 | 3 | 4 | 4 | 5 | 5 |
| 2 | 6 | 6 | 4 | 4 | 3 | 3 |
| 2 | 6 | 6 | 4 | 4 | 3 | 3 |
| 4 | 7 | 7 | 1 | 1 | 0 | 0 |
| 4 | 7 | 7 | 1 | 1 | 0 | 0 |
Slide 56. Shrinking (down-scaling) works the same way, but instead of replicating, delete every second row and column (halving). Slides 57–61 (skip): bilinear interpolation takes a distance-weighted average of the 2×2 known neighbours (smoother than nearest neighbour); bicubic uses 4×4.