A kind of method and device of image encryption
Technical field
This application involves image encryption processing technology fields, more particularly, to a kind of method and device of image encryption.
Background technique
With the development of the communication technology, user can carry out the publication of information by network at any time, anywhere,
Although a large amount of shared information is provided convenience for user, the safety problem of information transmission gradually shows, and information occurs and lets out
The phenomenon that dew, malice change information, it is therefore desirable to encryption mode be used to message transmitting procedure, avoid message transmitting procedure
In malicious intercepted phenomenon.
For transmitting color image information, the encryption method during colo r image transmission has to be compiled based on double random phase
The single channel multicolor image encryption algorithm of code, the video single channel optical Encryption Algorithm based on chaotic key etc., but pass through list
Channel is encrypted respectively, needs constantly to iterate to calculate, and complexity is higher, in addition, for dividing the different colours of color image
The method that amount is encoded to quaternionic matrix encryption is still quaternary number after encryption, there are problems that occupying memory space, so providing
A kind of method of image encryption, while guaranteeing to reduce memory space, the problem of effectively improving encryption efficiency.
Summary of the invention
In view of this, a kind of method and device for being designed to provide image encryption of the application, reduces memory space
Meanwhile the problem of effectively improving encryption efficiency.
In a first aspect, the embodiment of the present application provides a kind of method of image encryption, wherein include:
Obtain image to be encrypted;
For the image to be encrypted, the corresponding ternary matrix number of the image to be encrypted is determined;
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the ternary
The transformed frequency spectrum of matrix number;
For the frequency spectrum, the first real number matrix and the first complex matrix of the frequency spectrum are determined;
After carrying out equal moulds decomposition to first complex matrix, based on first real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix;
Gyrator transformation is carried out to first matrix, based on transformed as a result, determining that the image to be encrypted is corresponding
Ciphertext image.
In the embodiment of the application, the reference colours of the image to be encrypted include: the first color, the second color and
Three colors, it is described to be directed to the image to be encrypted, determine the corresponding ternary matrix number of the image to be encrypted, comprising:
The first color value for successively extracting each pixel in the image to be encrypted obtains the first color value Component Matrices;
The second color value for successively extracting each pixel in the image to be encrypted obtains the second color value Component Matrices;
The third color value for successively extracting each pixel in the image to be encrypted obtains third color value Component Matrices;Its
In, the first color value Component Matrices are the real component matrix of the ternary matrix number, the second color value component square
Battle array and the third color value Component Matrices are the imaginary matrix of the ternary matrix number.
In the embodiment of the application, first parameter preset that is based on is to the discrete Three-ary Number of ternary matrix number progress
Fourier transformation, the frequency spectrum after obtaining the Three-ary Number matrixing, comprising:
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the ternary
The transformed frequency spectrum of matrix number, wherein
In formula, F1(u, v) is the frequency spectrum after the Three-ary Number matrixing;ft(x, y) is the ternary matrix number, (x, y)
For the space coordinate of pixel in the image to be encrypted;μ1For pure Three-ary Number, and μ1=icos θ1+jsinθ1;θ1It is described first
Parameter preset;M is the pixel columns that the image to be encrypted includes;N is the number of lines of pixels that the image to be encrypted includes;ft
(x, y)=f1(x,y)+if2(x,y)+jf3(x, y), wherein f1(x, y) is the first color value Component Matrices;f2(x, y) is
The second color value Component Matrices;f3(x, y) is the third color value Component Matrices;I, j is imaginary, and is met
Condition: i2=j, ij=ji=-1, j2=-i.
It is described to be directed to the frequency spectrum in the embodiment of the application, determine the first real number matrix, the Yi Ji of the frequency spectrum
One complex matrix, comprising:
To the frequency spectrum F1The expression formula of (u, v) is converted, and determines the first real number matrix and first of the frequency spectrum
Complex matrix, transformation for mula are as follows:
Enable D (u, v)=B (u, v)+iC (u, v);In formula, A (u, v) is first real number matrix;D (u, v) is described the
One complex matrix;B (u, v) is the real-part matrix of first complex matrix;C (u, v) is the imaginary part of first complex matrix
Matrix.
It is described that equal moulds decomposition is carried out to first complex matrix in the embodiment of the application, comprising:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, P (u, v) is
Second complex matrix, Q (u, v) are the third complex matrix, | D (u, v) | for the first complex matrix D (u, v)
Amplitude,For the phasing matrix of the first complex matrix D (u, v), θ is default matrix;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, comprising:
The third complex matrix Q (u, v) based on the first real number matrix A (u, v) and after waiting moulds to decompose, really
Fixed first matrix, wherein K (u, v) is first matrix, and
It is described that equal moulds decomposition is carried out to first complex matrix in the embodiment of the application, comprising:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, D (u, v) is
First complex matrix, P (u, v) are second complex matrix, and Q (u, v) is the third complex matrix, | D (u, v) | be
The amplitude of the first complex matrix D (u, v),For the phasing matrix of the first complex matrix D (u, v), θ is default square
Battle array;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, comprising:
The third complex matrix based on first real number matrix and after waiting moulds to decompose, determines the second Three-ary Number
Matrix;
Discrete Three-ary Number Fourier transformation is carried out to the second ternary matrix number based on the second parameter preset, is obtained described
Frequency spectrum after second Three-ary Number matrixing;
For the frequency spectrum, the second real number matrix and the 4th complex matrix of the frequency spectrum are determined;
After carrying out equal moulds decomposition to the 4th complex matrix, based on second real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix.
In the embodiment of the application, it is described based on transformed as a result, determining the corresponding ciphertext of the image to be encrypted
Image, comprising:
The amplitude of transformed result is remained unchanged, phase truncation operation is carried out, it is corresponding to obtain the image to be encrypted
Ciphertext image.
In the embodiment of the application, the method also includes:
Gyrator inverse transformation is carried out to the ciphertext image, first matrix is determined, and be based on first matrix, obtains
To first real number matrix and the third complex matrix;
Based on the third complex matrix, second complex matrix is calculated;
Based on first real number matrix, second complex matrix and the third complex matrix, institute is calculated
State frequency spectrum;
Based on first parameter preset, discrete Three-ary Number inverse Fourier transform is carried out to the frequency spectrum, obtains described three
First matrix number;
According to the ternary matrix number, the image to be encrypted is obtained.
Second aspect, the embodiment of the present application also provides a kind of device of image encryption, described device includes:
Module is obtained, for obtaining image to be encrypted;
First determining module determines the corresponding Three-ary Number square of the image to be encrypted for being directed to the image to be encrypted
Battle array;
Processing module becomes for carrying out discrete Three-ary Number Fourier to the ternary matrix number based on the first parameter preset
It changes, the frequency spectrum after obtaining the Three-ary Number matrixing;
Second determining module determines the first real number matrix and the first plural number of the frequency spectrum for being directed to the frequency spectrum
Matrix;
Third determining module is based on the first real number square after carrying out equal moulds decomposition to first complex matrix
Battle array and wait moulds decompose after complex matrix, determine the first matrix;
4th determining module, for carrying out gyrator transformation to first matrix, based on transformed as a result, determining institute
State the corresponding ciphertext image of image to be encrypted.
In the embodiment of the application, the reference colours of the image to be encrypted include: the first color, the second color and
Three colors, first determining module, are specifically used for:
The first color value for successively extracting each pixel in the image to be encrypted obtains the first color value Component Matrices;
The second color value for successively extracting each pixel in the image to be encrypted obtains the second color value Component Matrices;
The third color value for successively extracting each pixel in the image to be encrypted obtains third color value Component Matrices;Its
In, the first color value Component Matrices are the real component matrix of the ternary matrix number, the second color value component square
Battle array and the third color value Component Matrices are the imaginary matrix of the ternary matrix number.
In the embodiment of the application, the processing module is specifically used for:
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the ternary
The transformed frequency spectrum of matrix number, wherein
In formula, F1(u, v) is the frequency spectrum after the Three-ary Number matrixing;ft(x, y) is the ternary matrix number, (x, y)
For the space coordinate of pixel in the image to be encrypted;μ1For pure Three-ary Number, and μ1=icos θ1+jsinθ1;θ1It is described first
Parameter preset;M is the pixel columns that the image to be encrypted includes;N is the number of lines of pixels that the image to be encrypted includes;ft
(x, y)=f1(x,y)+if2(x,y)+jf3(x, y), wherein f1(x, y) is the first color value Component Matrices;f2(x, y) is
The second color value Component Matrices;f3(x, y) is the third color value Component Matrices;I, j is imaginary, and is met
Condition: i2=j, ij=ji=-1, j2=-i.
In the embodiment of the application, second determining module is specifically used for:
To the frequency spectrum F1The expression formula of (u, v) is converted, and determines the first real number matrix and first of the frequency spectrum
Complex matrix, transformation for mula are as follows:
Enable D (u, v)=B (u, v)+iC (u, v);In formula, A (u, v) is first real number matrix;D (u, v) is described the
One complex matrix;B (u, v) is the real-part matrix of first complex matrix;C (u, v) is the imaginary part of first complex matrix
Matrix.
In the embodiment of the application, in the third determining module, equal moulds is carried out to first complex matrix and are decomposed,
It is specifically used for:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, P (u, v) is
Second complex matrix, Q (u, v) are the third complex matrix, | D (u, v) | for the first complex matrix D (u, v)
Amplitude,For the phasing matrix of the first complex matrix D (u, v), θ is default matrix;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, specific to use
In:
The third complex matrix Q (u, v) based on the first real number matrix A (u, v) and after waiting moulds to decompose, really
Fixed first matrix, wherein K (u, v) is first matrix, and
It is described that equal moulds are carried out to first complex matrix in the third determining module in the embodiment of the application
It decomposes, is specifically used for:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, D (u, v) is
First complex matrix, P (u, v) are second complex matrix, and Q (u, v) is the third complex matrix, | D (u, v) | be
The amplitude of the first complex matrix D (u, v),For the phasing matrix of the first complex matrix D (u, v), θ is default square
Battle array;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, specific to use
In:
The third complex matrix based on first real number matrix and after waiting moulds to decompose, determines the second Three-ary Number
Matrix;
Discrete Three-ary Number Fourier transformation is carried out to the second ternary matrix number based on the second parameter preset, is obtained described
Frequency spectrum after second Three-ary Number matrixing;
For the frequency spectrum, the second real number matrix and the 4th complex matrix of the frequency spectrum are determined;
After carrying out equal moulds decomposition to the 4th complex matrix, based on second real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix.
In the embodiment of the application, in the 4th determining module, based on transformed as a result, determination is described to be encrypted
The corresponding ciphertext image of image, is specifically used for:
The amplitude of transformed result is remained unchanged, phase truncation operation is carried out, it is corresponding to obtain the image to be encrypted
Ciphertext image.
In the embodiment of the application, described device is also used to:
Gyrator inverse transformation is carried out to the ciphertext image, first matrix is determined, and be based on first matrix, obtains
To first real number matrix and the third complex matrix;
Based on the third complex matrix, second complex matrix is calculated;
Based on first real number matrix, second complex matrix and the third complex matrix, institute is calculated
State frequency spectrum;
Based on first parameter preset, discrete Three-ary Number inverse Fourier transform is carried out to the frequency spectrum, obtains described three
First matrix number;
According to the ternary matrix number, the image to be encrypted is obtained.
The third aspect, the embodiment of the present application also provide a kind of electronic equipment, comprising: processor, memory and bus, it is described
Memory is stored with the executable machine readable instructions of the processor, when electronic equipment operation, the processor with it is described
By bus communication between memory, the machine readable instructions executed when being executed by the processor it is above-mentioned in a first aspect, or
Step in any possible embodiment of first aspect.
Fourth aspect, the embodiment of the present application also provide a kind of computer readable storage medium, the computer-readable storage medium
Computer program is stored in matter, which executes above-mentioned in a first aspect, or first aspect when being run by processor
Step in any possible embodiment.
A kind of method of image encryption provided by the embodiments of the present application, by obtaining the ternary matrix number of image to be encrypted,
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the first real number square of frequency spectrum
Battle array and the first complex matrix according to above-mentioned first real number matrix and wait moulds after decomposing to moulds such as first complex matrixs
Complex matrix after decomposition determines the first matrix, after carrying out gyrator variation to first matrix, determines that image to be encrypted is corresponding
Ciphertext image.
By the above method, may be implemented based on ternary matrix number is obtained after the encryption of ternary matrix number, relative to will be colored
The different colours component coding of image is quaternionic matrix encryption, is still the method for quaternary number after encryption, reduces memory space,
And the ternary matrix number by treating encrypted image carries out discrete Three-ary Number Fourier transformation, and to transformed complex matrix
Equal moulds decompose, to convert to the first matrix gyrator being calculated, improve the efficiency of encryption.
Other feature and advantage of the application will illustrate in the following description, also, partly become from specification
It obtains it is clear that being understood and implementing the application.The purpose of the application and other advantages are in specification, claims
And specifically noted structure is achieved and obtained in attached drawing.
To enable the above objects, features, and advantages of the application to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate
Appended attached drawing, is described in detail below.
Detailed description of the invention
It, below will be to specific in order to illustrate more clearly of the application specific embodiment or technical solution in the prior art
Embodiment or attached drawing needed to be used in the description of the prior art be briefly described, it should be apparent that, it is described below
Attached drawing is some embodiments of the application, for those of ordinary skill in the art, before not making the creative labor
It puts, is also possible to obtain other drawings based on these drawings.
Fig. 1 shows a kind of flow diagram of the method for image encryption provided by the embodiments of the present application;
Fig. 2 shows the flow diagrams of a kind of method of image decryption provided by the embodiment of the present application;
Fig. 3 shows a kind of structural schematic diagram of the device of image encryption provided by the embodiment of the present application;
Fig. 4 shows the structural schematic diagram of a kind of electronic equipment 400 provided by the embodiment of the present application.
Specific embodiment
To keep the purposes, technical schemes and advantages of the embodiment of the present application clearer, below in conjunction with attached drawing to the application
Technical solution be clearly and completely described, it is clear that described embodiment is some embodiments of the present application, rather than
Whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making creative work premise
Under every other embodiment obtained, shall fall in the protection scope of this application.
Firstly, making introduction to the application application scenarios applicatory.The application be applicable to image is encrypted,
Under the scene of decrypted transport.
For the method convenient for understanding the present embodiment, first to a kind of image encryption disclosed in the embodiment of the present application
It describes in detail.
Embodiment one
It is shown in Figure 1, it is a kind of flow diagram of the method for image encryption provided by the embodiment of the present application, the party
Method the following steps are included:
Step 101 obtains image to be encrypted.
Specifically, image to be encrypted can be color image, it is also possible to gray level image.
Step 102 is directed to image to be encrypted, determines the corresponding ternary matrix number of image to be encrypted.
When image to be encrypted be color image, and the reference colours of image to be encrypted include: the first color, the second color and
When third color, for image to be encrypted, the corresponding ternary matrix number of image to be encrypted is determined, comprising:
The first color value for successively extracting each pixel in image to be encrypted obtains the first color value Component Matrices;
The second color value for successively extracting each pixel in image to be encrypted obtains the second color value Component Matrices;
The third color value for successively extracting each pixel in image to be encrypted obtains third color value Component Matrices;
Wherein, the first color value Component Matrices are the real component matrix of ternary matrix number, the second color value Component Matrices
It is the imaginary matrix of ternary matrix number with third color value Component Matrices.
Illustratively, it is assumed that first color is red in the reference colours of image to be encrypted, and the second color is green, third face
Color is blue, then successively extracting the first color value of each pixel in image to be encrypted, the second color value, third color value, is obtained
To the first color value Component Matrices fR(x, y), the second color value Component Matrices fG(x, y), third color value Component Matrices fB(x,
And ternary matrix number f y),t(x, y)=fR(x,y)+ifG(x,y)+jfB(x, y), (x, y) are the sky of pixel in image to be encrypted
Between coordinate, i, j are imaginary, and eligible: i2=j, ij=ji=-1, j2=-i.
Step 103 carries out discrete Three-ary Number Fourier transformation to ternary matrix number based on the first parameter preset, obtains ternary
The transformed frequency spectrum of matrix number.
Illustratively, the spectrum expression formula after discrete Three-ary Number Fourier transformation is as follows:
In formula, F1(u, v) is the frequency spectrum after Three-ary Number matrixing;ft(x, y) is ternary matrix number, and (x, y) is to be encrypted
The space coordinate of pixel in image;μ1For pure Three-ary Number, and μ1=icos θ1+jsinθ1;θ1For the first parameter preset;M is to be added
The pixel columns that close image includes;N is the number of lines of pixels that image to be encrypted includes;ft(x, y)=f1(x,y)+if2(x,y)+jf3
(x, y), wherein f1(x, y) is the first color value Component Matrices;f2(x, y) is the second color value Component Matrices;f3(x, y) is the
Three color value Component Matrices;I, j is imaginary, and eligible: i2=j, ij=ji=-1, j2=-i.
Step 104 is directed to frequency spectrum, determines the first real number matrix and the first complex matrix of frequency spectrum.
Here, to frequency spectrum F1The expression formula of (u, v) is converted, and the first real number matrix and first for determining frequency spectrum are answered
Matrix number, transformation for mula are as follows:
Enable D (u, v)=B (u, v)+iC (u, v);In formula, A (u, v) is the first real number matrix;D (u, v) is the first plural square
Battle array;B (u, v) is the real-part matrix of the first complex matrix;C (u, v) is the imaginary-part matrix of the first complex matrix.
Optionally, by F1(u, v)=A (u, v)+iB (u, v)+jC (u, v) and i2=j, obtains F1(u, v)=A (u, v)+
I [B (u, v)+iC (u, v)], and then determine the first real number matrix and the first complex matrix.
Step 105 first complex matrix such as carries out after moulds decompose, based on the first real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix.
In a kind of possible embodiments, equal moulds are carried out to the first complex matrix and are decomposed, comprising:
Equal moulds are carried out to the first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein wait moulds point
Solve formula are as follows:
In formula, P (u, v) is the second complex matrix, and Q (u, v) is third complex matrix, | D (u, v) | it is the first complex matrix
The amplitude of D (u, v),For the phasing matrix of the first complex matrix D (u, v), θ is default matrix.
Complex matrix based on the first real number matrix and after waiting moulds to decompose, determines the first matrix, comprising:
Third complex matrix Q (u, v) based on the first real number matrix A (u, v) and after waiting moulds to decompose, determines the first square
Battle array, wherein K (u, v) is the first matrix, and
In the possible another embodiments of one kind, equal moulds are carried out to the first complex matrix and are decomposed, comprising:
Equal moulds are carried out to the first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein wait moulds point
Solve formula are as follows:
In formula, D (u, v) is the first complex matrix, and P (u, v) is the second complex matrix, and Q (u, v) is third complex matrix, |
D (u, v) | it is the amplitude of the first complex matrix D (u, v),For the phasing matrix of the first complex matrix D (u, v), θ is default square
Battle array.
Complex matrix based on the first real number matrix and after waiting moulds to decompose, determines the first matrix, comprising:
Third complex matrix Q (u, v) based on the first real number matrix A (u, v) and after waiting moulds to decompose, determines the two or three
First matrix number gt(x, y), and gt(x, y)=A (x, y)+iRe { Q (x, y) }+jIm { Q (x, y) }.
In formula, A (x, y) is the corresponding space coordinate matrix of the first real number matrix A (u, v), and Q (x, y) is third plural number square
The corresponding space coordinate matrix of battle array Q (u, v), operator Re (), Im () respectively indicate the real component of Q (x, y) matrix, imaginary part
Component.
Based on the second parameter preset θ2Discrete Three-ary Number Fourier transformation is carried out to the second ternary matrix number gt (x, y), is obtained
Frequency spectrum to after the second Three-ary Number matrixing;For frequency spectrum, the second real number matrix and the 4th plural square of frequency spectrum are determined
Battle array;After carrying out equal moulds decomposition to the 4th complex matrix, based on the second real number matrix and the complex matrix after moulds decomposition is waited, really
Fixed first matrix.
Here, frequency spectrum is determined to the discrete Three-ary Number Fourier transformation of the second ternary matrix number and by frequency spectrum after transformation
Real number matrix, complex matrix, to complex matrix etc. the process decomposed of moulds and above-mentioned discrete ternary is carried out to ternary matrix number
Number Fourier transformations and by frequency spectrum after transformation determine the real number matrix of frequency spectrum, complex matrix, to complex matrix etc. moulds point
The process of solution is identical, and details are not described herein.
Illustratively, after carrying out equal moulds decomposition to the 4th complex matrix, the 5th complex matrix and the 6th complex matrix are obtained,
Based on the second real number matrix A1(u, v) and wait the 6th complex matrix Q after moulds decomposition1(u, v) determines the first matrix, wherein
K1(u, v) is the first matrix, and
The number for carrying out discrete Three-ary Number Fourier transformation to ternary matrix number is not limited in the application, is not limited pair yet
The number that the moulds such as complex matrix of frequency spectrum decompose after discrete Three-ary Number Fourier transformation.
Step 106 carries out gyrator transformation to the first matrix, based on transformed as a result, determining that image to be encrypted is corresponding
Ciphertext image.
Illustratively, it is assumed that the first matrix is h, then after carrying out gyrator transformation to the first matrix h, obtained expression formula
It is as follows:
In formula, (u, v) indicates that frequency domain coordinates, (x, y) representation space domain coordinate, β are rotation angle.
The amplitude of transformed result is remained unchanged, phase truncation operation is carried out, it is corresponding close to obtain image to be encrypted
Texts and pictures picture.
It is shown in Figure 2, it is a kind of flow diagram of the method for image decryption provided by the embodiment of the present application, method
The following steps are included:
Step 201 carries out gyrator inverse transformation to ciphertext image, determines the first matrix, and be based on the first matrix, obtains the
One real number matrix and third complex matrix.
Illustratively, gyrator inverse transformation is carried out according to ciphertext image, obtains the first matrix K (u, v), andSo that it is determined that the first real number matrix is A (u, v) and third complex matrix is Q (u, v).
Step 202 is based on third complex matrix, and the second complex matrix is calculated.
According to third complex matrixThe second complex matrix is calculated
In formula, | D (u, v) | it is the amplitude of the first complex matrix D (u, v),For the phase of the first complex matrix D (u, v)
Matrix, θ are default matrix.
Step 203 is based on the first real number matrix, the second complex matrix and third complex matrix, and frequency spectrum is calculated.
According to the second complex matrix, third complex matrix, the first complex matrix D (u, v) is calculated, and then according to first
Complex matrix D (u, v), the first real number matrix A (u, v), obtaining frequency spectrum formula is F1(u, v)=A (u, v)+iD (u, v).
Step 204 is based on the first parameter preset, carries out discrete Three-ary Number inverse Fourier transform to frequency spectrum, obtains Three-ary Number
Matrix.
According to the first parameter preset θ1, to frequency spectrum F1(u, v) carries out discrete Three-ary Number inverse Fourier transform, obtains Three-ary Number
Matrix ft(x,y)。
Step 205, according to ternary matrix number, obtain image to be encrypted.
Here, the decrypting process of image to be encrypted is the inverse process of the ciphering process of correspondence image.
Illustratively, image to be encrypted, image size are 256 × 256, process discrete Three-ary Number Fourier transformation twice,
It is 0.3091 that wherein the first parameter preset, which is the 0.0859, second parameter preset, and rotation angle when carrying out gyrator transformation is
0.0596, ciphertext image is obtained after being encrypted, the information of ciphertext image is confusing, can not visually find out original to be added
Any useful information of close image is 0.0596 in the rotation angle Jing Guo gyrator inverse transformation, and the second parameter preset is
0.3091, after the decryption that the first parameter preset is 0.0859, decrypted image is obtained, by the calculating to decrypted image, peak value
Signal-to-noise ratio is 257.2369dB, and structural similarity SSIM is 1.00, and it is consistent with original image to be encrypted to obtain decrypted image.
A kind of method of image encryption provided in this embodiment is based on by obtaining the ternary matrix number of image to be encrypted
First parameter preset carries out discrete Three-ary Number Fourier transformation to the ternary matrix number, obtain frequency spectrum the first real number matrix, with
And first complex matrix, after being decomposed to moulds such as first complex matrixs, according to above-mentioned first real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix, to first matrix carry out gyrator variation after, determine the corresponding ciphertext of image to be encrypted
Image.
By the above method, may be implemented based on ternary matrix number is obtained after the encryption of ternary matrix number, relative to will be colored
The different colours component coding of image is quaternionic matrix encryption, is still the method for quaternary number after encryption, reduces memory space,
And the ternary matrix number by treating encrypted image carries out discrete Three-ary Number Fourier transformation, and to transformed complex matrix
Equal moulds decompose, to convert to the first matrix gyrator being calculated, improve the efficiency of encryption.
Embodiment two
It is shown in Figure 3, it is a kind of structural schematic diagram of the device of image encryption provided by the embodiment of the present application, packet
It includes: obtaining module 301, the first determining module 302, processing module 303, the second determining module 304, third determining module 305, the
Four determining modules 306, specifically include:
Module 301 is obtained, for obtaining image to be encrypted;
First determining module 302 determines the corresponding Three-ary Number of the image to be encrypted for being directed to the image to be encrypted
Matrix;
Processing module 303, for carrying out discrete Three-ary Number Fourier to the ternary matrix number based on the first parameter preset
Transformation, the frequency spectrum after obtaining the Three-ary Number matrixing;
Second determining module 304 determines the first real number matrix and first of the frequency spectrum for being directed to the frequency spectrum
Complex matrix;
Third determining module 305 is based on first real number after carrying out equal moulds decomposition to first complex matrix
Matrix and wait moulds decompose after complex matrix, determine the first matrix;
4th determining module 306, for carrying out gyrator transformation to first matrix, based on transformed as a result, really
Determine the corresponding ciphertext image of the image to be encrypted.
In the embodiment of the application, the reference colours of the image to be encrypted include: the first color, the second color and
Three colors, first determining module 302, are specifically used for:
The first color value for successively extracting each pixel in the image to be encrypted obtains the first color value Component Matrices;
The second color value for successively extracting each pixel in the image to be encrypted obtains the second color value Component Matrices;
The third color value for successively extracting each pixel in the image to be encrypted obtains third color value Component Matrices;Its
In, the first color value Component Matrices are the real component matrix of the ternary matrix number, the second color value component square
Battle array and the third color value Component Matrices are the imaginary matrix of the ternary matrix number.
In the embodiment of the application, the processing module 303 is specifically used for:
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the ternary
The transformed frequency spectrum of matrix number, wherein
In formula, F1(u, v) is the frequency spectrum after the Three-ary Number matrixing;ft(x, y) is the ternary matrix number, (x, y)
For the space coordinate of pixel in the image to be encrypted;μ1For pure Three-ary Number, and μ1=icos θ1+jsinθ1;θ1It is described first
Parameter preset;M is the pixel columns that the image to be encrypted includes;N is the number of lines of pixels that the image to be encrypted includes;ft
(x, y)=f1(x,y)+if2(x,y)+jf3(x, y), wherein f1(x, y) is the first color value Component Matrices;f2(x, y) is
The second color value Component Matrices;f3(x, y) is the third color value Component Matrices;I, j is imaginary, and is met
Condition: i2=j, ij=ji=-1, j2=-i.
In the embodiment of the application, second determining module 304 is specifically used for:
To the frequency spectrum F1The expression formula of (u, v) is converted, and determines the first real number matrix and first of the frequency spectrum
Complex matrix, transformation for mula are as follows:
Enable D (u, v)=B (u, v)+iC (u, v);In formula, A (u, v) is first real number matrix;D (u, v) is described the
One complex matrix;B (u, v) is the real-part matrix of first complex matrix;C (u, v) is the imaginary part of first complex matrix
Matrix.
In the embodiment of the application, in the third determining module 305, equal moulds point are carried out to first complex matrix
Solution, is specifically used for:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, P (u, v) is
Second complex matrix, Q (u, v) are the third complex matrix, | D (u, v) | for the first complex matrix D (u, v)
Amplitude,For the phasing matrix of the first complex matrix D (u, v), θ is default matrix;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, specific to use
In:
The third complex matrix Q (u, v) based on the first real number matrix A (u, v) and after waiting moulds to decompose, really
Fixed first matrix, wherein K (u, v) is first matrix, and
It is described first complex matrix to be carried out etc. in the third determining module 305 in the embodiment of the application
Mould decomposes, and is specifically used for:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, D (u, v) is
First complex matrix, P (u, v) are second complex matrix, and Q (u, v) is the third complex matrix, | D (u, v) | be
The amplitude of the first complex matrix D (u, v),For the phasing matrix of the first complex matrix D (u, v), θ is default square
Battle array;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, specific to use
In:
The third complex matrix based on first real number matrix and after waiting moulds to decompose, determines the second Three-ary Number
Matrix;
Discrete Three-ary Number Fourier transformation is carried out to the second ternary matrix number based on the second parameter preset, is obtained described
Frequency spectrum after second Three-ary Number matrixing;
For the frequency spectrum, the second real number matrix and the 4th complex matrix of the frequency spectrum are determined;
After carrying out equal moulds decomposition to the 4th complex matrix, based on second real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix.
In the embodiment of the application, in the 4th determining module 306, based on it is transformed as a result, determine it is described to
The corresponding ciphertext image of encrypted image, is specifically used for:
The amplitude of transformed result is remained unchanged, phase truncation operation is carried out, it is corresponding to obtain the image to be encrypted
Ciphertext image.
In the embodiment of the application, described device is also used to:
Gyrator inverse transformation is carried out to the ciphertext image, first matrix is determined, and be based on first matrix, obtains
To first real number matrix and the third complex matrix;
Based on the third complex matrix, second complex matrix is calculated;
Based on first real number matrix, second complex matrix and the third complex matrix, institute is calculated
State frequency spectrum;
Based on first parameter preset, discrete Three-ary Number inverse Fourier transform is carried out to the frequency spectrum, obtains described three
First matrix number;
According to the ternary matrix number, the image to be encrypted is obtained.
Embodiment three
Based on same technical concept, the embodiment of the present application also provides a kind of electronic equipment.It is this Shen referring to shown in Fig. 4
Please the structural schematic diagram of electronic equipment 400 that provides of embodiment, including processor 401, memory 402 and bus 403.Wherein,
Memory 402 is executed instruction for storing, including memory 4021 and external memory 4022;Here memory 4021 is also referred to as memory
Reservoir, for temporarily storing the operational data in processor 401, and the data exchanged with external memories 4022 such as hard disks,
Processor 401 carries out data exchange by memory 4021 and external memory 4022, when electronic equipment 400 is run, processor
It is communicated between 401 and memory 402 by bus 403, so that processor 401 is being executed to give an order:
Obtain image to be encrypted;
For the image to be encrypted, the corresponding ternary matrix number of the image to be encrypted is determined;
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the ternary
The transformed frequency spectrum of matrix number;
For the frequency spectrum, the first real number matrix and the first complex matrix of the frequency spectrum are determined;
After carrying out equal moulds decomposition to first complex matrix, based on first real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix;
Gyrator transformation is carried out to first matrix, based on transformed as a result, determining that the image to be encrypted is corresponding
Ciphertext image.
In a kind of possible design, in the processing that processor 401 executes, the reference colours of the image to be encrypted include: the
One color, the second color and third color, it is described to be directed to the image to be encrypted, determine the image to be encrypted corresponding three
First matrix number, comprising:
The first color value for successively extracting each pixel in the image to be encrypted obtains the first color value Component Matrices;
The second color value for successively extracting each pixel in the image to be encrypted obtains the second color value Component Matrices;
The third color value for successively extracting each pixel in the image to be encrypted obtains third color value Component Matrices;Its
In, the first color value Component Matrices are the real component matrix of the ternary matrix number, the second color value component square
Battle array and the third color value Component Matrices are the imaginary matrix of the ternary matrix number.
In a kind of possible design, in the processing that processor 401 executes, first parameter preset that is based on is to the ternary
Matrix number carries out discrete Three-ary Number Fourier transformation, the frequency spectrum after obtaining the Three-ary Number matrixing, comprising:
Discrete Three-ary Number Fourier transformation is carried out to the ternary matrix number based on the first parameter preset, obtains the ternary
The transformed frequency spectrum of matrix number, wherein
In formula, F1(u, v) is the frequency spectrum after the Three-ary Number matrixing;ft(x, y) is the ternary matrix number, (x, y)
For the space coordinate of pixel in the image to be encrypted;μ1For pure Three-ary Number, and μ1=icos θ1+jsinθ1;θ1It is described first
Parameter preset;M is the pixel columns that the image to be encrypted includes;N is the number of lines of pixels that the image to be encrypted includes;ft
(x, y)=f1(x,y)+if2(x,y)+jf3(x, y), wherein f1(x, y) is the first color value Component Matrices;f2(x, y) is
The second color value Component Matrices;f3(x, y) is the third color value Component Matrices;I, j is imaginary, and is met
Condition: i2=j, ij=ji=-1, j2=-i.
It is described to be directed to the frequency spectrum in the processing that processor 401 executes in a kind of possible design, determine the frequency spectrum
The first real number matrix and the first complex matrix, comprising:
To the frequency spectrum F1The expression formula of (u, v) is converted, and determines the first real number matrix and first of the frequency spectrum
Complex matrix, transformation for mula are as follows:
Enable D (u, v)=B (u, v)+iC (u, v);In formula, A (u, v) is first real number matrix;D (u, v) is described the
One complex matrix;B (u, v) is the real-part matrix of first complex matrix;C (u, v) is the imaginary part of first complex matrix
Matrix.
It is described that equal moulds are carried out to first complex matrix in the processing that processor 401 executes in a kind of possible design
It decomposes, comprising:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, P (u, v) is
Second complex matrix, Q (u, v) are the third complex matrix, | D (u, v) | for the first complex matrix D (u, v)
Amplitude,For the phasing matrix of the first complex matrix D (u, v), θ is default matrix;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, comprising:
The third complex matrix Q (u, v) based on the first real number matrix A (u, v) and after waiting moulds to decompose, really
Fixed first matrix, wherein K (u, v) is first matrix, and
It is described that equal moulds are carried out to first complex matrix in the processing that processor 401 executes in a kind of possible design
It decomposes, comprising:
Equal moulds are carried out to first complex matrix to decompose, and obtain the second complex matrix and third complex matrix, wherein etc.
Mould decomposition formula are as follows:
In formula, D (u, v) is
First complex matrix, P (u, v) are second complex matrix, and Q (u, v) is the third complex matrix, | D (u, v) | be
The amplitude of the first complex matrix D (u, v),For the phasing matrix of the first complex matrix D (u, v), θ is default square
Battle array;
The complex matrix based on first real number matrix and after waiting moulds to decompose, determines the first matrix, comprising:
The third complex matrix based on first real number matrix and after waiting moulds to decompose, determines the second Three-ary Number
Matrix;
Discrete Three-ary Number Fourier transformation is carried out to the second ternary matrix number based on the second parameter preset, is obtained described
Frequency spectrum after second Three-ary Number matrixing;
For the frequency spectrum, the second real number matrix and the 4th complex matrix of the frequency spectrum are determined;
After carrying out equal moulds decomposition to the 4th complex matrix, based on second real number matrix and after waiting moulds to decompose
Complex matrix, determine the first matrix.
In a kind of possible design, in the processing that processor 401 executes, it is described based on transformed as a result, described in determination
The corresponding ciphertext image of image to be encrypted, comprising:
The amplitude of transformed result is remained unchanged, phase truncation operation is carried out, it is corresponding to obtain the image to be encrypted
Ciphertext image.
In a kind of possible design, in the processing that processor 401 executes, the method also includes:
Gyrator inverse transformation is carried out to the ciphertext image, first matrix is determined, and be based on first matrix, obtains
To first real number matrix and the third complex matrix;
Based on the third complex matrix, second complex matrix is calculated;
Based on first real number matrix, second complex matrix and the third complex matrix, institute is calculated
State frequency spectrum;
Based on first parameter preset, discrete Three-ary Number inverse Fourier transform is carried out to the frequency spectrum, obtains described three
First matrix number;
According to the ternary matrix number, the image to be encrypted is obtained.
Example IV
The embodiment of the present application also provides a kind of computer readable storage medium, stored on the computer readable storage medium
There is computer program, which executes the method for above-mentioned image encryption when being run by processor the step of.
Specifically, which can be general storage medium, such as mobile disk, hard disk, on the storage medium
Computer program when being run, the step of being able to carry out the method for above-mentioned image encryption, thus while reducing memory space,
The problem of effectively improving encryption efficiency.
The computer program product of the method for image encryption provided by the embodiment of the present application, including store program code
Computer readable storage medium, the instruction that program code includes can be used for executing the method in previous methods embodiment, specifically
It realizes and can be found in embodiment of the method, details are not described herein.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In embodiment provided herein, it should be understood that disclosed device and method, it can be by others side
Formula is realized.The apparatus embodiments described above are merely exemplary, for example, the division of the unit, only one kind are patrolled
Function division is collected, there may be another division manner in actual implementation, in another example, multiple units or components can combine or can
To be integrated into another system, or some features can be ignored or not executed.Another point, shown or discussed is mutual
Coupling, direct-coupling or communication connection can be INDIRECT COUPLING or communication link by some communication interfaces, device or unit
It connects, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
In addition, each functional unit in embodiment provided by the present application can integrate in one processing unit, it can also
To be that each unit physically exists alone, can also be integrated in one unit with two or more units.
It, can be with if the function is realized in the form of SFU software functional unit and when sold or used as an independent product
It is stored in a computer readable storage medium.Based on this understanding, the technical solution of the application is substantially in other words
The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a
People's computer, server or network equipment etc.) execute each embodiment the method for the application all or part of the steps.
And storage medium above-mentioned includes: that USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic or disk.
It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing, in addition, term " the
One ", " second ", " third " etc. are only used for distinguishing description, are not understood to indicate or imply relative importance.
Finally, it should be noted that embodiment described above, the only specific embodiment of the application, to illustrate the application
Technical solution, rather than its limitations, the protection scope of the application is not limited thereto, although with reference to the foregoing embodiments to this Shen
It please be described in detail, those skilled in the art should understand that: anyone skilled in the art
Within the technical scope of the present application, it can still modify to technical solution documented by previous embodiment or can be light
It is readily conceivable that variation or equivalent replacement of some of the technical features;And these modifications, variation or replacement, do not make
The essence of corresponding technical solution is detached from the spirit and scope of the embodiment of the present application technical solution.The protection in the application should all be covered
Within the scope of.Therefore, the protection scope of the application shall be subject to the protection scope of the claim.