Quiz: images as arrays & geometric transforms
Short questions to test your understanding. Try each on paper first, then open the answer. Questions marked (math) use the formulas from the math slides; the others need only the ideas.
Q1. A 16-bit greyscale microscopy image has 2048 × 2048 pixels. How many different grey levels can a pixel take, and how many bytes does the image need (uncompressed)?
2^{16} = 65\,536 grey levels (0 to 65 535). Each pixel needs 2 bytes, so 2048 \cdot 2048 \cdot 2 = 8\,388\,608 bytes, i.e. 8 MiB.
Q2. Without multiplying anything out: what does A = \begin{bmatrix} 0 & -1\\ 1 & 0\end{bmatrix} do to an image? And B = \begin{bmatrix} 0 & 1\\ 1 & 0\end{bmatrix}?
Read the columns: where do (1, 0) and (0, 1) go? Then look at the determinant.
A sends (1,0) \to (0,1) and (0,1) \to (-1,0): a rotation by 90° counter-clockwise, \det A = 1. B swaps the two axes, (1,0) \leftrightarrow (0,1): a reflection in the line y = x, \det B = -1, so the image is mirrored.
Q3. You scale an image by a factor 3 by sending every input pixel to its new position. Why does the result look like a grid of isolated dots, and how do you avoid it?
Forward mapping sends the N^2 input pixels to N^2 positions spread over an area 9 times larger, so 8 of every 9 output pixels receive nothing. Use inverse mapping: for every output pixel \mathbf{x}', look up the input at A^{-1}\mathbf{x}' and interpolate.
Q4. A transform has \det A = 0.25. What happens to the area of a cell in the image? Can you undo the transform?
Every area is multiplied by 0.25, so the cell covers a quarter of its original area (for example, scaling both axes by 0.5). It is invertible, since \det A \neq 0, so geometrically yes. But when you shrink an image onto the same pixel grid, detail finer than the new pixel spacing is lost, and transforming back cannot restore it.
Q5. (math) Why does rotating about the image centre need a 3 \times 3 matrix, while rotating about the origin needs only a 2 \times 2 one?
A 2\times2 matrix always keeps the origin fixed, A\mathbf{0} = \mathbf{0}. Rotating about another point \mathbf{p} needs a translation: shift \mathbf{p} to the origin, rotate, shift back. Translation is not linear, but it becomes a matrix product in homogeneous coordinates, which are 3\times3.
Q6. A label image stores an object number in every pixel: 0 for the background, 1, 2, 3, … for the cells. You rotate it by 30°. Why should you use nearest-neighbour interpolation, not bilinear?
What does bilinear interpolation give halfway between a pixel of cell 2 and a pixel of cell 4?
Bilinear interpolation averages neighbouring values. Halfway between cell 2 and cell 4 it gives 3: the number of a different cell, and along every cell boundary it invents values that are not labels of anything there (0.5 between background and cell 1, and so on). Nearest neighbour only ever copies existing values, so every output pixel is still a valid label.