-
2006年,CANDES和DONOHO等人首次提出压缩感知理论,压缩感知在数据采样的同时完成数据压缩。在信号采样的过程中,用少量的采样点实现了和全采样一样的结果,突破了Nyquist采样定理的限制。压缩感知理论表示,压缩信号或图像可以通过一个小的非自适应线性测量矩阵把一个高维的信号成功地映射到低维空间当中,要想完美重构出原始信号只需要从这部分少量的投影中求解一个最优化问题即可[19]。
对于数据量大的图像信号,运用压缩感知理论时,不需要先对其进行高密度采样再做压缩处理,只需要通过简单测量便能同时完成采集和压缩。然而实践中发现,当接收端通过少量观测值重构图像时,对整幅图直接进行CS重构的运算量十分大。因而,GAN提出的BCS方法能很好的解决这一问题。
对大小为h×g的一幅图像进行分块,假设想要进行n个CS测量。在BCS中,图像被分成大小为ng×ng的小块,扫描每个图像块的像点,得到含Ng=ng×ng个元素的向量。记xi=[xi1, xi2, …, xiNg]T为第i个图像块的数据,对每个图像块的数据进行观测,采用相同的观测矩阵Φg,得到Mg个观测值[20]。xi表示第i个块的矢量化信号,相应的输出压缩向量yi可写为:
$ \boldsymbol{y}_{i}=\boldsymbol{\varPhi}_{g} \boldsymbol{x}_{i} $
(1) 式中,Φg是Mg×Ng的观测矩阵,yi为列向量,其长度为Mg,Mg≪Ng。观测每个图像块,共得到M=Mh(h×g)/Ng个观测值。
当接收端接收到某个图像块观测值后,选用相同的重构算法,对每个图像块进行重构,即可获得整幅图像。本文中采用的是运算量比较小的正交匹配追踪方法。
-
幻方的定义:以1,2,…,n2个自然数为元素组成的n阶矩阵:
$ \mathit{\boldsymbol{A}}=\left[\begin{array}{cccc}{a_{11}} & {a_{12}} & {\cdots} & {a_{1 n}} \\ {a_{21}} & {a_{22}} & {\cdots} & {a_{2 n}} \\ {\cdots} & {\cdots} & {\cdots} & {\cdots} \\ {a_{n 1}} & {a_{n 2}} & {\cdots} & {a_{n n}}\end{array}\right] $
(2) 若矩阵A的元素值满足条件:
$ \begin{array}{c}{\sum\limits_{i=1}^{n} a_{i j}=\sum\limits_{j=1}^{n} a_{i j}=\sum\limits_{i=1}^{n} a_{i i}=} \\ {\sum\limits_{i+j=n+1}^{n} a_{i i}=\frac{n\left(n^{2}+1\right)}{2}}\end{array} $
(3) 式中,i, j=1,2,…, n, 称A为n阶幻方[10]。
对数字图像采用传统的幻方变换进行加密,按行列顺序将图像矩阵P像素值与幻方矩阵A元素值依次对应。根据(4)式将矩阵A中元素aij移位至元素aijmod(n2)+1处,变换后的矩阵记为A1,再将矩阵P的像素位置根据矩阵A1元素所在位置做相应位移,迭代变换多次后获得变换图像。
$ \begin{array}{c}{T_{L}\left(a_{i j}+L\right) \bmod \left(n^{2}\right)=} \\ {\left\{\begin{array}{l}{\left(a_{i j}+L\right) \bmod \left(n^{2}\right), \left(\left(a_{i j}+L\right) \bmod \left(n^{2}\right) \neq 0\right)} \\ {n^{2}, \left(\left(a_{i j}+L\right) \bmod \left(n^{2}\right)=0\right)}\end{array}\right.}\end{array} $
(4) 当L=n2时,Tn2(aij)=(aij+n2)mod(n2)=aijmod(n2)=aij。
由此可见,传统幻方变换的周期为T=n2。经过n2次迭代变换,每个像素便回到变换前的位置,因此传统的幻方加密虽然置乱效果显著,但安全性很低,很容易遭攻击。因此,本文中提出了改进的幻方变换方法。
-
改进的幻方变换有效地解决了传统幻方变换周期性的问题。由于logistic混沌序列具有非周期性,因此矩阵A′的坐标值具有随机性。原幻方矩阵A中的元素随机移动到矩阵A′其它位置处,经过n2次迭代变换,每个像素不会回到变换前的位置,打破了传统幻方置乱的周期性。以4阶改进的幻方变换为例,其置换矩阵图如图 1所示。
具体的实现步骤如下:
(1) 生成一个n×n大小的幻方矩阵A,幻方矩阵元素值ai, j, 且i, j=1, 2, …, n。
(2) x1(i),x2(i)是logistic混沌系统[21]xk+1=uxk(1-xk)迭代后的状态值,对其进行放大取整处理:
$ \left\{\begin{array}{l}{X_{1}(i)=\text { floor }\left(\left(x_{1}(i) \cdot S\right) \bmod \left(n^{2}\right)\right)} \\ {X_{2}(i)=\text { floor }\left(\left(x_{2}(i) \cdot S\right) \bmod \left(n^{2}\right)\right)}\end{array}\right. $
(5) 得到两组混沌序列X1(i), X2(i),作为幻方变换移位参量。S表示原始矩阵元素值的和,floor(x)表示将x中元素取整,其值为不大于本身的最小整数。x1(i), x2(i)是初值不同的logistic混沌系统迭代后的状态值。
(3) 求得原幻方矩阵A中元素aij的坐标值(i, j),aij=1, 2, …, n2,令A′=A。将A′和A按行列一一对应,将元素aij移动到元素A(X1(i), X2(i))′,得到置乱后的幻方矩阵A″。
-
在MATLAB R2010b平台上进行数值仿真,选用4幅大小为256×256的灰度图像“Barbara”, “Lena”,“fruits”, “peppers”作为原始图像,如图 4a~图 4d所示。根据原始图像的大小选择合适的随机测量矩阵,分别将4张原始图像通过压缩感知进行分块加密,再将压缩后的4张加密图融合为一张图。其中,随机测量矩阵用来作为密钥1。然后再进行改进后的幻方变换,得到二次加密后的加密图像如图 4i所示,其中混沌参量值x0,u为重要的解密密钥。为了保证实验的普遍性,对多组图像进行了测试,其中图 4e~图 4h中4幅256×256的灰度图像“candy”, “milk”,“flower”, “Tiffany”的解密图如图 5e~图 5h所示,解密过程是加密过程的逆过程,解密图像如图 5所示。
解密结果中,可以清晰地看到重建的原始图像。通常,相关系数(correlation coefficient,CC)CCC和峰值信噪比(peak signal-to-noise ratio,PSNR)RPSNR被用来评估解密图像的质量。相关计算公式表示为:
$ \left\{ \begin{array}{l} C_{\mathrm{cc}}=\frac{E\{[\boldsymbol{f}-E(\boldsymbol{f})][\boldsymbol{F}-E(\boldsymbol{F})]\}}{\sqrt{\boldsymbol{E}\left\{[\boldsymbol{f}-E(\boldsymbol{f})]^{2}\right\} E\left\{[\boldsymbol{F}-E(\boldsymbol{F})]^{2}\right\}}} \\ R_{\mathrm{PSNR}}=10 \lg \left(\frac{255^{2}}{\sigma}\right) \end{array} \right. $
(6) 式中,σ表示原图像与解密图像之间的均方误差,E代表期望值,f和F分别代表原始图像和解密图像。采样样本大小与原始样本大小的比率定义为压缩比r=[(N-M)/N]×100%。当设置M=96,压缩比为62.5%时,通过正确的密钥解密出的图像的CC值记录在表 1中。由表 1中的数据可以看出,所有重建图像的CC值都高于0.99,PSNR值都大于35dB,这意味着每个解密图像的质量都非常高。
Table 1. CC and PSNR values of four decrypted images and original images
decryption image CCC decryption image RPSNR/dB Barbara 0.9965 Barbara 35.2095 Lena 0.9964 Lena 35.9673 fruits 0.9980 fruits 37.7877 peppers 0.9985 peppers 40.7638 -
分别对4幅大小为256×256的灰度图像做分块压缩感知,分块尺寸为128×128, 64×64。当每幅图像的块观测值数目为图像块像素个数的0.75倍时,对图像进行128×128分块处理时,加密系统所需时间为0.98s,对图像进行64×64分块处理时,加密系统所需时间为0.44s。实验结果显示,随着分块尺寸的变小,加密系统所需时间减少,能很快地处理图像,但同时发现,随着块尺寸的无限缩小,图像质量逐步变差,因此不能无限小的分块。当图像分块大小分别为128×128, 64×64时,由表 2中解密图像的CC值可以看出,解密图像质量良好,所以本文中提出的加密系统选用128×128大小的图像块进行分块压缩处理,图 6a~图 6d为分块尺寸为64×64时“candy”, “milk”,“flower”, “Tiffany”的解密图。
Table 2. CC values of decrypted images and original images with block size of 128×128, 64×64
image(128×128) CCC image(64×64) CCC candy 0.9993 candy 0.9940 milk 0.9977 milk 0.9948 flower 0.9973 flower 0.9930 Tiffany 0.9950 Tiffany 0.9902 -
在图像传输和处理的过程中,密文很容易受到噪声的攻击,降低解密图像的质量甚至会使解密图像无法识别出原始信息。因此在设计一个好的加密系统时,需要考虑系统抗噪声攻击的能力。为了测试系统的抗噪声攻击能力,按照以下形式给加密图像增加乘性噪声:
$ \boldsymbol{F}^{\prime}=\boldsymbol{F} \times(1+k \times G) $
(7) 式中,F和F′分别是原加密图像和受噪声影响后的加密图像,k表示噪声的强度系数,G是噪声类型。
图 7中给出了加密图像在各种噪声情况下重构的解密图像。当加密图像加入了强度为0.1的随机噪声时,原始图像和解密图像的PSNR分别为21.1092dB, 20.9332dB, 23.7608dB, 22.7085dB,对应的CC值分别为0.9612, 0.9531, 0.9795和0.9637;当加密图像加入了均值为0、方差为0.1的高斯白噪声时,原始图像和重构的解密图像间的PSNR分别为30.3852dB, 30.6284dB, 32.8713dB, 32.7124dB,CC值分别为0.9895, 0.9877, 0.9942和0.9908。此时的噪声强度对重构的解密图像影响不大,图像很容易被重构,由此看出作者提出的算法具有良好的抗噪能力。
-
灰度直方图是判断一个图像的统计特性的指标,一种理想的加密算法,应该破坏原始图像的统计特性,使不同的原始图像具有均匀的统计分布或者类似的与原始图像无关的灰度直方图。
图 8中给出了4幅原图的灰度直方图。其中横坐标表示灰度值(灰度级别),纵坐标表示具有各个灰度值或者灰度级别的像素在图像中出现的次数或者概率, 横纵坐标均无量纲。图 8a~图 8d最终为原图灰度直方图, 图 8e为加密后密文的灰度直方图(直方图横坐标表示灰度级,纵坐标表示图像中该灰度级出现的频率,均无量纲)。从测试结果可以看出, 4幅原始图像的灰度直方图完全不同,它们加密图像的灰度直方图与任意一幅图的灰度直方图都不相同,成均匀分布。为了保证实验的普遍性,对多组图像进行了测试,所得到的加密图像都具有相似的分布特征。可以看出,改进后的加密系统仍具有好的统计特性,从加密图像的灰度直方图,攻击者很难获得原始信息。
-
在本次设计的加密算法中,密钥参量分别是测量矩阵R,logistic的系统参量u和初值x0。当初始值为x0+dx(dx的范围是-0.5×10-15~0.5×10-15)时,给出了4幅图像的相关增长量dx的CC值曲线(横坐标为dx的取值范围,纵坐标为CC值的大小,增量dx和CC值均为无量纲化的)。图 9分别是图像“Barbara”,“Lena”,“fruits”,“peppers”每个偏差所对应的CC值曲线。图 10a~图 10d分别是正确密钥时所对应的解密图。图 11a~图 11d分别是错误密钥x0′所对应的解密图。可见密钥正确时,解密图像与原始图像完全一致,而密钥有微小偏差时,图像将完全不能解密。表明了本算法对密钥具有良好的敏感性。
基于分块压缩感知和改进幻方变换的图像加密
Image encryption based on block compression sensing and the improved magic square transformation
-
摘要: 为了提高多图像加密的安全性,同时解决多图像加密系统数据量大的问题,采用了基于分块压缩感知和改进幻方变换的加密方法。加密过程中,充分利用了混沌序列对初始值的敏感性,解决基于传统幻方变换的加密算法周期性的问题;结合分块压缩感知的方法,减少加密系统的数据量。对4幅256×256的灰度图像进行加密测试。结果表明,系统加密时间只需要0.98s,重建图像的质量高,相关系数值均高于0.99,峰值信噪比值均大于35dB; 该算法在减少加密系统的数据量的同时进一步提高了系统的安全性。该算法实现容易,能高效安全地完成多图像加密。Abstract: In order to improve the security of multi-image encryption and solve the problem of large amount of data in multi-image encryption system, the encryption method based on block compressed sensing and improved magic square transform was adopted. During the encryption process, the sensitivity of chaotic sequence to initial value was fully utilized and the periodicity of encryption algorithm based on traditional magic square transformation was solved. Combining the block compression sensing method, the amount of data in the encryption system was reduced. Four 256×256 gray-scale images were encrypted and tested. The results show that the encryption time of the system is only 0.98s. The quality of the reconstructed image is high. The correlation coefficients were higher than 0.99. Peak signal-to-noise ratio (PSNR) values are greater than 35dB. This algorithm reduces the amount of data in the encryption system and further improves the security of the system. The algorithm is easy to implement and can complete multi-image encryption efficiently and safely.
-
Table 1. CC and PSNR values of four decrypted images and original images
decryption image CCC decryption image RPSNR/dB Barbara 0.9965 Barbara 35.2095 Lena 0.9964 Lena 35.9673 fruits 0.9980 fruits 37.7877 peppers 0.9985 peppers 40.7638 Table 2. CC values of decrypted images and original images with block size of 128×128, 64×64
image(128×128) CCC image(64×64) CCC candy 0.9993 candy 0.9940 milk 0.9977 milk 0.9948 flower 0.9973 flower 0.9930 Tiffany 0.9950 Tiffany 0.9902 -
[1] WU J J, XIE Zh W, LIU Zh G, et al. Multiple-image encryption based on computational ghost imaging[J]. Optics Communications, 2016, 359:38-43. doi: 10.1016/j.optcom.2015.09.039 [2] LI W N, PHAN A H, PIAO M L, et al. Multiple-image encryption based on triple interferences for flexibly decrypting high-quality images[J]. Applied Optics, 2015, 54(11):3273. doi: 10.1364/AO.54.003273 [3] CHANG H T, SHUI J W, LIN K P. Image multiplexing and encryption using the nonnegative matrix factorization method adopting digital holography[J]. Applied Optics, 2017, 56(4):958. doi: 10.1364/AO.56.000958 [4] KONG D Zh, SHEN X J. Multiple-image encryption based on optical wavelet transform and multichannel fractional Fourier transform[J]. Optics & Laser Technology, 2014, 57: 343-349. [5] SHAN M, CHANG J, ZHONG Z, et al. Double image encryption based on discrete multiple-parameter fractional Fourier transform and chaotic maps[J]. Optics Communications, 2012, 285(21/22): 4227-4234. [6] SITU G H, ZHANG J J. Multiple-image encryption by wavelength multiplexing[J]. Optics Letters, 2005, 30 (11) :1306-1308. doi: 10.1364/OL.30.001306 [7] LIU Zh J, ZHANG Y, ZHAO H F, et al. Optical multi-image encryption based on frequency shift[J]. Optik—International Journal for Light and Electron Optics, 2011, 122(11):1010-1013. doi: 10.1016/j.ijleo.2010.06.039 [8] SHI Y S, SITU G H, ZHANG J J. Multiple-image hiding in the Fresnel domain[J]. Optics Letters, 2007, 32(13) :1914-1916. doi: 10.1364/OL.32.001914 [9] ZHONG W B, DENG Y H, FANG K T. Image encryption by using magic squares[C]//2016 9th International Congress on Image and Signal Processing, BioMedical Engineering and Informatics (CISP-BMEI). New York, USA: IEEE, 2017: 771-775. [10] WANG D M, JIN Y Q. Semi-period of doubly even order magic square transformed digital images[J]. Journal of Zhejiang University, 2005, 32(3):273-276(in Chinese). [11] LIN Y, LIN J B. Study and application of magic square group in process of image scrambling[J]. Computer Technology & Development, 2012, 22(9):119-122(in Chinese). [12] LI T Y. An image encryption algorithm based on chaotic sequences and magic square transformation[J]. Network Security Technology & Application, 2006(5):90-92(in Chinese). [13] CHEN Q, LIAO X, CHEN Y. Modified image encryption based on chaotic sequences and rubik cube transformation[J]. Computer Engineering & Applications, 2005, 41(22):138-139(in Chinese). [14] WANG D M, HUANG L, WANG J R. Encrypting digital holograph with magic transformation[J]. Journal of Zhejiang University of Technology, 2007, 35(1):116-118(in Chinese). [15] LUO Q, WEI Q, MIAO X J. Blocked image compression and reconstruction algorithm based on compressed sensing[J]. Scientia Sinica Informationis, 2014, 44(8) :1036-1047 (in Chinese). [16] GAN L. Block compressed sensing of natural images[C] //2007 15th International Conference on Digital Signal Processing. New York, USA: IEEE, 2007: 403-406. [17] ZHOU N, YANG J, TAN C, et al. Double-image encryption scheme combining DWT-based compressive sensing with discrete fractional random transform[J]. Optics Communications, 2015, 354:112-121. doi: 10.1016/j.optcom.2015.05.043 [18] RAWAT N, KIM B, KUMAR R. Fast digital image encryption based on compressive sensing using structurally random matrices and Arnold transform technique[J]. Optik—International Journal for Light and Electron Optics, 2016, 127(4):2282-2286. doi: 10.1016/j.ijleo.2015.11.064 [19] LIU X Y, CAO Y P, LU P, et al. Optical image encryption technique based on compressed sensing and arnold transformation[J]. Optik—International Journal for Light and Electron Optics, 2013, 124(24):6590-6593. doi: 10.1016/j.ijleo.2013.05.092 [20] LI Y H. Improved model of image block compressed sensing[J]. Computer Engineering & Applications, 2011, 47(25):186-189(in Chinese). [21] QIAO J P, DENG L W, HE J, et al. Optimization of fast image encryption algorithm based on chaotic mapping[J]. Laser Technology, 2017, 41(6):897-903(in Chinese).