Suppose that matrix A represents an 256 X 256 image

343 Views Asked by At

Suppose that matrix A represents an 256 X 256 image what matrix operation would you use to produce a plot of :

a)A rotated 90 clockwise.

b) A rotated 180 counterclockwise.

c)A with its elements reflected across the main diagonal.

d)A with the first 128 columns colored gray.

please any hint or help with that I appreciate it

1

There are 1 best solutions below

6
On

In general, most of these geometrical operations on matrices are trivially found by combining transposition (i.e. rotating through the diagonal) and flip permutation (rotating through a mid vertical line). That is the reason the next expressions are quite similar.

Let have the permutation matrix $P_{i_1... i_n}=[e_{i_1} ... e_{i_n}]$ with $e_{i}$ the column base vector with a 1 at the $i$th row, and $D_{d_1... d_n}$ the diagonal matrix with $d_i$ as the diagonal $i$th position. Lets assume the image maps in $[0,1]$.

a) $A' P_{n...1}$

b) $P_{n...1} A P_{n...1}$

c) $A'$

d) $A D_{d_1...d_n}$ with $d_1...d_{n/2}=1/2$ and $d_{n/2+1}...d_n=1$

Let try the following example in Octave for $\mathbb{R}^4$:

% Simple Example
n=4;
A=rand(n,n);
P=fliplr(eye(n));
D=diag([0.5 0.5 1 1]);
A1=A'*P,A2=P*A*P,A3=A',A4=A*D