function [dPSNR,outImg]=arnold(inImg,iTimes);
%% -------------------------------------------------------------------- %%
% Function: Arnold图像置乱
% Arnold: x'=(x+y) mod N, y'=(x+2y) mod N
% 变换周期(N,M): (128,96),(256,192),(512,384)
% Argument: dPSNR: 置乱后PSNR
% outImg: 置乱后输出图像
% inImg: 输入图像
% iTimes: 置乱次数
% Version: 1.01.20070409
% Email: afoe@tom.com
% Copyright Wei weimin, http://foe.bokee.com
%% -------------------------------------------------------------------- %%
start_time=cputime; % save start time
if nargin ~= 2 % 设置默认值
[filename, pathname] = uigetfile('*.jpg;*.bmp', 'Pick an image file');
if isequal(filename,0) || isequal(pathname,0) % User pressed cancel
dPSNR=0;outImg=[];
return;
end
fn=[pathname filename];
inImg = imread(fn);
iTimes = input('Please input Arnold scramble times[1]:');
if isempty(iTimes)
iTimes=1;
end
end
[iH iW iL]=size(inImg);
if iH ~= iW % 必须是正方形
error('The cover must be a square !');
return;
end
outImg=uint8(zeros(iH,iW));
tempImg=inImg;
h = waitbar(0,'Arnold transform, Please wait...');
for i=1:iTimes % 调用次数
for l=1:iL % 图层
for u=1:iH
for v=1:iW
temp=tempImg(u,v,l);
ax=mod((u-1)+(v-1),iW)+1;
ay=mod((u-1)+2*(v-1),iW)+1;
% ax=mod((u-1)+(v-1),iW)+1; Fibonacci变换置乱
% ay=mod((u-1),iW)+1;
outImg(ax,ay,l)=temp;
end
end
end
tempImg=outImg;
waitbar(i/iTimes,h);
end
close(h);
h = waitbar(0,'Copyright http://foe.bokee.com');
%ElapsedTime=cputime-start_time
%dPSNR = psnr(inImg,outImg);
dPSNR=0;
subplot(1,2,1);imshow(inImg);
title('Original Image');
subplot(1,2,2);imshow(outImg);
title(['Arnold times=',num2str(iTimes)]);
%title(['Arnold times=',num2str(iTimes),',PSNR=',num2str(dPSNR)]);
%% -------------------------------------------------------------------- %%
Arnold_Matlab_code.rar_ARNOLD PSNR_Arnold 置乱_Arnold图像置乱_Arnold置乱
版权申诉
60 浏览量
2022-07-14
00:38:01
上传
评论
收藏 1KB RAR 举报
我虽横行却不霸道
- 粉丝: 72
- 资源: 1万+
最新资源
- 2022年各城市PM2.5, PM10, SO2, NO2等环境空气质量数据
- Golang:通过Gin框架+Redis+责任链,实现一个简单的钉钉机器人,进行消息处理 ps:多应用版
- 2021年各城市PM2.5, PM10, SO2, NO2等环境空气质量数据
- CORRUPT.navicat150-premium-cs-x64.exe
- centos7 ssh 升级至 9.6p1
- DriverMax Pro .exe
- PHP端通过modbus协议跟第三方设备进行数据通信
- navicat安装包亲测可用
- 算法部署-使用OpenVINO部署MobileStyleGAN轻量化高保真图像合成算法-项目源码-优质项目实战.zip
- 基于java实现远程采集华为逆变器使用modbus tcp协议进行通讯的设备数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0