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

 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('密文直方图');endfigure;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;endimgEncrypted1 = imgPlain;for i = 1 : encryptCount    imgEncrypted1 = encrypt(imgEncrypted1, Key);enddisp(strcat('------', testImgName, ',加密次数为:', num2str(encryptCount), ',明文敏感性分析------'));NPCR(imgEncrypted, imgEncrypted1, '明文改变1个像素值');UACI(imgEncrypted, imgEncrypted1, '明文改变1个像素值'); :, 2) = cG;    A(:, :, 3) = cB;else    A = crop_(img);endend

3 仿真结果

4 参考文献

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

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值