3.1.3. Permutation

In this part, matrix *S*1 is used to permute plaintext image. At the beginning, each element in *S*1 should be allocated to each pixel as index. Hence, an *N* × *N* × 3 matrix *S*1 is needed to be converted from *S*1 by reshaping.

$$S\_1' = reshape(S\_1, N, N, \mathcal{3})\tag{8}$$

Afterwards, each pixel in plaintext image has a corresponding index in *S*1 at the same coordinate. Combine plaintext image with matrix *<sup>S</sup>*1, and take another reshaping operation to convert these two matrix into two sequences with a length of *N* × *N* × 3. After sorting *S*1 ascendingly with image sequence synchronously, pixels' orders in plaintext image sequence have been scrambled.

Finally, reshaping the sorted image sequence to an *N* × *N* × 3 matrix, the initial cipher image could be generated.
