1 简介

传统的Arnold变换能改变图像象素的位置,而不能改变图像象素值,不能仅仅靠Arnold变换来实现图像加密.本文结合Logistic映射的伪随机性与对初值的敏感性,提出一种新的基于Arnold变换的图像加密算法,改进后的算法不仅改变了图像象素的位置,也改变了图像象素值.matlab仿真实验表明了该算法的有效性与安全性.

2 部分代码

function jiami
% NOTE:请修改 testImgName,来测试不同输入图像,支持灰度图和 RGB 图
% testImgName = 'lena';
% testImgName = 'lena_color';
% testImgName = 'color0';
% testImgName = 'lena16x16';
% testImgName = 'gray32x32';
% testImgName = 'gray2';
testImgName = 'pepper_gray';
% testImgName = '1Pixel';
img = imread(strcat(testImgName, '.png'));
[w h rgb] = size(img);
% chaos映射预迭代次数,Logistic映射初始值x0,mu,Arnold置乱次数
Key = [128, 0.7532, 3.8793, 2];
%
disp('###############################');
% 信息熵计算
% 统计输出
figure;
if rgb == 3
% 彩色图像
subplot(4, 2, 1);
imshow(uint8(img));
title('明文');
subplot(4, 2, 2);
imshow(imgEncrypted);
title('密文');
imgR = img(:, :, 1);
imgG = img(:, :, 2);
imgB = img(:, :, 3);
subplot(4, 2, 3);
imhist(uint8(imgR));
title('明文R分量直方图');
subplot(4, 2, 5);
imhist(uint8(imgG));
title('明文G分量直方图');
subplot(4, 2, 7);
imhist(uint8(imgB));
title('明文B分量直方图');
imgEncryptedR = imgEncrypted(:, :, 1);
imgEncryptedG = imgEncrypted(:, :, 2);
imgEncryptedB = imgEncrypted(:, :, 3);
subplot(4, 2, 4);
imhist(imgEncryptedR);
title('密文R分量直方图');
subplot(4, 2, 6);
imhist(imgEncryptedG);
title('密文G分量直方图');
subplot(4, 2, 8);
imhist(imgEncryptedB);
title('密文B分量直方图');
else
% 灰度图像
subplot(2, 2, 1);
imshow(uint8(img));
title('明文');
subplot(2, 2, 2);
imshow(uint8(imgEncrypted));
title('密文');
subplot(2, 2, 3);
imhist(uint8(img));
title('明文直方图');
subplot(2, 2, 4);
imhist(uint8(imgEncrypted));
title('密文直方图');
end
figure;
subplot(3, 3, 1);imshow(imgEncrypted);title('加密后图像');
subplot(3, 3, 2);imshow(imgEncrypted_Noise_Salt);title(strcat('(1)椒盐噪声ρ=', num2str(delta)));
subplot(3, 3, 3);imshow(imgDecrypted_Noise_Salt);title('(1)解密图像');
subplot(3, 3, 5);imshow(imgEncrypted_Noise_Gaussian);title(strcat('(2)高斯噪声μ=0,σ=', num2str(delta)));
subplot(3, 3, 6);imshow(imgDecrypted_Noise_Gaussian);title('(2)解密图像');
subplot(3, 3, 8);imshow(imgEncrypted_Croped);title('(3)1/16剪切');
subplot(3, 3, 9);imshow(imgDecrypted_Croped);title('(3)解密图像');
% 明文敏感性
imgPlain = img;
if rgb == 3
% 彩色图像
gray = imgPlain(w, h, 1);
% bin = dec2bin(gray);
gray = bitxor(gray, 1);
imgPlain(w, h, 1) = gray;
else
% 灰度图像
gray = imgPlain(w, h);
% bin = dec2bin(gray);
gray = bitxor(gray, 1);
imgPlain(w, h) = gray;
end
imgEncrypted1 = imgPlain;
for i = 1 : encryptCount
imgEncrypted1 = encrypt(imgEncrypted1, Key);
end
disp(strcat('------', testImgName, ',加密次数为:', num2str(encryptCount), ',明文敏感性分析------'));
NPCR(imgEncrypted, imgEncrypted1, '明文改变1个像素值');
UACI(imgEncrypted, imgEncrypted1, '明文改变1个像素值');
:, 2) = cG;
A(:, :, 3) = cB;
else
A = crop_(img);
end
end

3 仿真结果

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_直方图

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_02

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_03

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_直方图_04

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_加密算法_05

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_06

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_07

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_08

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_直方图_09

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_10

4 参考文献

[1]杨恒伏, 伍雁鹏, 田祖伟. 基于Logistic混沌映射与Arnold变换的图像加密算法[J]. 衡水学院学报, 2008, 10(4):4.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_加密算法_11

【图像加密】基于Logistic混沌结合Arnold置乱实现图像加密含Matlab源码_彩色图像_12