Introduction

Advancements in data transmission and multimedia processing techniques add significant risks to the security and privacy of medical data. As a vital data type, images are essential in various fields, including electronic healthcare1. These images typically contain sensitive information2, and unauthorized access to this data could result in significant problems. Developing an efficient and safe image encryption algorithm has become a considerable concern in image processing3. Researchers have suggested several encryption techniques, including chaos-based4,5,6, DNA-based7,8,9, compressive sensing10,11, transform domain12, and AI-based13,14 approaches, among others. Hosny et al.15 presented an elegant and extensive survey for securing multimedia content using various encryption approaches.

Many researchers are focusing on studying MIE algorithms to secure the large number of medical images transmitted16. MIE enhances security by combining multiple images into a single encrypted format, increasing complexity and making unauthorized decryption more challenging. This approach provides cohesive protection that mitigates the effects of breaches, surpassing the individual safeguarding of single images in complexity. Additionally, it reduces computational expenses compared to processing each image independently.

In recent years, several notable MIE algorithms have been proposed, including17,18. In the first paper, Chen et al. used DNA, and the gyrator transformed with the XOR operation to design an algorithm for MIE. In the second paper, Zhang et al. used DCT, Lorenz, and logistic maps to encrypt multiple images. Zhang & Gao19. proposed a MIE technique based on using a scrambling-diffusion structure, bit planes, Zigzag transformation, and exclusive OR operation. Wu et al.20 proposed an MIE algorithm based on DNA encoding and the SHA-256 hashing algorithm. Song et al.21 proposed a parallel image encryption scheme using intra-bitplane scrambling and multithreaded diffusion to accelerate the encryption process. While the method targets single images, its parallel architecture and efficiency improvements are highly relevant to MIE scenarios, where speed and scalability are critical.

Perez et al.22 proposed an MIE algorithm based on the JTC architecture, GT, and the JGPD. Zhang & Liu23 developed an MIE algorithm for encrypting multiple grayscale images using SZT, the Henon chaotic map, and the 2D ZT. Kumar & Dua24 utilized the ESC map and DNA to develop an MIE algorithm for RGB color images. Liu et al.25 proposed a semantically enhanced selective image encryption scheme based on salient object detection and parallel chaos-based encryption. Although it focuses on single images, its strategy of encrypting only sensitive regions and improving efficiency via parallel processing is relevant to MIE scenarios, where both speed and intelligent resource usage are essential.

Song et al.26 introduced a batch image encryption scheme that utilizes cross-image permutation and bidirectional diffusion, enabling the encryption of multiple images of varying sizes without requiring preprocessing. Du et al.27 proposed an MIE technique, which the study implemented into face images. The study began with a face detection process to capture the desired facial information from multiple plain images that were input.

Stack Image Representation (SIR) employs a stacking approach, where images are arranged in layers along the vertical dimension, resulting in a 3D array28. This representation is beneficial for enhancing the security of image encryption and enabling simultaneous processing of multiple images, preserving their unique characteristics while improving efficiency and maintaining data integrity, making it a valuable strategy for robust multidimensional image handling.

Despite their efficiency, existing MIE schemes have certain limitations. Certain methods are limited to encrypting a specific number of images simultaneously rather than accommodating an arbitrary number. Most algorithms are primarily tested on standard grayscale images, with very few explicitly tailored for medical image encryption. Others work with either grayscale or color images only. This paper, therefore, introduces an encryption scheme designed explicitly for multiple medical images. This paper’s primary contributions are delineated as follows:

  1. 1.

    The proposed MIE algorithm encrypts a massive number of medical images simultaneously and is designed to effectively encrypt grayscale and color images, showcasing its adaptability and broad applicability.

  2. 2.

    It creates interconnected cipher images within the same stack, where if one cipher image is lost, the remaining cipher images in the stack can help recover partial information from the lost image.

  3. 3.

    MIE is implemented using multilayer encryption to enhance security, including subdivision, 3D transformation, block segmentation, confusion, and diffusion processes. Subdivide the images and apply 3D transformations to increase the complexity of the decryption process.

  4. 4.

    Applying block segmentation-based encryption to disrupt the intra-correlation between adjacent pixels and utilize different keys generated from a Baker chaotic map, incorporating swapping and XOR operations to apply confusion and diffusion processes for each block.

This multi-stage approach provides high security and complexity, making unauthorized decryption attempts for multiple medical images challenging. It integrates stacking randomization, confusion, and diffusion, supported by chaotic maps and stacking representation.

The paper is organized as follows: the proposed MIE algorithm is presented in Sect. 2. The validity and the effectiveness of the proposed method are presented in Sect. 3. Experiments, results, and the discussion are included in Sect. 4. Finally, the conclusion is given in Sect. 5.

Proposed method

Encryption scheme for color images

The encryption process for multiple images involves several sequential steps, each contributing to the security of the images. The entire process can be broken down into the following stages, as illustrated in the diagram below.

Crop process

For each original image \(\:I\:\)with dimension \(\:W\times\:H\times\:D\:\)and desired crop size \(\:{w}_{c}\:and\:{h}_{c}\):

  1. 1.

    Split each image into RGB channels \(\:{I}_{r},{I}_{g},\:{I}_{b}\), each of which has a size of \(\:W\times\:H\).

  1. 2.

    Determine the number of crops in both the width and height directions.

    $$\:{N}_{x}=\left[\:\frac{W}{{w}_{c}}\:\right],\:{N}_{y}=\left[\:\frac{H}{{\:h}_{c}}\:\right]\:$$
    (1)

Where \(\:{N}_{x}\) represents the number of crops along the horizontal direction, and \(\:{N}_{y}\:\)represents the number of crops along the vertical direction.

  1. 3

    For each crop \(\:(i,j)\) operation:

  1. a.

    Determine the coordinates of each crop.

$$\:{x}_{s}=i\cdot \:{w}_{c}\:,\:{x}_{e}={x}_{s}+\:{w}_{c}$$
$$\:{y}_{s}=j\cdot \: {h}_{c}\:,\:{y}_{e}={y}_{s}+\:{h}_{c}$$

Where,

$$\:i\in\:\left[0,\:{N}_{x-1}\right]\:,\:j\in\:[0,{N}_{y-1}]$$
(2)

Where \(\:i\) denotes the horizontal index and \(\:j\:\)denotes the vertical index. \(\:{x}_{s},\:\:{x}_{e}\:\)are the start and end coordinates along the horizontal direction, and \(\:{y}_{s},\:\:{y}_{e}\:\)along the vertical direction.

  1. 4.

    Use the calculated coordinates to extract crops for each channel:

$$\:{I}_{rc}\left(i,j\right)={I}_{r}\left[{\:y}_{s}:{y}_{e}\:,\:{x}_{s}:{x}_{e}\:\right]$$
$$\:{I}_{gc}\left(i,j\right)={I}_{g}\left[{\:y}_{s}:{y}_{e}\:,\:{x}_{s}:{x}_{e}\:\right]$$
$$ \:{I}_{bc}\left(i,j\right)={I}_{b}[{\:y}_{s}:{y}_{e}\:,\:{x}_{s}:{x}_{e}\:]$$
(3)

Stacking process

After cropping all input images into smaller crops, the stacking process proceeds as follows:

  1. 1.

    Determine the total number of 2D crops.

$$\:N={[{N}_{x}+{N}_{y}]}^{2}\times\:n$$
(4)

Where \(\:n\) is the total number of input images.

  1. 2.

    Initialize \(\:cube\) of size \(\:N\times\:{w}_{c}\times\:{h}_{c}\), and stack the crops \(\:{C}_{l}\) onto it.

$$\:cube\left[l,a,b\right]={C}_{l}$$

where:

$$\:l\in\:\left[1,N\right],\:a\in\:\left[1,{w}_{c}\right],\:b\in\:[1,{h}_{c}]$$
(5)

3. Repeat steps 1 and 2 for each channel.

Block division

  1. 1.

    Let the block size be \(\:{b}_{x},{b}_{y},\:and\:{b}_{z}\). Determine the number of blocks that fit along all dimensions:

$${N}_{b}=\left(\: \lfloor\frac{{w}_{c}}{{b}_{x}}\rfloor \:\times\: \lfloor \frac{{h}_{c}}{{b}_{y}} \rfloor\times\:\: \lfloor \frac{N}{{b}_{z}}\rfloor\:\right)$$
(6)
  1. 2.

    Iterate \(\:{N}_{b}\) over the \(\:cube\) to extract blocks by slicing them. For each iteration, extract a block as follows:

$$\:block=cube\:\left[{\:d}_{x}\::{d}_{x}+{b}_{x}\:,\:{d}_{y}\::{d}_{y}+{b}_{y}\:,\:{d}_{z}\::\:{d}_{z}+{b}_{z}\right]$$

where:

$$\:{d}_{x}\in\:\left[0\:,\:{w}_{c}\:,\:{b}_{x}\right]$$
$$\:{d}_{y}\in\:\left[0\:,\:{h}_{c}\:,\:{b}_{y}\right]$$
$$\:{d}_{z}\in\:\left[0\:,\:N\:,\:{b}_{z}\right]$$
(7)
  1. 3.

    Repeat steps 1 and 2 for each channel.

Permutation and substitution

In this process, pixels in each block are permuted and substituted using different keys according to the following steps.

  1. 1.

    Generate two keys for each block using \(\:\alpha\:\:and\:\beta\:\) parameters, which are calculated as follows:

$$\:{\upalpha\:}=\frac{(\sum\:block)+(W\times\:{w}_{c}\times\:{b}_{x})}{{2}^{23}+\left(H\times\:{h}_{c}\right)}$$
$$\:\beta\:=\frac{{e}^{\left(\alpha\:\:mod\:2\right)}}{10}$$
(8)
  1. 2.

    Insert \(\:\alpha\:\:and\:\beta\:\) parameters into the Baker map defined by29 to generate the keys \(\:({X}_{p},\:{Y}_{s})\).

$$\:\left({X}_{n+1},{Y}_{n+1}\right)=\:\left\{\begin{array}{c}\left(\frac{{X}_{n}}{\alpha\:},\alpha\:{Y}_{n}\right),\:0<X\:\le\:\alpha\:\\\:\left(\frac{{(X}_{n}-\alpha\:)}{(1-\alpha\:)},\:\left(1-\alpha\:\right){Y}_{n}+\left(1-\alpha\:\right)\right),\:\alpha\:<x\le\:1\end{array}\right.$$
(9)
  1. 3.

    Apply the permutation process for each block. In this phase, the pixel positions across the block are permuted to achieve a more complex data mixing. In this step \(\:block\) cube is scrambled by using a sequence \(\:{X}_{p}\) as follows:

  1. i.

    Flattening block cube into a 1D vector \(\:v\), as follows:

$$\:v\left[r\right]=block[\:{b}_{x}\:,{b}_{y}\:,{\:b}_{z}\:]$$
(10)

where \(\:r\) is a linear index in the 1D vector, and let \(\:{v}_{n}=\:{b}_{x}\times\:{b}_{y}\times\:{b}_{z}\).

ii. Swapping values in the vector as follows:

$$\:let,\:{K}_{1}=\lfloor{X}_{p}\rfloor\:mod\:{v}_{n}$$
$$\:then,$$
$$\:\:v\left[r\right]\leftrightarrow\:v\left[{K}_{1}\left[r\right]\right],\:r\in\:\left[0,{v}_{n}\right]$$
(11)
  1. 4.

    Apply the substitution process for each block. In this phase, the pixel values are adjusted to obscure their original content using \(\:{Y}_{s}\), where the values of the vector \(\:v\) is changed as follows:

    1. i.

      The bitwise XOR operation is performed as follows.

$$\:let,\:{K}_{2}=\lfloor{Y}_{s}\rfloor\:mod\:{v}_{n}$$
$$\:then,$$
$$\:\:v\left[r\right]=\text{v}\left[r\right]\oplus\:{K}_{2},\:\text{r}\in\:[0,{v}_{n}]$$
(12)

ii. Reshaping of vector \(\:v\) is performed to obtain a final encrypted \(\:block\) cube, as follows.

$$\:block\left[\:{b}_{x}\:,{b}_{y}\:,{\:b}_{z}\:\right]=\:v\left[r\right]$$
(13)
  1. 5.

    Repeat steps from 1 to 4 are applied to each block separately, obtaining a total \(\:{N}_{b}\) encrypted blocks.

  2. 6.

    Reconstruct the stack from the encrypted blocks to obtain the encrypted stack cube.

  3. 7.

    Repeat steps 1 to 6 for each channel, resulting in three RGB-encrypted stacked cubes.

  4. 8.

    Merge the RGB encrypted stacked cubes to produce the final cipher stacked image.

The entire encryption process is shown in Fig. 1.

Illustrative example for one channel

We use 64 images from the Multi-Cancer Dataset—8 Types of Cancer Images dataset. This dataset contains images of various cancer types, compiled for research and analysis purposes. It encompasses 8 main cancer classes and 26 subclasses, offering a comprehensive resource for medical image classification and machine learning applications. Given that the number of input images is \(\:n=64\), where the size of each image is \(\:W=512,\:H=512\) and crop size \(\:{w}_{c}=256,\:{h}_{c}=256\). Determine the number of crops along the width \(\:{N}_{x}\) and along the height \(\:{N}_{y}\):

$$\:{N}_{x}=\left[\:\frac{512}{256}\:\right]=2,\:{N}_{y}=\left[\:\frac{512}{256}\:\right]=2$$
(14)

The grid consists of a \(\:2\times\:2\) matrix of crops, with each crop defined by its coordinates \(\:{x}_{s},{y}_{s},{x}_{e},{y}_{e}\), Which results in Table 1:

Table 1 Example of the result of the crop process.
Fig. 1
figure 1

Encryption Process.

Figure 2 illustrates the crop process for the illustrative example of one image. The previous steps applied to all input images resulted in a total number of crops \(\:N:\)

$$\:N={\left[2+2\right]}^{2}\times\:64=256$$
(15)
Fig. 2
figure 2

Crop process of the illustrative example for one channel. (a) crop frame. (b) original image with the crop frame. (c) The result of the crop process.

The total of 256 crops is stacked together, resulting in a 3D cube of size \(\:256\times\:256\times\:256\). Figure 3 shows the result of the stack process of the illustrative example. In the block segmentation process, let the block size be \(\:\left(128,\:128,\:128\right)\) then, the number of blocks that fit along each dimension is:

$${N}_{b}=\left(\:\lfloor \frac{256}{128}\rfloor \:\times\:\: \lfloor \frac{256}{128}\rfloor \times\:\: \lfloor\frac{256}{128}\rfloor \:\right)=8$$
(16)
Fig. 3
figure 3

The result of the stacking process. The authors created the 3D visualization by using Python 3.9.12 and Plotly v6.2.0 (https://plotly.com/python/).

Fig. 4
figure 4

The result of the block segmentation, permutation, and substitution processes for the R-channel. The authors created the 3D visualization by using Python 3.9.12 and Plotly v6.2.0 (https://plotly.com/python/).

Figure 4   shows the result of the block segmentation process of the illustrative example, as well as the result of the permutation and substitution processes.

Table 2 is the representation for visualizing the block extraction for a total of 8 blocks:

Table 2 Example of the result of the block extraction process.

Examples of plain images from the mentioned dataset and their corresponding encrypted images are shown in Fig. 5.

Fig. 5
figure 5

(a, c, e, g, i, k) Examples of plain images from the mentioned dataset and (b, d, f, h, j, l) their corresponding encrypted images.

Decryption process

The encrypted images are divided into sub-images and stacked into a 3D cube in the decryption process. Block segmentation is then performed to prepare the images for reversing the encryption process. Figure 6 illustrates the entire decryption procedure.

Fig. 6
figure 6

Decryption Process.

Performance analysis

Three experiments were conducted to evaluate the proposed scheme’s performance. Table 3 provides details of the images, cubes, and blocks used in these experiments.

Table 3 Experiments information.

Key space

A valid image cryptosystem requires a key space large enough to render standard attacks, such as brute-force, infeasible. The key space represents the complete set of possible keys available for encryption/decryption. The secret key mainly consists of the initial values (\(\:u,t)\:\)and the control parameter \(\:\left(\rho\:\right)\:\)and the keys parameter \(\:(\alpha\:,\beta\:)\). Suppose the control parameter initial values and key parameter precision are\(\:{10}^{-15}\). Thus, the corresponding key space value is \(\:{\left({10}^{15}\right)}^{5\times\:{N}_{b}}\:\)where the minimum \(\:{N}_{b}\) value is equal to 2. So, the minimum key space value for the scheme is approximately \(\:{\left({10}^{15}\right)}^{5\times\:2}={10}^{150}\approx\:\:{2}^{498.29}\) which is greater than \(\:{2}^{128}\). Hence, the scheme has a highly adequate key space, therefore being resilient toward brute-force attacks. Table 4 lists the key spaces of the three experiments used.

Table 4 Key Pace analysis.

Key sensitivity

The secret key should be completely different when generated using different initial conditions, especially when the difference between these initial conditions is minimal. To carry out the key sensitivity analysis, there are two primary steps. The first one, \(\:{Key}_{1}\), is generated with the initial conditions \(\:{x}_{0},\:{y}_{0}\:\)and used to encrypt the plain image, resulting in a cipher image \(\:{c}_{1}\). In the second step, we change the initial conditions to \(\:{x}_{0}+{10}^{-10},\:{y}_{0}+{10}^{-10}\), then generate \(\:{Key}_{2}\) and use it to encrypt the same plain image, resulting in a cipher image \(\:{c}_{2}\). Finally, we decrypt the two encrypted images with the original \(\:{Key}_{1}\). Figure 7 illustrates the results of these processes.

Fig. 7
figure 7

Key Sensitivity. (a) Plain image. (b) Cipher Image “\(\:{c}_{1}\)” using \(\:{Key}_{1}\). (c) Cipher Image “\(\:{c}_{2}\)” using \(\:{Key}_{2}\). (d) Decrypted Image c1 using the modified \(\:{Key}_{2}\). (f) Decrypted Image \(\:{c}_{1}\)using the original \(\:{Key}_{1}\).

Entropy

Entropy, as defined by30, quantifies an image’s level of randomness or unpredictability. It is a metric to assess how much information is hidden or concealed within the image. The entropy of the encrypted image was calculated and compared to that of the original image. The encrypted images showed a significant increase in entropy, indicating a high level of randomness and, thus, enhanced security. The amount of entropy \(\:H\) of an image is determined by utilizing the following formula:

$$\:H=-{\sum\:}_{i}^{N-1}{p}_{i}{\text{log}}_{2}\left({p}_{i}\right)$$
(17)

Where \(\:N\) is the number of possible pixel values and \(\:{p}_{i}\), is the probability of occurrence of the \(\:i-th\) pixel value in the image. Ideally, the information entropy for a grayscale image is 8. Table 5 provides an entropy of the three implemented experiments after encryption. An entropy value of \(\:7.9999\) bits per pixel in the encrypted image is close to the theoretical ideal value. The high entropy of the encrypted image suggests that the pixel values are spread roughly uniformly. Such high entropy demonstrates that the encryption process has been highly effective in randomizing pixel values and concealing the original image content.

Table 5 Entropy analysis.

Histogram analysis

The histograms of the original and encrypted images were compared to assess the effectiveness of the encryption in terms of pixel value distribution. The encrypted images exhibited uniform histograms, indicating that pixel values were effectively scrambled and that the encryption successfully masked the original image data. Figure 8 displays the histograms of the cipher cubes of the three experiments.

Time analysis

The efficiency of the designed scheme is directly reflected in the speed of the encryption process. To evaluate this, three image sets with dimensions of \(\:128\times\:128\), \(\:256\times\:256\), and \(\:512\times\:512\) were used. The average encryption times for these operations are presented in Table 6. The experiments were conducted on a system with an Intel Core i5-9300 H CPU (2.40 GHz, 4 cores, 8 threads) and Windows 11 OS. The average encryption time per image and channel demonstrates the method’s efficiency, with reasonable execution times across test cases. These results suggest that the proposed scheme is computationally feasible for practical applications; however, further optimization, such as parallel processing, could enhance its performance.

Table 6 Encryption time Analysis.
Fig. 8
figure 8

Histogram for (a, b,c), (g, h,i), (m, n,o) Experiment 1, Experiment 2, and Experiment 3 plain images respectively. (d, e,f), (j, k,l), (p, q,r) Experiment 1, Experiment 2, and Experiment 3 cipher images respectively.

Time complexity

The proposed MIE algorithm consists of four main stages: cropping, 3D stacking, block division, and block-wise encryption. The cropping and stacking steps are linear concerning the number of input images \(\:n\), resulting in a complexity of \(\:O\left(n\right)\). During encryption, each block of fixed size\(\:\:b\times\:b\times\:b\) undergoes permutation and substitution, with complexity \(\:O\left({b}^{3}\right)\) per block. Since the block size \(\:b\) is small and constant in practice, the overall time complexity becomes \(\:O(n\cdot\:{b}^{3})\), which effectively behaves as \(\:O\left(n\right)\). This demonstrates the method’s scalability and computational efficiency in real-world implementations.

Correlation analysis

An effective encryption technique should eliminate the correlation between diagonal, horizontal, and vertical pixels, ensuring that the pixel relationships in the plain images are completely obscured, thereby enhancing the security of the encrypted images and preventing statistical attacks. The correlation \(\:{r}_{i,j}\) of 10,000 randomly selected adjacent pixel pairs \(\:(i,j)\) from both the plain and cipher images was estimated using the following equations:

$$\:{r}_{i,j}=\frac{Co\left(\right(i-Co\left(i\right)\left(j-Co\left(j\right)\right))}{\sqrt{D\left(i\right)D\left(j\right)}}$$
(18)

Where:

$$\:Co\left(i\right)=\frac{1}{N}\sum\:_{n=1}^{N}{i}_{n},D\left(i\right)=\frac{1}{N}\sum\:_{n=1}^{N}{{(i}_{n}-Co\left(i\right))}^{2}$$
(19)

In Experiment 2, Figs. 9 and 10 present the distributions of pixels of the RGB channels of the color plain and corresponding cipher images along three orientations. Table 7 identifies the correlation coefficients of the RGB channels of the plain and corresponding cipher color images neighboring pixel values in three orientations. All the results of the cipher RGB channels are approaching 0, exhibiting reduced inter- and intra-channel correlation, and the pixels became highly dissimilar to each other.

Fig. 9
figure 9

Correlation for three plain channels in the three directions.

Fig. 10
figure 10

Correlation for three cipher channels in the three directions.

Table 7 Correlations values of the color image.

Differential attack analysis

Metrics include the Unified Average Changing Intensity (UACI) and the Number of Pixels Change Rate (NPCR), which are used to quantify the resistance to different attacks. These metrics measure the differences between two encrypted images obtained by slightly altering the original image. Consequently, even minor pixel alterations in the original image substantially impact the encrypted image31. The following are the definitions of UACI and NPCR:

$$\:\left\{\begin{array}{c}UACI=\frac{1}{w\times\:h}\times\:\sum\:_{x=0}^{w}\sum\:_{y=0}^{h}\frac{\left|{C}_{1}\left(x,y\right)-{C}_{2}\left(x,y\right)\right|}{255}\times\:\:100\text{\%}\\\:NPCR=\frac{1}{w\times\:h}\times\:\sum\:_{x=0}^{w}\sum\:_{y=0}^{h}D\left(x,y\right)\times\:\:100\text{\%}\end{array}\right.$$
(20)
$$\:where$$
$$\:D\left(x,y\right)=\left\{\begin{array}{c}0,\:{C}_{1}\left(x,y\right)={C}_{2}\left(x,y\right)\:\\\:1,\:{C}_{1}\left(x,y\right)\ne\:{C}_{2}\left(x,y\right)\:\end{array}\right.$$
(21)

Where \(\:{C}_{1},\:\text{a}\text{n}\text{d}\:{C}_{2\:}\), are two cipher images derived from a plain image with a single random pixel variation, while \(\:\left(w,h\right),\:\)denotes the number of rows and columns. Table 8 shows NPCR and UACI values. Suppose the resulting cubes from encrypting two virtually similar cubes show an NPCR close to 100% and a UACI larger than 33%32. In this case, the encryption method can be considered strong since a minor change in the algorithm’s input results in a drastically different output. The results indicate that our method exhibits resilience against differential attacks.

Table 8 NPCR and UACI values for the three experiments.

MSE and PSNR

For a cipher image to be deemed effective, it must show a substantial deviation from its plain form, ensuring that the encrypted image bears no resemblance to the plain image. The MSE measures the total squared difference between the original and cipher images using the following formula:

$$\:{r}_{i,j}=\frac{1}{W\times\:H}{\sum\:}_{i=0}^{W}{\sum\:}_{j=0}^{H}{(P\left(i,j\right)-E\left(i,j\right))}^{2}$$
(22)

where \(\:P\left(i,j\right)\) represents the pixel value of the plain image while \(\:E(i,j)\) denotes the corresponding encrypted pixel value at the position \(\:(i,j)\) in the cipher image. The MSE value serves as a criterion for assessing the encryption level of a cryptosystem, where the encryption security level increases with a larger MSE scale. PSNR analysis determines the quality level of encryption; a higher score indicates that the encrypted image closely resembles the original image. Therefore, a smaller PSNR value indicates stronger encryption for a cryptosystem. It can be described as follows:

$$\:PSNR=20\times\:{\text{log}}_{10}[255/\sqrt{MSE}]$$
(23)

The values of the MSE and PSNR reported in Table 9 highlight the difficulties of recovering the plain image content from the cipher image without knowing the secret decryption key.

Table 9 MSE and PSNR values for the three experiments.

Data loss and data noise

Images experience data loss during transmission or storage. In the case of a cipher cube, some data is lost, and the remaining information is recovered through the decryption process. The experiments partially destroy the cipher cube and then implement the decryption process to get the original images. Images are also affected by noise during transmission or storage, in addition to data loss. To simulate a noise attack, noise was added to the cipher cube at varying intensities of salt and pepper before decrypting the cube. After applying block data loss of 10% and 20%, and under salt-and-pepper noise with densities of 5% and 10%, the proposed algorithm maintained PSNR values ranging from 21.5 dB to 30.2 dB. Corresponding SSIM scores were 0.72 and 0.81, indicating acceptable visual quality and structural preservation despite noise corruption.

The results are displayed in Fig. 11. The results reveal that the most authentic features of the images have remained intact after decryption, suggesting that the proposed technique can resist these attacks.

Fig. 11
figure 11

Data Loss (a, c) Random block loss of more than 10% and 20% of the cipher image, respectively; (b, d) Corresponding decrypted images. Data Noise (e, g) Plain images; (f, h) Decrypted results after adding 5% and 10% salt-and-pepper noise to the encrypted images.

Grayscale images

Although this study focuses on color image encryption, the proposed method can also be used for a single grayscale channel. Some analyses are performed to evaluate the scheme for grayscale images. Figures 12 and 13 illustrate the encryption and decryption methodology for grayscale images, and Fig. 14 shows examples of plain grayscale medical images and their corresponding encrypted images.

Fig. 12
figure 12

Encryption Process of Grayscale image.

Fig. 13
figure 13

Decryption Process of Grayscale image.

Fig. 14
figure 14

(a, c) Examples of plain grayscale images and (b, d) their corresponding encrypted images.

Figures 15 and 16 show the histogram and correlation analysis results for a 256 × 256 image, demonstrating a uniform distribution. The histogram confirms that pixel intensity values are evenly spread, ensuring the encryption process effectively conceals patterns. Additionally, the reduced correlation between adjacent pixels highlights the proposed method’s strong diffusion and confusion properties, making it resistant to statistical attacks.

Fig. 15
figure 15

Histogram for 256 × 256 grayscale cipher image.

Fig. 16
figure 16

Correlation for 256 × 256 grayscale cipher image in (a) Horizontal direction, (b) Vertical direction, and (c) Diagonal direction.

Other analyses are shown in Table 10, where the entropy, NPCR, UACI, PSNR, MSE, and execution time demonstrate favorable values. The high entropy value indicates a high level of randomness in cipher images. In contrast, NPCR and UACI values confirm the method’s sensitivity to small changes in plaintext images, ensuring a strong avalanche effect. The PSNR and MSE values also highlight the significant difference between the original and cipher images, reinforcing the encryption strength. Moreover, the execution time further demonstrates the efficiency of the proposed approach, making it suitable for real-time applications.

Table 10 Performance analysis.

Discussion

This study presents a multiple medical image encryption scheme for both color and grayscale images. The proposed approach integrates a chaotic map, 3D transformation, and block segmentation to enhance security and efficiency. Chaotic maps ensure high sensitivity, 3D transformations strengthen confusions and diffusions, and block segmentation optimizes processing speed. Following the trends of hybrid encryption techniques, this scheme effectively balances security and computational performance. Notably, it achieves a 0.1-second encryption time for a 256 × 256-channels image, demonstrating its efficiency for real-time applications. The result highlights the potential of combining chaotic maps with 3D transformation for robust and fast encryptions. The proposed multiple medical image encryption scheme demonstrates superior performance across key security and efficiency metrics.

The algorithm was compared with several recent chaotic-based MIE techniques. Singh et al.33 encrypt multiple grayscale images by merging them into an RGB image and applying chaotic permutation and diffusion. The method proposed by Gao et al.34 combines three grayscale images into a single image and performs encryption on a single channel using a chaotic system. The algorithm by Zhang and Zhang35 encrypts multiple images using chaotic scrambling and gene fusion based on DNA operations. These algorithms were selected for comparison as they represent MIE approaches built entirely on chaotic principles.

Additionally, the scheme was evaluated against MIE algorithms that employ alternative strategies. Xu et al.36 introduced an approach that encrypts multiple medical images by scrambling the region of interest (ROI) and applying diffusion using odd-even interleaved points. It represents a domain-specific MIE method that focuses on protecting sensitive content. Xu37 proposed a multiple-image encryption algorithm based on orthogonal arrays with strength 3, incorporating chaotic operations to perform spatial permutation and substitution across images. Ye and Guo38 presented an MIE algorithm that embeds encrypted images into a carrier image using 3D-DCT and a 3D chaotic map, producing a visually meaningful encrypted result with combined encryption and hiding. These works were selected for comparison as they present recent MIE techniques with varied strategies.

Further comparison was made with hybrid techniques that integrate chaotic systems with classical cryptographic or transformation elements. Zhang and Liu23 introduced a stereo Zigzag transformation to expand 2D scrambling into 3D, combined with hash-based chaotic diffusion. Alexan et al.39 developed an MIE algorithm using SVD, modified RC5, and a hyperchaotic Hill cipher for satellite imagery. Xu et al.40 proposed an approach based on a novel chaotic system and odd-even interleaving strategy for encrypting medical images. These methods were chosen for comparison because they represent recent hybrid MIE approaches that target enhanced robustness and domain-specific performance.

As shown in Table 11, the proposed algorithm achieves faster execution times than most recent MIE methods. The encryption time of 0.1 s for a 256 × 256-channel image makes it more efficient than both chaotic-only and transform-based approaches.

Security analysis reveals that the scheme maintains high entropy, ensuring a uniform distribution of ciphertexts. It provides a large key space, making brute-force attacks infeasible. The encryption process effectively reduces pixel correlation, enhancing security against statistical attacks. Table 12 presents the different MIE experiment key space and entropy results obtained using our scheme and recent algorithms, as well as various experimental correlation results.

Table 11 Encryption time comparison.
Table 12 Key space, entropy, and correlation comparison.

Additionally, the scheme achieves high NPCR (~ 99%) and UACI (~ 33%), indicating strong sensitivity to small changes in plain data. Image quality metrics further validate the scheme’s effectiveness. A high MSE and low PSNR confirm strong encryption, ensuring encrypted images appear noise-like and unreadable. These improvements make the proposed approach well-suited for secure and efficient multiple medical image encryption. The values of UACI, NPCR, MSE, and PSNR for different algorithms are listed in Table 13.

Table 13 NPCR, UACI, MSE, PSNR analysis comparison.

The proposed encryption algorithm is based on chaotic systems and block-wise permutation–diffusion operations rather than number-theoretic or algebraic primitives. As a result, it is not directly susceptible to well-known quantum algorithms such as Shor’s algorithm, which targets RSA and ECC, or Grover’s algorithm, which speeds up key search in symmetric cryptosystems. Since the chaotic sequences used for scrambling and diffusion are dynamically generated per block and do not rely on fixed key scheduling or algebraic structure, the algorithm provides an inherent level of resistance to existing quantum attack models.

However, a formal quantum cryptanalysis of chaos-based image encryption schemes remains an open area of research. At present, there are no known quantum algorithms that can efficiently break such systems. Nevertheless, evaluating their security under quantum computing assumptions is essential in the context of post-quantum cryptography and will be addressed in future work.

Conclusion

A multiple-image encryption algorithm for medical images is proposed based on stack representation and block segmentation. In the preprocessing phase, multiple medical grayscale images are cropped into sub-images and stacked into a 3D cube to prepare for encryption. The cube then undergoes block segmentation, where each block is individually subjected to confusion and diffusion processes. These processes leverage keys generated from a Baker chaotic map, employing swapping and XOR operations to produce a fully encrypted cube. The proposed algorithm’s effectiveness is evaluated through comprehensive experiments, demonstrating its potential as a secure solution for encrypting medical grayscale images. By integrating image transformation, sub-image stacking, block segmentation, and the confusion and diffusion phases, the algorithm achieves high encryption strength and robustness against attacks. Performance analyses further reveal excellent encryption speed and strong security characteristics, making it a promising approach for medical image encryption.