*3.2. N-Dimensional MSM (NMSM)*

In this section, we introduce the construction of NMSM and the secret data-embedding and extraction algorithm, based on the NMSM. In addition, a fast algorithm for the inner embedding layer is proposed to improve the time efficiency.

#### 3.2.1. The Data-Embedding and Extraction Algorithm

To boost the efficiency of data embedding and extraction, the proposed secret data-embedding scheme can be generalized to an n-dimensional version. In the NMSM, a basic structure consists of 2*<sup>n</sup>* elements and 2*<sup>n</sup>* basic structures constitute a submatrix. An n-tuple pixel group can uniquely map to an element in the NMSM. Therefore, by applying the same embedding rule, we can hide n MSBs with the label of basic structure and n LSBs with the element value. The pseudo codes for the NMSM-based embedding and extraction schemes are given as follows:

The secret data-embedding algorithm based on the n-dimensional mini-SuDoKu matrix (NMSM) Input: cover image *P*, secret stream *S*, secret key *K*

Output: stego image *P* Step 1: Construct the NMSM *M* using the secret key *K* (details are given in Appendix B);

(a) Make an n-dimensional array of size 16*n*, which consists of 8*<sup>n</sup>* submatrix;

(b) Repeat the array to obtain NMSM;

Step 2: Group the cover pixels into *P* = - *pX*(0)*i*, *pX*(1)*i*, ... , *pX*(*n*−1)*<sup>i</sup> <sup>i</sup>* <sup>=</sup> 1, 2, ... , (*<sup>H</sup>* <sup>×</sup> *<sup>W</sup>*)/*<sup>n</sup>* ;

Step 3: Segment secret digits *S* = *sj* = - *dj* <sup>2</sup>*n*−1*d<sup>j</sup>* <sup>2</sup>*n*−<sup>2</sup> ... *<sup>d</sup><sup>j</sup>* 0 *<sup>j</sup>* <sup>=</sup> 1, 2, ... , *<sup>L</sup>*/2*<sup>n</sup>* ;

Step 4: Locate the basic structure *M* - *G* - *pX*(0)*i*, *<sup>d</sup><sup>j</sup> n* , *G* - *pX*(1)*i*, *<sup>d</sup><sup>j</sup> n*+1 , ... , *G* - *pX*(*n*−1)*i*, *<sup>d</sup><sup>j</sup>* 2*n*−1 by applying Equations (2) and (3);

Step 5: Search the matching element in the located basic structure

$$M\Big(p\_{X(0)i'}', p\_{X(1)i'}', \dots, p\_{X(n-1)i}'\Big) = \left(2^{n-1} \times d\_{n-1}^j + 2^{n-2} \times d\_{n-2}^j + \dots + 2^0 \times d\_0^j\right);$$

Step 6: Record *p X*(0)*i* , *p X*(1)*i* , ... , *p X*(*n*−1)*i* to stego image *P* ;

Step 7: Repeat Steps 4–6, until all secret digits are embedded.

The secret data extraction algorithm based on the n-dimensional mini-SuDoKu matrix (NMSM) Input: stego image *P* , secret key *K*

Output: secret stream *S*

Step 1: Construct the NMSM by the same process as Step 1 of embedding;

$$\text{Step 2: Group the stego pixels into } P' = \left\langle \left| p'\_{X(0)i'} p'\_{X(1)i'}, \dots, p'\_{X(n-1)i} \right| i = 1, 2, \dots, \left( H \times W \right) / n \right\rangle$$

;

Step 3: Extract the n LSBs by *s<sup>L</sup> <sup>j</sup>* = ! *M p X*(0)*i* , *p X*(1)*i* , ... , *p X*(*n*−1)*i* " 2

Step 4: Extract the n MSBs by

$$s\_j^M = \left(mod(p'\_{X(n-1)i'}4)/2, mod(p'\_{X(n-2)i'}4)/2, \dots, mod(p'\_{X(0)i'}4)/2\right);$$

Step 5: Concatenate *sj* = *sM j sL j* ;

Step 6: Repeat Steps 3–5, until all secret digits are extracted.

### 3.2.2. Fast Algorithm for the Inner Layer of Embedding

As the MSM generalized to n-dimensions, the basic structure for embedding can be efficiently determined by the range locator. However, the searching process in the Step 5 of embedding algorithm becomes burdensome. To improve time efficiency of the inner embedding layer, we devise a fast algorithm to overcome this burden. Its key idea is to leverage the matrix operation supported by the MATLAB language. The pseudo code of the fast algorithm is given as follows: More precise pseudo code expressed in MATLAB instructions is given in Appendix C.

Fast Algorithm for the Inner Embedding Layer (details are given in Appendix C) Input: n LSBs of secret segment *sL j* , basic structure for embedding

$$A = M(G(p\_{\mathcal{X}(0)i'}d\_n^j), G(p\_{\mathcal{X}(1)i'}d\_{n+1}^j), \dots, G(p\_{\mathcal{X}(n-1)i'}d\_{2n-1}^j)))$$

Output: stego pixel values *p X*(0)*i* , *p X*(1)*i* , ... , *p X*(*n*−1)*i* 

