GUI Orthogonal Latin Square+2-D Arnold Scrambled Image Encryption

Keywords: MATLAB image processing Encryption

GUI Orthogonal Latin Square+2-D Arnold Scrambled Image Encryption

1. Introduction

1 Purpose of digital image scrambling

Up to now, more mature information hiding algorithms are basically based on images as carriers. Image scrambling, as the name implies, is to scramble the image to hide the real content of the original image. Digital image scrambling and information file encryption are similar in thought, it is mainly to "scramble" by transforming the pixel position of the digital image.An image can become completely unrecognized and cluttered, thus hiding the true information that the image is intended to convey. Image scrambling can achieve two purposes:

1.1 Encryption Processing
Image scrambling transformation is a content-based image encryption method. Just like decrypting encrypted information without knowing the key, it is also difficult to recover the information of the original image without knowing the algorithm used for image scrambling.

1.2 Enhance robustness of image camouflage(Robustness: Digital watermarks retain partial integrity and can be accurately identified after a variety of unintentional or intentional signal processing processes. Possible signal processing processes include channel noise, filtering, digital/analog to analog/digital conversion, resampling, shearing, shifting, scale changes, and lossy compression encoding. Digital watermarks are mainly used for copyright protection.(Fragile Watermarking), which is mainly used for integrity protection, embeds invisible information in the content data as well. When the content changes, these watermarks change accordingly to identify whether the original data has been tampered with.)

As a preprocessing method for information hiding, scrambling technology can greatly enhance the robustness of image information disguising.
1. After the image is shuffled, you will get a disordered image with no content, no texture, and no shape from which meaningful information can not be read.
When we embed such an image into another normal image, it is not easy to cause the content, texture and shape of this image to change too much or even not to be aware of the change. This makes it not easy for the human eye to recognize, thus avoiding the third party's view and better ensuring the concealment of the watermark information.
(2) Since a secret image is a post-shuffling image, it is difficult for third parties to make statistical analysis of its content, texture, shape, etc. so that even if they intercept a secret image, they will not be able to do so. This is also very difficult if third parties attempt to reverse the shuffling operation on the secret image, because there are many methods for image shuffling, and each method can be used differently.The scrambling algorithm and the setting of different parameters make it possible for the encryptor to get many different results according to his own ideas, which makes it difficult for the third party to attempt to reverse the scrambling and requires a large amount of computational effort to exhaustively test the possibilities.
(3) If the third party fails to perform the anti-scrambling operation, it may also make malicious modifications on the concealed carrier, and the purpose of resisting these attacks can also be achieved by using the scrambling method, because when the legitimate recipient inverts the secret image, it will spread the information painted by the third party on the image to all locations of the picture, forming point-like random noise and visual shadows.The loudness is not very loud.

Fig.1 is a secret image recovered from two malicious modifications, alteration and cropping, on a scrambled image. You can see that the contents of the secret image are still visible. In order to make the extracted image information clearer, median filtering can also be applied to the damaged image to remove random noise.
Of course, it should not be ignored that image scrambling increases the complexity and computational load of encryption computation to a certain extent, but it is still a cost-effective and relatively safe means compared with the more computational load that illegal attackers may spend. That is why image scrambling plays an important role and significance in digital watermarking technology.

2 Methods of digital image scrambling
With the development of computer technology and digital image processing technology, many literatures have proposed different image scrambling algorithms, which can be divided into linear transformation, geometric transformation and affine transformation in general. Currently, more research on the scrambling technology includes Fibonacci transformation, Arnold transformation, Hilbert transformation.Curve transformation, E-Curve transformation, Gray transformation, affine transformation, magic square, orthogonal Latin square transformation and so on. Either scrambling technique is reversible or periodic, that is, multiple iterations or inverse transformation can restore the original image.
The following is only an example of Arnold transformation to discuss digital image scrambling.

2.1 Arnold transformation
Arnold transformation is a kind of transformation proposed by V.J.Arnold in the study of traversal theory, originally catmapping, commonly known as cat face transformation. Arnold transformation is intuitive, simple, periodic and very convenient to use. The principle of Arnold transformation is to make a mis-tangent transformation in x-axis direction, then a mis-tangent transformation in y-axis direction. The final modular operation is equivalent to a cut-back filling operation, and its transformation diagramAs shown in Figure 4.

The scrambling effect of the Arnold transformation is shown in Figure 5.



3 Assessment of image scrambling effect

Generally, the evaluation of image scrambling should mainly consider the following aspects: 1) the distance of pixel movement; 2) the uniformity of pixel dispersion; 3) the difference between the original image; 4) the visual perception effect of the image.
Generally speaking, the more "messy" a secret image is after shufflingThe better the concealment, the higher the security. From the concept of scrambling transformation, the essence of location space scrambling is to move the position of each pixel in the original image. Visually, the farther the pixel moves, the more scrambled it will be. On the other hand, after the pixel position is moved, the uniformity of pixel dispersion should also be considered.A problem. If the local pixels of the image move parallel in the same direction, it will not scramble well even if the translation distance is large.
Generally speaking, the pixels that were originally clustered together disperse more evenly after scrambling, and the image scrambling effect is better. Moreover, the purpose of the scrambling transformation is to hide the information of the original image to the greatest extent. Therefore, the greater the difference between the scrambled image and the original image, the better the scrambling effect is because the scrambling transformation does not change the gray value of the original image pixels, but it does not change the gray value of the original image pixels.It changes the distribution of gray values in the neighborhood of pixel points, so the more "scrambled" the image is relative to the original image, the more effective the scrambling algorithm is.

Source Code

function varargout = ladingfang(varargin)

% LADINGFANG M-file for ladingfang.fig

%      LADINGFANG, by itself, creates a new LADINGFANG or raises the existing

%      singleton*.

%

%      H = LADINGFANG returns the handle to a new LADINGFANG or the handle to

%      the existing singleton*.

%

%      LADINGFANG('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in LADINGFANG.M with the given input arguments.

%

%      LADINGFANG('Property','Value',...) creates a new LADINGFANG or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before ladingfang_OpeningFunction gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to ladingfang_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 ladingfang



% Last Modified by GUIDE v2.5 05-Jan-2005 22:18:40



% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @ladingfang_OpeningFcn, ...

                   'gui_OutputFcn',  @ladingfang_OutputFcn, ...

                   'gui_LayoutFcn',  [] , ...

                   'gui_Callback',   []);

if nargin & isstr(varargin{1})

    gui_State.gui_Callback = str2func(varargin{1});

end



if nargout

    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

    gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT



% --- Executes just before ladingfang is made visible.

function ladingfang_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 ladingfang (see VARARGIN)



% Choose default command line output for ladingfang

handles.output = hObject;



% Update handles structure

guidata(hObject, handles);



% This sets up the initial plot - only do when we are invisible

% so window can get raised using ladingfang.

if strcmp(get(hObject,'Visible'),'off')

%   plot(rand(5));

end

global h1 h2

h1=handles.axes1;

h2=handles.axes2;

%-----------------Initialize interface properties

set(handles.edit1,'string','1');

set(handles.edit2,'string','2');

set(handles.edit3,'string','125');

set(handles.pushbutton2,'Visible','off');

G=imread('LENA256.BMP');

set(gcf,'CurrentAxes',h1);

imshow(G);

title('Original Image');

set(h2,'Visible','off');



% UIWAIT makes ladingfang wait for user response (see UIRESUME)

% uiwait(handles.figure1);





% --- Outputs from this function are returned to the command line.

function varargout = ladingfang_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

varargout{1} = handles.output;



%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Encryption function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

cla;



global h1 h2

%------------Update and get properties for each object

Times = str2num(get(handles.edit1, 'string'));

X= str2num(get(handles.edit2, 'string'));

Y= str2num(get(handles.edit3, 'string'));

popup_sel_index = get(handles.popupmenu1, 'Value');

switch popup_sel_index

    case 1

        G=imread('lena256.bmp');

        set(gcf,'CurrentAxes',h1);

        imshow(G);

        title('Original Image');

   %-----Verify the validity of the input data

   N = str2double(get(handles.edit1,'String'));

   Errstr = '';



      Errstr = 'The number of transformations must be a positive integer!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

   D(1) =str2double(get(handles.edit2,'String'));

   D(2) =str2double(get(handles.edit3,'String'));

   Errstr = '';

   if isnan(D(1)) | ~(floor(D(1)) == D(1)) | (D(1) < 1)| (D(1)>255)

      Errstr = 'Parameter 1 must be a positive integer from 1 to 255!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

   Errstr = '';

   if isnan(D(2)) | ~(floor(D(2)) == D(2)) | (D(2) < 1)| (D(1)>255)

      Errstr = 'Parameter 2 must be a positive integer from 1 to 255!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

   

   if D(1) == D(2)

      Errstr = 'Parameter 1 must be different from parameter 2!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

%-----------End of Validation   

        %-----------During calculation, disable some controls

        mousefrm(0,'watch');

        set(handles.popupmenu1,'enable','off');

        set(handles.popupmenu2,'enable','off');

        set(handles.edit1,'enable','off');

        set(handles.edit2,'enable','off');

        set(handles.edit3,'enable','off');

        set(handles.pushbutton1,'enable','off');

        set(handles.pushbutton2,'enable','off');

        %----------------------------------------

        set(gcf,'CurrentAxes',h2);

        I=G;

        [u,v]=zhengjiaodui(X,Y);

  

        %----------Restore the availability of controls

        set(handles.popupmenu1,'enable','on');

        set(handles.popupmenu2,'enable','on');

        set(handles.edit1,'enable','on');

        set(handles.edit2,'enable','on');

        set(handles.edit3,'enable','on');

        set(handles.pushbutton1,'enable','on');

        set(handles.pushbutton2,'enable','on');

        mousefrm(0,'arrow');

        %--------------------------------------

        

    case 2

        G=imread('LENA256.BMP');

        set(gcf,'CurrentAxes',h1);

        imshow(G);

        title('Original Image');

        %-----Verify the validity of the input data

   N = str2double(get(handles.edit1,'String'));

   Errstr = '';

   if isnan(N) | ~(floor(N) == N) | (N <= 0)

      Errstr = 'The number of transformations must be a positive integer!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

   D(1) =str2double(get(handles.edit2,'String'));

   D(2) =str2double(get(handles.edit3,'String'));

   Errstr = '';

   if isnan(D(1)) | ~(floor(D(1)) == D(1))

      Errstr = 'Parameter 1 must be an integer!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

   Errstr = '';

   if isnan(D(2)) | ~(floor(D(2)) == D(2))

      Errstr = 'Parameter 2 must be an integer!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

%-----------End of Validation   

        mousefrm(0,'watch');

        set(gcf,'CurrentAxes',h2);

        positiontrans(G,Times,X,Y);

        title('After Encryption');

        mousefrm(0,'arrow');

end



%%%%%%%%%%%%%%%%%%%%%%%%%%%%  decryption %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

cla;

global  h1 h2

Times = str2num(get(handles.edit1, 'string'));

X= str2num(get(handles.edit2, 'string'));

Y= str2num(get(handles.edit3, 'string'));

Times = str2num(get(handles.edit1, 'string'));

UNCODE=imread('code.bmp');

set(gcf,'CurrentAxes',h1);

imshow(UNCODE);

title('Before decryption');

%-----Verify the validity of the input data

   N = str2double(get(handles.edit1,'String'));

   Errstr = '';

   if isnan(N) | ~(floor(N) == N) | (N <= 0)

      Errstr = 'The number of transformations must be a positive integer!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

   D(1) =str2double(get(handles.edit2,'String'));

   D(2) =str2double(get(handles.edit3,'String'));

   Errstr = '';

   if isnan(D(1)) | ~(floor(D(1)) == D(1)) | (D(1) < 1)| (D(1)>255)

      Errstr = 'Parameter 1 must be a positive integer from 1 to 255!';

   end

   

   

   if D(1) == D(2)

      Errstr = 'Parameter 1 must be different from parameter 2!';

   end

   if ~isempty(Errstr)

      errordlg(Errstr);

      return

   end

3. Operational reference

Posted by sir nitr0z on Sat, 09 Oct 2021 09:55:52 -0700