Rotating a 2D image with Permutation matrix

1k Views Asked by At

As I understand, permutation matrices are rotation matrix with even permutation corresponds to a proper rotation and odd permutation corresponds to an improper rotation.

Does not that mean that, If I multiply a binary image (simply a matrix of 0s and 1s), I get a rotation of the image ?. But I do not get it. What does exactly happens ?. Can anyone please explain to me ?

2

There are 2 best solutions below

2
On BEST ANSWER

A permutation matrix (call it $P$) is a nonsingular (hence, square) matrix where all elements are zero except for one element on each row which is $1$.

Consider now any square matrix $A$ (maybe, an image) and let $$ B = PA$$ then, if the $i$th element of row $j$ is $1$, this means that the $j$th row of $B$ is equal to the $i$th row of $A$. For instance, if i have two matrices

$$ A = \begin{pmatrix} 0 & 0 &0 & 0 & 0\\ 0 & 1 &1 & 0 & 0\\ 0 & 1 & 0 & 1 & 0\\ 0 & 1 & 0 & 1 & 0\\ 0 & 1 & 1 & 0& 0 \end{pmatrix}, \quad P = \begin{pmatrix} 1 & 0 &0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0\\ 0 & 0 & 1 & 0 & 0\\ 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0& 1 \end{pmatrix}. $$ Then, the result would be

$$ B = PA = \begin{pmatrix} 0 & 0 &0 & 0 & 0\\ 0 & 1 & 0 & 1 & 0\\ 0 & 1 & 0 & 1 & 0\\ 0 & 1 &1 & 0 & 0\\ 0 & 1 & 1 & 0& 0 \end{pmatrix}, $$ or, in pictures

enter image description here

You could say that they are rotation matrices but I don't know if that will give you more intuition as to how they work. I believe thinking of them as "row swappers" is more intuitive and useful.

If we postmultiply by the permutation matrix, you get the same effect but for the columns (so a $1$ element in position $i$ in row $j$ means that column $j$ in the output was column $i$ in the input); so doing $AP$ would give you

enter image description here

A rotation matrix would allow you to perform similar operations, but the rows of the output would be combinations of the rows of the input (with $\sin$ and $\cos$ relationships).

0
On

As you say, it can be confusing to think of rotating a matrix that represents an "image", since a $90$ degree rotation, for example, would make you think that a matrix that is $m$ x $n$ should now become $n$ x $m$. But this is not true, since rotation matrices are square. So instead of thinking of it like multiplying by the rotation matrix, I would suggest thinking of it as explained in this post - in other words, you should take each pixel in the "output" matrix, and apply the inverse transformation matrix and look at the corresponding pixel in the "input" matrix.