图像加密基于matlab GUI双随机相位编码光学图像加密解密含Matlab源码 1633期

Posted 紫极神光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了图像加密基于matlab GUI双随机相位编码光学图像加密解密含Matlab源码 1633期相关的知识,希望对你有一定的参考价值。

一、双相位编码单通道彩色图像加密简介(附lunwen)

1 前言
在国际上不断发展的新一代信息安全理论与技术的研究中,基于光学理论与方法的数据加密、隐藏和提取技术成为了一个重要的组成部分。近年来,国内外很多学者都开始从事这方面的研究,并提出了很多新方法,新技术.在这些研究中,大多是采用单色光照明,因此所恢复的图像将会失去彩色信息.
色彩是自然界的基本属性之一,图像的色彩信息在许多场合都是非常有用的,彩色图像信息的加密处理正受到越来越多的重视.在这类研究中,彩色图像通常被分成3个或多个通道,再采用和灰度图像相同的处理方法,解密时将各个通道组合起来,以恢复原来的彩色图像,这类方法常被称为多通道彩色图像处理.由于使用了多个通道,则相应的光学实现系统也就需要多个光源和多套光学元件,在增加了实验难度的同时,也增加了系统的成本,使此类方法的实用性受到限制.
本文提出一种基于双相位编码的单通道彩色图像加密方法.在该方法中, 图像首先被从RGB空间转换到HSI(色调、饱和度、强度) 空间, 再将其合并到一个通道中,采用双相位编码技术加密.其中,(强度)分量可作为双相位编码时的原始待加密图像,而编码时所用的密钥,可由H(色调)分量和S(饱和度) 分量获得.因为在HSI空间中, 色调与一个角度相对应,可以将其作为一个相位角来处理,该相位即可作为双相位编码中的相位密钥之一;而采用双随机相位加密技术对S分量加密后得到的相息图,可作为双相位编码的另一个密钥.由于仅使用一个通道对彩色图像加密,其相应的光学实现系统仅需一个光源和一套光学元件,不仅使实验难度降低,也减少了系统的成本.又因为采用双随机相位加密技术得到的S分量的相息图,在加密的过程中引进了随机相位因子,在不知密钥的情况下解密出S分量几乎不可能,从而保证了本方法的安全性.模拟实验结果证明了本文所提出方法的有效性。

2.色彩空间的转换
本文中,图像的彩色信息被转换成振幅和位相信息,以实现单通道加密.而彩色图像通常用红、绿、蓝三元组的二维矩阵来表示.为此,首先需将彩色图像用HSI表示.在RGB和HSI之间的变换公式有多种形式, 所有变换方法的基本思想都是一致的.一般而言,对

2.1 RGB 到HSI 的彩色模型转换

2.2 HSI 到RGB 的彩色模型转换

3.彩色图像的单通道加密
3.1.密钥 ——— S 分量的加密


3.2 基于双相位的单通道彩色图像加密




二、部分源代码

function varargout = main(varargin)
% MAIN MATLAB code for main.fig
%      MAIN, by itself, creates a new MAIN or raises the existing
%      singleton*.
%
%      H = MAIN returns the handle to a new MAIN or the handle to
%      the existing singleton*.
%
%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN.M with the given input arguments.
%
%      MAIN('Property','Value',...) creates a new MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to main_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help main

% Last Modified by GUIDE v2.5 08-Jun-2021 11:15:19

% Begin initialization code - DO NOT EDIT
gui_Singleton = 0;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @main_OpeningFcn, ...
                   'gui_OutputFcn',  @main_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin1)
    gui_State.gui_Callback = str2func(varargin1);
end

if nargout
    [varargout1:nargout] = gui_mainfcn(gui_State, varargin:);
else
    gui_mainfcn(gui_State, varargin:);
end
% End initialization code - DO NOT EDIT


% --- Executes just before main is made visible.
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to main (see VARARGIN)

% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
%设置状态标签
setappdata(handles.figure,'OriginalImFlag',false);
setappdata(handles.figure,'ArnoldImFlag',false);
setappdata(handles.figure,'EncryptionImFlag',false);
setappdata(handles.figure,'DecryptionImFlag',false);

setappdata(handles.figure,'makeRM1Flag',false);
setappdata(handles.figure,'makeRM2Flag',false);

setappdata(handles.figure,'KeyFlag',false);
setappdata(handles.figure,'ArnoldCountKeyFlag',false);
setappdata(handles.figure,'LogisticXKeyFlag',false);
setappdata(handles.figure,'LogisticUKeyFlag',false);
setappdata(handles.figure,'LogisticNKeyFlag',false);
setappdata(handles.figure,'ChenXKeyFlag',false);
setappdata(handles.figure,'ChenYKeyFlag',false);
setappdata(handles.figure,'ChenZKeyFlag',false);
setappdata(handles.figure,'ChenCKeyFlag',false);
setappdata(handles.figure,'ChenHKeyFlag',false);
setappdata(handles.figure,'ChenTKeyFlag',false);
setappdata(handles.figure,'ChenNKeyFlag',false);

%隐藏坐标轴
set(handles.axesOriginalIm,'Visible','off');
set(handles.axesArnoldIm,'Visible','off');
set(handles.axesEncryptionIm,'Visible','off');
set(handles.axesDecryptionIm,'Visible','off');
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure);


% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout1 = handles.output;


function File_Callback(hObject, eventdata, handles)


function FileOpenOriginal_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile( ...  
    '*.jpg;*.bmp;*.png;*.jpeg','Image Files ( *.jpg,*.bmp, *.png,*.jpeg)'; ...  
    '*.*','All Files (*.*)', ...  
    'Pick an image'); 
if isequal(filename,0) || isequal(pathname,0)
    return;  
end
fpath=[pathname filename];%将文件名和目录名组合成一个完整的路径  
global OriginalIm
OriginalIm=imread(fpath);
OriginalIm=im2double(OriginalIm);
if length(size(OriginalIm))==3
    OriginalIm=rgb2gray(OriginalIm);
end
axes(handles.axesOriginalIm); %用axes命令设定当前操作的坐标轴是axes_src
cla;%清空坐标图
imshow(OriginalIm);
title('原图');
h_fig=findall(0,'Type','figure','Tag','figure');
setappdata(h_fig,'makeRM1Flag',false);
setappdata(h_fig,'makeRM2Flag',false);
setappdata(h_fig,'OriginalImFlag',true);




function FileOpenKey_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile( ...  
    '*.csv;*.txt','Image Files ( *.csv,*.txt)'; ...  
    '*.*','All Files (*.*)', ...  
    'Pick an image'); 
if isequal(filename,0) || isequal(pathname,0)
    return;  
end
fpath=[pathname filename];%将文件名和目录名组合成一个完整的路径  
k=importdata(fpath);
key=k.data;
global ArnoldCount LogisticX LogisticU LogisticN ChenX ChenY ChenZ ChenC ChenH ChenT ChenN;
ArnoldCount=key(1);
LogisticX=key(2);
LogisticU=key(3);
LogisticN=key(4);
ChenX=key(5);
ChenY=key(6);
ChenZ=key(7);
ChenC=key(8);
ChenH=key(9);
ChenT=key(10);
ChenN=key(11);
set(handles.editArnoldCount,'string',num2str(ArnoldCount));
set(handles.editLogisticX,'string',num2str(LogisticX));
set(handles.editLogisticU,'string',num2str(LogisticU));
set(handles.editLogisticN,'string',num2str(LogisticN));
set(handles.editChenX,'string',num2str(ChenX));
set(handles.editChenY,'string',num2str(ChenY));
set(handles.editChenZ,'string',num2str(ChenZ));
set(handles.editChenC,'string',num2str(ChenC));
set(handles.editChenH,'string',num2str(ChenH));
set(handles.editChenT,'string',num2str(ChenT));
set(handles.editChenN,'string',num2str(ChenN));

h_fig=findall(0,'Type','figure','Tag','figure');
setappdata(h_fig,'makeRM1Flag',false);
setappdata(h_fig,'makeRM2Flag',false);
setappdata(handles.figure,'KeyFlag',true);




function FileOpenEncryption_Callback(hObject, eventdata, handles)
global EncryptionIm;
[filename, pathname] = uigetfile('encryption.mat','Pick an encryption file'); 
if isequal(filename,0) || isequal(pathname,0)
    return;  
end 
fpath=[pathname filename];%将文件名和目录名组合成一个完整的路径  
try
    load(fpath,'-mat');
catch
    msgbox('输入的源文件不能进行解密,请输入*.mat文件!','error');
    return;
end

axes(handles.axesEncryptionIm); %用axes命令设定当前操作的坐标轴是axes_src
cla;%清空坐标图
imshow(abs(EncryptionIm));
title('加密图');
h_fig=findall(0,'Type','figure','Tag','figure');
setappdata(h_fig,'makeRM1Flag',false);
setappdata(h_fig,'makeRM2Flag',false);
setappdata(h_fig,'ArnoldImFlag',true);
setappdata(h_fig,'EncryptionImFlag',true);

function FileSaveKey_Callback(hObject, eventdata, handles)
[filename, pathname] = uiputfile('key.csv','Save file name');
if isequal(filename,0) || isequal(pathname,0)  
    return;%如果点了“取消”  
else  
    fpath=fullfile(pathname, filename);%获得全路径的另一种方法  
end  
global ArnoldCount LogisticX LogisticU LogisticN ChenX ChenY ChenZ ChenC ChenH ChenT ChenN;
T=table(ArnoldCount,LogisticX,LogisticU,LogisticN,ChenX,ChenY,ChenZ,ChenC,ChenH,ChenT,ChenN);
writetable(T,fpath,'WriteRowNames',true,'Delimiter',',');

function FileSaveEncryption_Callback(hObject, eventdata, handles)
[filename, pathname] =   uiputfile('EncryptionIm.mat','Save file name');
if isequal(filename,0) || isequal(pathname,0)  
    return;%如果点了“取消”  
else  
    fpath=fullfile(pathname, filename);%获得全路径的另一种方法  
end  
global EncryptionIm;
save(fpath,'EncryptionIm');
% imwrite(abs(EncryptionIm),fpath);%保存图片  

function FileSaveDecryption_Callback(hObject, eventdata, handles)
[filename, pathname] =   uiputfile('original.jpg','Save file name');
if isequal(filename,0) || isequal(pathname,0)  
    return;%如果点了“取消”  
else  
    fpath=fullfile(pathname, filename);%获得全路径的另一种方法  
end  

三、运行结果







四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]杨晓苹,高丽娟,王晓雷,翟宏琛,王明伟.基于双相位编码的单通道彩色图像加密[J].物理学报. 2009,58(03)

以上是关于图像加密基于matlab GUI双随机相位编码光学图像加密解密含Matlab源码 1633期的主要内容,如果未能解决你的问题,请参考以下文章

光学基于matlab GUI菲涅尔系数计算含Matlab源码 1165期

图像加密解密基于matlab GUI混沌序列图像加密解密(含相关性检验)含Matlab源码 1862期

图像加密基于matlab混沌系统和DNA编码彩色图像加密解密抗噪声性能分析含Matlab源码 2414期

matlab设计GUI

图像加密基于matlab GUI混沌系统图像加密解密含Matlab源码 1240期

图像加密基于matlab GUI彩色图像加密解密含Matlab源码 1231期