Linear algebra: is there a matrix representation of cropping an image?

image processinglinear algebra

Can I write a matrix description of cropping an image to a given size? It doesn't even need to be an image, simply some rectangle $\square ABCD$, and a crop boundary $\square EFGH$. Is there a representation of their intersection that could be described algebraically?

Best Answer

It depends what you are asking for exactly. A matrix represents a linear map, in this case I will assume you mean a map $\Bbb R^2\to\Bbb R^2$.

Given arbitrary rectangles $\square ABCD$ and $\square EFGH$, is there a linear map taking $\square ABCD$ to $\square EFGH$ (isomorphically)?

The answer is no because linear maps must preserve the origin. Consider when $\square ABCD$ is the unit square $[0,1]\times[0,1]$ and $\square EFGH$ is any rectangle which doesn't contain the origin.

Can we still use linear algebra (or at least matrix notation) to express the information we want?

Yes. Any rectangle can be translated so that one corner is the origin. The two sides of the rectangle can be considered as vectors $u$ and $v$ (which you can visualize as arrows pointing away from the origin). Then the matrix taking $[0,1]\times[0,1]$ to the rectangle with one corner at the origin and sides formed by $u$ and $v$ is just $[u\ v]$ (here $u$ and $v$ are column vectors, so this is a $2\times 2$ matrix). We can remember where the original rectangle's corner was using another vector.

There won't be any way to avoid needing more data than just one matrix here, because in my interpretation cropping is not a linear map (but rather affine).

Related Question