Background
With the development of hardware technology, image acquisition devices are more and more popular, and when these images are distributed and communicated through public networks, the demand for encryption of private contents is increasing. The image encryption hides visual information through an algorithm, and data security is protected. The evaluation of the image encryption effect can evaluate the effectiveness of the encryption method, optimize the selection of algorithm parameters and improve the encryption scheme. The effectively encrypted image should exhibit a uniform distribution of pixel values and a chaotic detailed state. For the characteristics, the objective encryption effect evaluation method usually calculates the similarity degree between the encrypted image and white noise or random distribution, and the current main methods are as follows:
such as S.Chapaneri, R.Chapaneri, and T.Sarode, "Evaluation of a genetic map Systems for image encryption". in Proceedings of the International Conference on Circuits, Systems, Communication and Information Technology Applications (CSCITA' 14), pp.59-64, IEEE, Mumbai, India, April 2014. The shannon information entropy of the gray value distribution of the ciphertext image is used as an encryption effect evaluation standard, the gray value one-dimensional distribution of the ciphertext image is counted, the probability space is regarded as the description of the information source, and then the shannon information entropy of the information source is calculated. The method does not consider the relation between adjacent pixels, and cannot estimate the encryption effect of the encryption algorithm with disturbed pixel positions.
Such as a.h.m.ragab, o.s.fall alah, a.y.noaman, and k.w.magld, "Encryption quality evaluation of robust textual block cipher for digital imaging". International Journal of Recent Technology and Engineering, vol.2, No.6, pp.4-9,2014. statistical gray value distributions of plaintext image and ciphertext image, calculate the degree of similarity of these two probability spaces, and evaluate the Encryption quality. This method requires information from the plaintext image, but also does not allow an estimation of the encryption effect of the encryption algorithm with a disturbed pixel position.
Disclosure of Invention
Aiming at the encrypted image, a two-dimensional image matrix is converted into a one-dimensional binary sequence by utilizing block scanning and twice quantization, the result of the gap inspection is calculated as an image encryption quality evaluation standard, plaintext image information is not required, and various image encryption schemes can be evaluated.
In order to achieve the purpose, the invention adopts the following technical scheme:
the method comprises the following steps:
the method comprises the following steps: reading in the encrypted image file to obtain a two-dimensional image data matrix;
step two: converting a two-dimensional image data matrix into a one-dimensional image data vector by utilizing block scanning;
step three: uniformly quantizing element values in the one-dimensional image data into N grades, and converting the N grades into one-dimensional vectors of integers with the element values in a [1, N ] interval; wherein N is an integer greater than 1;
step four: inputting a threshold value t, and binarizing element values in the one-dimensional vector to obtain a binarized vector with element values in a set {0,1 };
step five: regarding 0 in the binary vector as a gap between 1, counting the occurrence frequency of gaps with different lengths in the whole vector, calculating the gap observation probability, and arranging the gap observation probabilities in ascending order according to the gap length j to obtain an observation probability vector;
step six: calculating prior probabilities of gaps with different lengths in an ideal randomly distributed binary vector, and arranging the prior probabilities in ascending order according to the gap length j to obtain a prior probability vector;
step seven: and calculating the chi-square distance between the observation probability vector obtained in the fifth step and the prior probability vector obtained in the sixth step, and taking the chi-square distance as a quantized image encryption effect evaluation result to finish image encryption effect evaluation based on gap detection.
Further, in the first step, the rows of the two-dimensional image data matrix correspond to the width of the encrypted image size, the columns correspond to the height of the encrypted image size, and the elements in the two-dimensional image data matrix correspond to the pixel points of the image, and the value range is [0, 2]L-1]Where L is the pixel grayscale depth.
And further, converting the two-dimensional image data matrix into a one-dimensional image data vector in the second step, namely dividing the two-dimensional image data matrix into non-overlapping blocks, scanning element values in each block, and connecting the scanning results of each block in sequence to complete the conversion from the two-dimensional image data matrix to the one-dimensional image data vector.
Further, scanning the element values in the two-dimensional image data matrix in each block in a scanning mode of a progressive scanning mode, a column-by-column scanning mode, a zigzag scanning mode or a clip-type scanning mode; the value range of the elements in the one-dimensional image data vector is [0, 2]L-1]L is the pixel gray scale depth.
Further, in step five, assuming that a gap with a gap length of j occurs together c
jNext, if the longest gap value is J, the observation probability of the gap with the gap length J is:
then all o are arranged in ascending order of gap length j
jObtaining an observation probability vector O ═ O
1,o
2,...,o
j,...o
J]。
Further, in the ideal randomly distributed binarization vector of the step six, a prior probability calculation formula for the occurrence of gaps with different lengths is as follows:
wherein ejIs the prior probability of the gap with the gap length j, t is the threshold value selected during binarization, and all e are arranged according to the ascending order of the gap length jjObtaining a prior probability vector E ═ E1,e2,...,ej,...eJ]。
Further, the chi-square distance in the seventh step is calculated by the following formula:
wherein o isjIs the probability of observation of a gap with a gap length of j, ejIs the prior probability of a gap having a gap length j.
Compared with the prior art, the invention has the following beneficial technical effects:
according to the method, the encrypted ciphertext image is converted into a one-dimensional sequence by utilizing block scanning, local neighborhood pixel distribution of the image is considered, neighborhood information of the image is reserved, and the method is favorable for evaluating the encryption effect of the whole image; when the elements of the one-dimensional sequence are converted into binary elements, twice quantization is adopted, more original information can be stored, and the threshold value can be adjusted according to specific conditions. The encryption effect evaluation method provided by the invention considers the characteristics that the huge data volume of image signals and the ciphertext image are close to the noise distribution, does not need plaintext image information, can evaluate various different types of image encryption schemes, has simple parameter selection, easy realization and adjustment of the calculation process and high evaluation speed.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
The invention provides an image encryption effect evaluation method based on gap detection, which is used for evaluating the effect of image encryption and comprises the following steps:
the method comprises the following steps: reading in the encrypted image file to obtain a two-dimensional image data matrix, wherein the rows and columns of the matrix correspond to the width and height of the image size, and the elements in the matrix correspond to the pixel points of the image, and the value range is [0, 2]L-1]Where L is the pixel grayscale depth.
Step two: dividing the two-dimensional image data matrix into non-overlapping small blocks according to a certain rule; scanning element values in a two-dimensional image data matrix by using the same rule in each small block, wherein the scanning can be performed by line-by-line, column-by-column, Z-shaped or clip-shaped needle type scanning, and the scanning can keep neighborhood information of a local area of an image; the scanning results in the small blocks are connected in sequence to form a long one-dimensional vector, so that the two-dimensional image data matrix is converted into a one-dimensional image data vector, and the value range of elements in the one-dimensional image data vector is [0, 2]L-1]Is an integer of (1).
Step three: the element values in the one-dimensional image data are uniformly quantized into N levels, for example, 10 levels, and the element with the value a becomes 10a/2 after quantizationLA rounded up value; thus, the one-dimensional image data is converted to an element value of [1,10]]A one-dimensional vector of integers within the interval.
Step four: inputting an integer threshold value t in the range of [1,10], binarizing element values in the one-dimensional vector, wherein the element values larger than t are binarized to be 1, and 0 is taken when the element values smaller than or equal to t are binarized; thus, a binary vector with the element value in the set {0,1} can be obtained;
step five: and (4) regarding 0 in the binary vector as a gap between 1, counting the frequency of the gaps with different lengths in the whole binary vector, and calculating the probability, namely the gap observation probability. Assuming that a gap of length j occurs together cjSecond, if the longest gap value is J, then the observed probability of a gap with length J is
Then all o are arranged in ascending order of gap length jjObtaining an observation probability vector O ═ O1,o2,...,oj,...oJ];
Step six: calculating prior probability e of gaps with different lengths in ideal randomly distributed binary vectorsjAnd arranging according to the gap length j in an ascending order to obtain a prior probability vector. In the case where N is 10, the calculation formula is:
ej=(0.1t)j(1-0.1t)2
wherein ejThe prior probability of a gap with the length of j is shown, t is a threshold value selected during binarization, and j is the gap length. Arranging all e in ascending order of gap length jjObtaining a prior probability vector E ═ E1,e2,...,ej,...eJ];
Step seven: and calculating the chi-square distance between the observation probability vector obtained in the fifth step and the prior probability vector obtained in the sixth step to serve as an encryption effect evaluation result of the quantized image. Is calculated by the formula
The present invention will be described in further detail with reference to fig. 2(a) to 2(d) and specific examples:
firstly, the ciphertext image is read in to obtain a two-dimensional image data matrix, all of the ciphertext images in fig. 2(a) to 2(d) are 124 × 124, and the depth L is 8, so that the number of rows and columns of the two-dimensional image data matrix is 124 × 124, and the range of values of elements is an integer in [0,255 ].
And secondly, converting the two-dimensional image data matrix into a one-dimensional image data vector by utilizing block scanning. Here, 8 by 8 patches are used, and local neighborhood information of the image is maintained within each patch using column-by-column scanning. If the size of the two-dimensional image data matrix is not divisible by the block size, zero padding may be applied after the last column and the last row.
And thirdly, uniformly quantizing the element values in the one-dimensional image data into 10 grades, and converting the element values into one-dimensional vectors of integers in the interval of [1,10 ]. For the images in fig. 2(a) to 2(d), since the depth L is 8, the element whose value is in the range of [0,25] is quantized to 1, and the element whose value is in the range of [26,52] is quantized to 2 … … and the element whose value is in the range of [231,255] is quantized to 10.
Fourthly, when the input threshold value t is 5, binarizing the element value in the one-dimensional vector, and if the element value is more than 5, obtaining a value of 1 after binarization; and if the element value is equal to or less than 5, the value is 0 after binarization. After processing, obtaining a binary vector with element values in a set {0,1 };
and fifthly, regarding 0 in the binary vector as a gap between 1, counting the occurrence times of gaps with different lengths in the whole vector, calculating the probability of the gaps, and arranging the gaps according to the ascending order of the lengths of the gaps to obtain an observation probability vector. As shown in fig. 2(a), the number of occurrences of a gap having a length of 0 is 5758, and the observation probability is 0.7998.
And sixthly, calculating prior probabilities of gaps with different lengths in the ideal randomly distributed binary vector, and arranging the prior probabilities in an ascending order according to the lengths of the gaps to obtain a prior probability vector. As in fig. 2(a), the gap prior probability of 0 is 0.25 for a length of 0.
And seventhly, calculating the chi-square distance between the two vectors obtained in the fifth step and the sixth step as the quantized image encryption effect evaluation result. As in fig. 2(a), the final quantitative assessment result is 1.2638. The closer this value is to zero, the closer the observed probability vector is to the prior probability vector, i.e., the better the encryption.
Fig. 2(a) is a meaningful plaintext image, and as the number of encryption rounds increases, the ciphertext image becomes more disordered and more appears to be similar to white noise, compared to fig. 2(b) which is obviously more regular than fig. 2(c) and fig. 2(d), fig. 2(c) is more textured than fig. 2(d), and thus the encryption effect of fig. 2(d) should be the best. With the quality evaluation method provided by the invention, the quantitative evaluation results of fig. 2(a), fig. 2(b), fig. 2(c) and fig. 2(d) are 1.2638, 0.9173, 0.2321 and 0.2017 respectively, and the encryption effects are arranged in the order of good to bad in fig. 2(d), fig. 2(c), fig. 2(b) and fig. 2(a), which are consistent with the human visual sense.
The image encryption destroys the neighborhood correlation of the image signal, and the ciphertext image is presented as a meaningless noise image as much as possible. The encryption effect evaluation method provided by the invention considers the characteristics that the huge data volume of image signals and the ciphertext image are close to the noise distribution, and does not need reference image and plaintext image information when evaluating the encryption effect. Various different types of encryption schemes can be evaluated.
The image signal is converted into a one-dimensional binary vector to count the probability distribution of voids of various lengths. In the process of converting the two-dimensional matrix into the one-dimensional vector, the block local scanning method provided by the invention considers the local neighborhood pixel distribution of the image, can store local information and is beneficial to evaluating the encryption effect of the whole image. The size of the block and the local scanning method can be flexibly selected according to actual conditions.
In the conversion process, the invention adopts twice quantization, so that more original information can be stored, and the threshold value can be set according to specific conditions during binarization.