## 3 Proposed Method
### Image Encryption  
In the stage of encryption, the image of size \(M\times N\) is divided into four 256 \(\times\) 256 pixel blocks, for each 256 \(\times\) 256 size pixel block, and AQP is employed. The quadtree partitioning rule proposed in this paper is denoted as \(T\). \(T\) represents the minimum number of MSB bits shared by all pixels in the pixel block with the upper-left pixel. Subsequently, based on the pre-set \(T\), the image is further divided into 128 \(\times\) 128, 64 \(\times\) 64, 32 \(\times\) 32, 16 \(\times\) 16, 8 \(\times\) 8, 4 \(\times\) 4, and 2 \(\times\) 2 pixel blocks of varying sizes. The specific process code of adaptive quadtree partitioning is in Algorithm 1:  
```
1:\(I\): image to be segmented; \(T\): threshold
2:procedurebuildQuadtree(\(node\), \(x_{1},y_{1},x_{2},y_{2}\));
3:if The data difference is less than threshold.then
4:\(node\) indicates a leaf node;
5:save data;
6:return;
7:else
8:computation midpoint \(mx\leftarrow(x_{1}+x_{2})/2\), \(my\leftarrow(y_{1}+y_{2})/2\);
9:buildQuadtree(\(node\).\(topLeft\), \(x_{1},y_{1},mx,my\));
10:buildQuadtree(\(node\).\(topRight\), \(mx,y_{1},x_{2},my\));
11:buildQuadTree(\(node\).\(bottomLeft\), \(x_{1},my,mx,y_{2}\));
12:buildQuadtree(\(node\).\(bottomRight\), \(mx,my,x_{2},y_{2}\));
13:endif
14:endprocedure
15:Initializes the root node;
16:buildQuadtree(\(root\), \(x_{1},y_{1},x_{2},y_{2}\)) build a quadtree;
```  
**Algorithm 1** Adaptive quadtree partitioning  
### Image Encryption  
In the stage of encryption, the image of size \(M\times N\) is divided into four 256 \(\times\) 256 pixel blocks, for each 256 \(\times\) 256 size pixel block, and AQP is employed. The quadtree partitioning rule proposed in this paper is denoted as \(T\). \(T\) represents the minimum number of MSB bits shared by all pixels in the pixel block with the upper-left pixel. Subsequently, based on the pre-set \(T\), the image is further divided into 128 \(\times\) 128, 64 \(\times\) 64, 32 \(\times\) 32, 16 \(\times\) 16, 8 \(\times\) 8, 4 \(\times\) 4, and 2 \(\times\) 2 pixel blocks of varying sizes. The specific process code of adaptive quadtree partitioning is in Algorithm 1:  
```
1:procedurebuildQuadtree(\(node\), \(x_{1},y_{1},x_{2},y_{2}\));
2:if The data difference is less than threshold.then
3:\(node\) indicates a leaf node;
4:save data;
5:return;
6:else
7:computation midpoint \(mx\leftarrow(x_{1}+x_{2})/2\), \(my\leftarrow(y_{1}+y_{2})/2\);
8:buildQuadtree(\(node\).\(topLeft\), \(x_{1},y_{1},mx,my\));
9:buildQuadtree(\(node\).\(topRight\), \(mx,y_{1},x_{2},my\));
10:buildQuadTree(\(node\).\(bottomLeft\), \(x_{1},my,mx,y_{2}\));
11:buildQuadtree(\(node\).\(bottomRight\), \(mx,my,x_{2},y_{2}\));
12:endif
13:endprocedure
14:Initializes the root node;
15:buildQuadtree(\(root\), \(x_{1},y_{1},x_{2},y_{2}\)) build a quadtree;
16:\(S\): segmented image; \(block\_{s}\): block type

Figure 6: The framework of the proposed method. Block-level encryption is then performed, using the encryption key \(\mathrm{K_{e}}\) and the classical stream cipher. This process ensures that the partitioning structure \(S\), obtained through the encrypted image, remains identical to that obtained before encryption, which ensures the reversibility of the method. To counteract the KPA attack proposed in [26], pixel modulation is performed after block-level encryption. An example of pixel modulation is shown in Figure 7. For an encrypted image, according to the \(S\) derived from AQP, a round of Arnold permutation is first executed. According to \(md\), this paper defines that for pixel values converted to eight bits binary, the high bits are the \(md\) bits starting from the highest bit, and the remaining \(8\)-\(md\) bits are the low bits. Thereafter, using the permutable keys \(\mathrm{K_{1}}\) and \(\mathrm{K_{2}}\), the high and low bits of the pixels within each block are permuted, respectively.