M02 · Mathematics alongside
Matrices, operators and bases
Transparent channel mixing, a linear filter and reconstruction from a few contributions.
Mathematical support for the textbook chapters: start with a small calculation, then an interactive example and precise definitions.
Work through a small example
One matrix row takes three values with weights ¼, ½, ¼. What is the result?
- One operator row
Another row uses different coordinates with the same weights. The whole filter becomes a matrix: one row per output and one column per input. The weights stay fixed; doubling the input gives 9.
The same operator for different inputs
A linear operator A preserves addition and scaling: . Averaging with fixed weights and declared linear boundary rules is linear; the median is not. Adding a nonzero constant bias makes a transform affine rather than linear.
A 3×3 RGB mixing matrix acts at every point. Spatial convolution also becomes a matrix after flattening an image, often a very sparse one. Applying its local rule does not require storing that whole matrix. The transpose satisfies ; it is generally not .
At one selected output pixel, fixed weights multiply neighboring inputs and sum: one row of a linear operator. Compare a neighbor's contribution with the total. This illustrates local linear action, not every matrix decomposition defined below.
Which contributions produce a pixel?
Select a cell in either image. The left frame marks its neighbors, the middle shows their values, weights and products, and the right shows the result. Start with a black-and-white mean, then try grayscale and color.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
Each curve point is a pixel value on the marked horizontal line. Select another image row to move the graph. Compare edge width and preservation of detail.
- Input
- Output
The mean replaces a pixel with its neighbors' average; the Gaussian kernel favors the center. Sobel measures change, so negative results are valid. For color, the same rule runs independently on the selected R, G or B channel.
Parameters and details
Correlation uses weights as drawn; convolution rotates them by 180°. An asymmetric kernel exposes the difference. Derivative and sharpening preserve negative values: display colours do not alter the array. Weights below are after the chosen rotation, in row order.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
A basis gives reconstruction directions
Definitions and details
Vector (3,2) equals 3·(1,0)+2·(0,1). Likewise an image can be expanded into stripes, sinusoids or other basis images. Orthonormal directions are mutually perpendicular and unit length, so a coefficient equals the inner product with its direction.
An eigenvector preserves direction under A: . A real symmetric matrix has an orthonormal eigenbasis. Positive definiteness means for every nonzero x; for a symmetric matrix this is equivalent to positive eigenvalues. An arbitrary matrix need not have a real orthonormal eigenbasis.
SVD and PCA answer different questions
Definitions and details
Every finite real matrix A has an SVD: with orthogonal U,V and nonnegative singular values. Keeping the r largest terms gives a best rank-at-most-r approximation in Frobenius norm; tied singular values can make it nonunique. This is a precise matrix-and-norm statement, not a visual-quality guarantee.
PCA finds maximum-variance directions of centered observations. For a spectral cube, observations can be pixel spectra and features the bands. The rank of one grayscale image matrix and covariance eigendirections of a spectrum collection are different decompositions. Centering, units and feature scale affect interpretation.
A linear system need not have an exact solution
Definitions and details
Ax=b can have more equations than unknowns, fewer, or equally many. Least squares minimizes . If A has independent columns, the solution is unique; normal equations describe it, but QR or SVD are often more stable than directly solving through .
Small singular values amplify noise under inversion. Truncating weak directions or regularizing stabilizes results at the cost of bias. This explains why an 'inverse filter' can look worse than the blurred observation.