Image Hashing Algorithm Based on Mirror Flipping and a Three- Dimensional Space Angle

In order to make full use of image flipping information to get comprehensive image features and improve the distinguishing performance of hash algorithm, this paper proposes a new image hashing algorithm based on mirror flipping and a threedimensional space angle. Firstly, the original image is preprocessed and then combined with mirror flipping image to obtain the new luminance component and opposite color components. Then, we combine new luminance component with the different sizes of structural elements to construct morphological features. The new opposite color components are used to construct a three-dimensional space. The angle between vectors formed by the pixels in the three-dimensional space is computed to construct the space angle features. Finally, the morphological features and space angle features are combined and disturbed to form the final hash sequence. Simulation results show that the algorithm has good security and tamper image recognition accuracy. Compared with some existing algorithms, it has better image classification performance and shorter computation time.


Introduction
With the rapid development of Internet technology, multimedia information security is becoming more and more important in people's life. Image hashing is an important part of multimedia information security. Nowadays, individuals have the ability to easily and rapidly process the images on computers, mobile phones, and other digital devices. In addition, the modern image editing tools allow the individuals to temper the content of images. These changes are very hard to be distinguished by the naked eye. The analysis for detecting the tampered parts of the image requires expertise and time. Thus, there is a need to devise methods that allow the concerned individuals to assess the image authenticity and detect the changes. The image hashing technology is an important and effective method to solve the aforementioned problem.
Image hash refers to a unidirectional mapping of an image to a sequence of numbers. These numbers can be binary or decimal. The image hashing should be robustness, discrimination, and key secure. The robustness means that the hash sequence of the original image after processing should preserve the digital content and should be the sim-ilar to the hash sequence of the original unprocessed image. The discrimination means that the hash sequences of different images should be significantly different when subject to same hash mapping; i.e., the probability of collision of hash sequences for different images should be very small. The key security refers to the failure of an attacker to obtain the correct hash sequence without knowing the correct key. These features enable the image hashing to be applied to image retrieval, image classification, and image tamper detection. The previous hashing algorithms use twodimensional plane features or global features of a threedimensional space. All of them have good performance. But it is noticeable that the algorithms based on a threedimensional space may ignore some three-dimensional local features. And image mirror flipping has more useful image information. Therefore, image classification performance of existing image hash algorithms can be improved. In this paper, we combine the image flipping of the image component with the local features of the three-dimensional space to construct the hash sequence. This method makes full improvement of the classification performance of hashing algorithm.

Related Work
There are different methods proposed in recent literature for performing image hashing. These methods are majorly divided into two categories, namely, spatial domain methods and transform domain methods.
2.1. Spatial Domain Methods. In [1], Tang et al. proposed an image hashing algorithm based on local color features. The proposed technique extracts are featured from HSI space and YCbCr space, in order to obtain image hashing. The algorithm proposed in [1] is robust to most of the image processing operations; however, the algorithm performs poorly for the rotated images. The authors in [2] presented an algorithm that is based on opposite colors and quadtree decomposition of image hashing algorithm. The proposed algorithm effectively localizes the tampers in the image. The authors in [3] proposed an image hashing scheme that combines color vector angle (CVA) and Canny operator. The features obtained from the CVA and the edges are combined to compute the hash sequence. This algorithm performs efficiently against image rotation, brightness contrast adjustment, and other attacks. However, the discrimination of this technique is not ideal. Qin et al. in [4] proposed an image hashing technique based on hybrid structure of the color image perception. The proposed algorithm performs image preprocessing by performing image normalization, Gaussian low-pass filtering, and singular value decomposition (SVD). After preprocessing, the algorithm performs edge detection and computes the CVA. The edge information and the CVA are used to obtain the hash sequence. It is noticeable that as compared to the aforementioned CVA-based technique, this algorithm showcases better robustness and discrimination. However, this method is less robust to the changes in brightness. Tang et al. proposed an image hashing technique based on ring segmentation and invariant vector distance [5]. This technique extracts statistical features from the image segmentation ring to construct the image hashing, as the features extracted from within the image segmentation ring are invariant to rotation. The robustness of this algorithm can be further improved. In [6], Tang et al. proposed an image hashing technique that makes use of visual attention model and the invariant moments. In this method, the visual significance model and invariant moments are used to construct the hash sequence. This technique performs effectively against the conventional attacks, such as brightness and contrast, but performs poorly against image rotation and cropping attacks. In [7], Zhao et al. proposed an image hashing algorithm based on Zernike moments and significant regions. The method proposed in [7] performs authentication effectively and can be used for tampering and positioning. In [8], Davarzani et al. proposed a hashing scheme based on the central local symmetric binary mode (CS-LBP) and SVD. This method is robust against brightness and JPEG compression. In addition, this technique has the capability to locate tampering. However, this algorithm performs poorly against rotation.

Transform Domain Methods.
In [9], Tang et al. proposed a robust image hashing based on CVA. This algorithm first extracts the CVA from the input image and then computes the pixel histogram from within the maximum inscribed circle of the image. The extracted information is then combined with the discrete cosine transform (DCT) for generating the image hashing. This algorithm is robust and secure; however, the different color may generate same CVA which affects the performance. In [10], Qin et al. proposed an image hashing technique that uses significant structural features. This technique performs efficient edge detection. On the basis of edge information, some nonoverlapping image blocks containing rich information are adopted. Finally, DCT is used to obtain the final hash sequence. The algorithm is secure and robust, but the scheme only uses some boundary information, and some local information may be omitted. This may lead to performance degradation. In [11], Tang et al. proposed an image hashing algorithm based on DCT and local linear embedding (LLE). This method first extracts the CVA of the image and then extracts the feature matrix on the basis of DCT. The hash sequence is computed by combining the LLE. This scheme is robust to various transformations but is not effective against rotations at large angles. In [12], Tang et al. proposed an image hashing technique that uses multidimensional scaling (MDS) analysis. In this algorithm, log-polar transform (LPT) and discrete Fourier transform (DFT) are successively applied to the image for extracting the rotation invariant feature matrix. The final hash sequence is obtained using the MDS. This algorithm is robust to rotations, but it is inefficient.
Moreover, there are some image hashing algorithms, such as algorithms based on tensor decomposition (TD) [13], methods based on Laplacian Pyramids [14], methods based on two-dimensional principal component analysis (PCA) [15], techniques based on the structure and gradient hashing algorithm [16,17], and techniques based on the cool and warm hue [18].
All the above hashing algorithms have good performance, but none of them combine the image flipping, twodimensional plane features, and three-dimensional space local features of image components to construct the hash sequence. In this work, we propose an image hashing algorithm based on the mirror flipping and a threedimensional space angle. The proposed algorithms significantly consider the two-dimensional global features of luminance and opposite colors of three-dimensional space local features. The algorithm combines mirror flipping for the image components in a three-dimensional space of each small build specific three-dimensional space coordinates and extracts the features of a three-dimensional space angle. The proposed algorithm shows robustness and discrimination. In addition, the proposed algorithm shows the key security. The contributions of this work are as follows.

Image Hashing Algorithm Based on Mirror
Flipping and a Space Angle

Image Preprocessing.
At first, the input image I is resized to N × N by applying bilinear interpolation. This allows us to generate the hash sequence with same length for each input image. Then, we smooth the image by applying Gaussian low-pass filter. This is done in order to reduce the influence of noise. The resultant image I 0 is obtained for the corresponding input image I. Then, we compute the RG and BY colors [19,20] by using the following equations.
where f r ðx, yÞ, f g ðx, yÞ, and f b ðx, yÞ represent the red, green, and blue channels of RGB color space, respectively. The image I 0 is obtained after preprocessing original image and used to extract the opposite color components RG 0 and BY 0 . I 1 is I 0 after mirror flipping; I 1 is used to extract the opposite color components RG 1 and BY 1 . We add RG 0 and RG 1 to compute the opposite color component RG 2 . Similarly, add BY 0 and BY 1 to compute the opposite color component BY 2 . Finally, we transform the images I 0 and I 1 from RGB color space to YCbCr color space. The luminance Y 0 and Y 1 are extracted from I 0 and I 1 . We add Y 0 and Y 1 to compute the luminance component Y 2 .

Morphological Features.
We perform adaptive histogram equalization and luminance adjusted on the luminance component Y 2 to obtain Y 3 . Y 3 is used to perform the open operations, i.e., the construction of element specified as "diamond" and which has a distance "d" from the origin. When "d = 1", the operation on Y 3 results in Y 4 . When "d = 2", the operation performed on Y 3 results in Y 5 . Y 4 subtracts Y 5 obtains Y 6 . In this process, it is called the parameter "d = 1, 2".
Finally, we divide the luminance component Y 6 into M × M nonoverlapping blocks of equal size. We compute the standard deviation S i,j of the pixels contained in each block, get the matrixS. The dimensions of matrix S are M × M. Each row of the matrix is connected to the hash sequence 3.5. Three-Dimensional Space Angle Features. Let (x, y) represent the pixel location and z represent the value of the pixel at location (x, y). Then, considering the location variables, i.e., (x, y), and the value variable, i.e., z, we can represent the image in a three-dimensional space. The RG 2 in a three-dimensional space are presented in Figure 3(a).
In this work, we divide the images RG 2 and BY 2 into M × M nonoverlapping blocks of equal size. In order to construct these images with a three-dimensional space, we consider the number of small block's rows i of the image along the x-axis, the number of small block's columns j of the image along the y-axis, and the average value of the pixels of images RG 2 and BY 2 in a small block L 1 ði, jÞ and L 2 ði, jÞ along the z-axis. Then, the coordinates of RG 2 and BY 2 images' small block in the i-th row and j-th column (i, j) in a three-dimensional space are ði, j, L 1 ði, jÞÞ and ði, j

Wireless Communications and Mobile Computing
, L 2 ði, jÞÞ. Figure 3(b) presents the coordinates of RG 2 's blocks of the image in a three-dimensional space.
The three-dimensional space angle features extracted from RG 2 are shown in Figure 4. The three-dimensional space angle features of the image are extracted from small blocks. These small blocks comprise the central pixel at location (i, j) and eight adjacent pixels. First, we estimate the coordinate of the block with position (i, j − 1) and (i, j + 1) represented by a i,j and e i,j , respectively. Then, we calculate the vector A i,j by using these two coordinates, i.e., A i,j = e i,j − a i,j . In a similar fashion, we estimate the coordinates of the little block with positions (i + 1, j) and (i − 1, j) repre-sented by b i,j and f i,j , respectively. The vector B i,j is calculated by using these two coordinates, i.e., Finally, we use the vector A i,j and the vector B i,j to calculate cos α i,j in a three-dimensional space. The

Wireless Communications and Mobile Computing
Similarly, we estimate the coordinates of the little block at (i + 1, j − 1) and (i − 1, j + 1) represented as c i,j and g i,j , respectively. The vector C i,j is computed as In the same way, we estimate the coordinates of the little block at (i + 1, j + 1) and We use vector C i,j and vector D i,j to compute cos β i,j in a three-dimensional space as follows: The Finally, we add the two matrices E and F to obtain the resultant matrix J. The dimensions of matrix J are ðM − 2Þ × ðM − 2Þ. Each column is successively connected to a vector JðnÞ. And in the same way, a threedimensional space angle eigenvector J 1 ðnÞ is extracted in BY 2 . We add JðnÞ and J 1 ðnÞ to obtain J 2 ðnÞ and multiply every number in J 2 ðnÞ × 10 to get the hash sequence H 2 ðnÞ, where 1 ≤ n ≤ ðM − 2Þ 2 .

Experimental Results and Analysis
The parameters that are used in this study and for performing simulations include 3 × 3 Gaussian low-pass kernel with normalized size N = 256 and standard deviation 1, d = " 1, 2 " . The numbers of image subblocks are M × M = 16 × 16 = 256. Thus, the hash length is L H = 2M 2 − 4M + 4 = 452 decimal numbers. All experiments were implemented with MATLAB 2018b on a computer, which the CPU is Inter Core i5-8300H with 8 GB memory and Window 10 operating system.  Figure 3: (a) The RG 2 images in a three-dimensional space. (b) The coordinates of RG 2 's blocks of the image in a three-dimensional space. Figure 4: The three-dimensional space angle features extracted.

Wireless Communications and Mobile Computing
4.1. Robustness Experiment. In order to evaluate the robustness of the image hashing algorithm proposed in this work, we use 20 images as test samples. Figure 5 represents one of the sample images. We also generate similar images for each test according to the type of attack as presented (Table 1); there are 59 attack samples for each image as test samples of similar images. We use the proposed algorithm to compute the hash sequence of the original image. Similarly, we also compute the hash sequence of a closely similar image. Then, we calculate the Euclidean distance between the two resultants. The Euclidean distance charts are drawn according to attack category. The simulation results for assessing robustness of the proposed algorithm are presented in Figure 6. It is evident from Figure 6 that the JPEG compression, brightness adjustment, contrast adjustment, salt and pepper noise, image scaling, watermark embedding, gamma correction, speckle, and Gaussian filtering have a small fluctuation range in the curve. The Euclidean distance in all cases is less than 165. In the simulations performed to test the algorithms robustness against the rotation attack, we observe that the distance of the rotation attack within 1°of image rotation is small. The distance of the rotation attack gradually increases with the increase in the angle. This is because the proposed algorithm blocks the image, thus making it more sensitive to the rotation attack. In Table 2, we present the statistical results of Euclidean distance for 20 images under different attacks. The presented cases include JPEG compression, brightness adjustment, contrast manipulation, salt and pepper noise, image scaling, watermark embedding, rotation, gamma correction, speckle, and Gaussian filtering. In Table 3, we give the average mean square error (MSE) and peak signal-to-noise ratio (PSNR) values between the original images of five test images and the images generated after the corresponding maximum parameter attack in each attack. For all these attacks, except rotation, the maximum Euclidean distance is less than 165 and the mean and variance are less than 88. The maximum and average Euclidean distance for rotation attack is 226 and 318. The results show that the maximum value of the Euclidean distance is 165 except the rotation attack. This indicates that the proposed algorithm is robust against all types of attacks except large angle rotation attacks, such as JPEG

Discrimination Experiment.
We download 1000 images from Ground Truth database [21] and VOC2007 database [22] for performing discrimination analysis of the proposed algorithm. The hash sequences of 1000 images are computed by using the algorithm proposed in this work. Then, we calculate the Euclidean distance between these 1000 images hash sequences. We generate a total of C 2 1000 = 499, 500   Table 4.
Each downloaded image is used to generate 20 similar image pairs. The Euclidean distance between the similar generated images and the original image is calculated. There are ð21 × 20Þ/2 × 1000 = 210000 pairs of similar images. The distribution of Euclidean distances for similar and different images is presented in Figure 7 for different Euclidean distances and ordinate for the different frequencies of Euclidean distance; find the minimum Euclidean distance between different images by a calculation value of 274.06, similar image on the maximum Euclidean distance of 344.96, and similar and different images of Euclidean distance intersection between 274.06 and 344.96. In order to obtain the optimal value for distinguishing similar image pairs from different image pairs in this work, we use collision rate and error detection rate to perform analysis. The collision rate and error detection rate are computed as follows: where N C and N D represent the number of different image pairs detected as similar image pairs and the total number of different image pairs, respectively. Similarly, N E and N S represent the number of similar image pairs detected as different image pairs and the total number of similar image pairs, respectively. P C and P E represent the collision rate and error detection rate, respectively. The computation results are presented in Table 5. The results presented in Table 5 reveal that the threshold value is 322, and at this point, the algorithm has a low collision rate and a low error detection rate, with good discrimination.

Key-Dependent Security.
For any secure hashing algorithm, each different key results into a different hashing sequence; i.e., the probability of sequence collision is minimum. Figure 8 illustrates the key security of the hash algorithm in this work. The x-axis represents the index of 1000 wrong keys, and the y-axis represents the Euclidean distance. It is evident from the figure that the minimum value of Euclidean distance and the average value of all error keys are 345.2521 and 376.8121, respectively. It is noticeable that both of these quantities are significantly greater than the threshold value of 322 as discussed above. The threshold is presented in the red line in Figure 8. This means that it is difficult for an attacker to generate the correct hash sequence without the correct key. Therefore, the hash algorithm proposed in this work satisfies the security requirements.

Performance Comparison of Different Blocks, Different
Mirror Flipping, and Different Components. In order to analyze the influence of the number of blocks on the performance of the algorithm, we use receiver operating characteristics (ROC) curve to compare the performance, which mainly includes robustness and discrimination. We set a series of different thresholds to obtain a series of false positive rate (P FPR ) and the true positive rate (P TPR ) in order to draw the ROC curve. The simulation results are presented in Figure 9. The abscissa represents the P FPR and ordinate represents the P TPR . The P FPR and P TPR are computed as follows: where n 1 represents the number of different image pairs misjudged as similar image pairs, n 2 represents the number of similar image pairs correctly judged, and N 1 and N 2 denote the total number of different image pairs and similar image pairs, respectively. The horizontal axis represents the discrimination performance, while the vertical axis represents the robustness performance. The closer the ROC curve is to the upper left corner, the better is the performance of the proposed algorithm.
In the simulations, we use 1000 images for discrimination test. According to the attack settings presented in Table 4, we generate visually similar images. Each image is used to generate 20 similar images. Therefore, the total number of similar image pairs is 210,000, and the number of different image pairs is 499,500. When the image is divided into 8 × 8, 16 × 16, and 32 × 32 blocks, the resultant hash code length of the proposed algorithm is 100 decimal numbers, 452 decimal numbers, and 1924 decimal numbers, respectively. When the image is divided into 32 × 32 blocks, the resultant hash sequence length is too long. Therefore, in the simulations, we only evaluate the performance of hash algorithm whose image is divided into 8 × 8 blocks and image flipping along the vertical axis 16 × 16 blocks and image flipping along the vertical axis 16 × 16 blocks, but the algorithm does not add the image component after mirror flipping (NAF), flipping the up and down sides of the preprocessed image along the horizontal axis (UDH), and the image component L in the lab space is used to replace the brightness component Y. As presented in Figure 9, the ROC curve of the hash algorithm divided into 16 × 16 blocks is closer to the upper left corner than other hash algorithm. Thus, the performance of the former is better than the latter. In this work, the hash algorithm divides the image into 16 × 16 blocks and image flipping along the vertical axis, which is an effective choice for the balance between robustness and discrimination.

Performance Comparison of Different Parameters.
In order to analyze the influence of the parameters on the performance of the proposed algorithm, we use ROC curve to compare the performance. This major component includes robustness and discrimination. A series of different thresholds are set to obtain a series of P FPR and the P TPR . These computed parameters are then used to draw the ROC curve. The simulation results are presented in Figure 10. In Figure 10, the abscissa represents the P FPR and the ordinate represents the P TPR . The computations     (11) and (12).
In the experiment, we use 1000 images for performing discrimination tests. According to the attack situations presented in Table 4, we generate visually similar images. Each image is used to generate 20 similar images. Therefore, the total number of similar image pairs is 210,000, and the number of different image pairs is 499,500. In this section, we discuss the influence on the performance of the algorithm when the parameter "d" takes different values, where "d" represents the distance from the origin of elements to the four angles of the diamond. In this section, we compare three pairs of parameters: d = " 1, 2 " , d = " 2, 3 " , and d = " 3, 4 " , respectively. As presented in Figure 10, the ROC curve of the hash algorithm with a parameter set d = " 1, 2 " is closer to the upper left corner as compared to the hash algorithm with parameter sets d = " 2, 3 " and d = " 3, 4 " . In this work, the hashing algorithm chooses to set the hyper pixel segmentation parameter d = " 1, 2 " , which is a good choice to balance between robustness and discrimination.

Performance Comparison of Different Algorithms.
We compare the performance of the image hashing algorithm proposed in this work with the previous works presented in literature, such as CVA-Canny algorithm [3], the Ring algorithm [5], TD algorithm [13], LP algorithm [14], and color structure algorithm [17]. The parameters of the comparison are equivalent to the parameter values selected in the respective published papers. As shown in Table 6, the hash length of the algorithm compared is 40 decimal numbers, 440 binary numbers, 96 binary numbers, 1024 decimal numbers, and 354 binary numbers, respectively. The hash code length of the proposed hash algorithm is 452 decimal numbers.
In this simulation, the hash algorithm is used to extract the hash sequences of similar image pairs and different image pairs. The Euclidean distance between these image pairs is computed. The attack settings for similar images are also kept the same as presented in Table 4. There are 210,000 similar image pairs and 499,500 different image pairs. A series of different thresholds are set to obtain a series of P FPR and the P TPR to draw the ROC curve. The simulation results are presented in Figure 11. It is evident that the curve of the proposed algorithm in this work is closer to the upper left corner than the ROC curves of other algorithms. This indicated that the classification ability of the proposed algorithm is better as compared to previous algorithms presented in literature.
In this work, the luminance component Y is extracted and the color components RG and BY are partitioned for feature extraction. Therefore, the hash sequence length is relatively long. However, the average computation time of this algorithm is only longer than the color structure and LP algorithm, which is superior to the remaining comparison algorithms.

Tamper Detection Experiment.
When a part of the image is tampered, the Euclidian distance between the tampered image and the hash sequence of the original image should be between the distance from the similar image and the distance from the different image. In order to verify the tamper detection capability of the proposed algorithm, we obtain 15,000 images from VOC2012 database [23]. Each image in the dataset is tampered to perform simulations. Figure 12 presents an example of a tampered image. The Euclidean distance distribution diagram of similar image pairs, tampered image pairs, and different image pairs is presented in Figure 13(a). The x-coordinate T 1 at the intersection of similar image pairs and tampered image pairs is 136, and the x-coordinate T 2 at the intersection point of tampered image pair and different image pair is 301. We select T 1 and T 2 as thresholds; when the distance between the detected image and the original image is less than T 1 ,

12
Wireless Communications and Mobile Computing the target image is regarded to be similar, and when the distance between the image to be detected and the original image is greater than T 1 and less than T 2 , the image is regarded as tampered image. When the distance between the image to be detected and the original image is greater than T 2 , the image to be detected is regarded as a different    Figure 14 shows several pairs of contrast image pairs. Similarly, Table 7 shows the Euclidian distance and relationship between several pairs of contrast image pairs.
The contrast image includes similar images, tampered images, and different images, and the relationship between the original image and the contrast image can be judged on the basis of Euclidean distance. It is evident that the relationship between the two images is accurately judged according to the Euclidean distance between the original 14 Wireless Communications and Mobile Computing image and the comparison image. This indicates that the algorithm presented in this work has good tampering detection performance. Just to prove the advantage of mirror flipping, we present the performance of the algorithm with and without mirror flipping. The database used for this simulation is the same as above. In this work, mirror flipping is not performed in the step of "mirror flipping" in Figure 1. The luminance components extracted from two identical images superimposed together, and the opposite color components are extracted from two identical images superimposed together for performing calculation. In this way, the variables are controlled and the comparison is more reliable. The distribution diagram is shown in Figure 13(b). The x -coordinate T 1 at the intersection of similar image pairs and tampered image pairs is 111. The x-coordinate T 2 at the intersection point of tampered image pair and different image pair is 310. We select T 1 and T 2 as thresholds. When the distance between the detected image and the original image is less than T 1 , the image to be detected is judged to be similar. When the distance between the image to be detected and the original image is greater than T 1 and less than T 2 , the image to be detected is judged as tampered image. When the distance between the image to be detected and the original image is greater than T 2 , the image to be detected is judged to be different image. The simulation results have shown that the proposed algorithm has an accuracy of 72.34%, 96.60%, and 99.99% without adding mirror flipping in the case of similar images, tampered images, and different images, respectively.
As shown in Table 8, comparing algorithm with join mirror flipping that did not join the mirror rotating algorithm in recognition tamper or different images in accuracy is similar, but the recognition similar image accuracy of 72.34% is significantly less than the join mirror flipping to identify similar image accuracy of 80.26%, so this article chooses to mirror flipping algorithm.

Conclusions
This work proposes an image hashing algorithm based on mirror flipping and space angle. The new luminance component and the opposite color component are obtained by mirror flipping. We extract the morphological features by the new luminance component. In addition, the space angle features are also extracted by the new opposite color component. Finally, the hash sequence is obtained by combining the morphological and space angle features. Simulation results show that the proposed algorithm is robust against brightness attack, contrast attack, and other attacks. The ROC curve shows that the algorithm presented in this work has better image classification performance than the previous algorithms proposed in literature. In addition, the proposed algorithm has good key security and good detection accuracy of tampered images.
But the algorithm in this paper has poor robustness to large angle rotation and can only detect a large range of tampering for the time being. So, our future work will focus on how to improve robustness to large angle rotations, reduce the storage space of hash sequence, and locate tampering region.