Abstract

Safeguarding the identity of people in photographs or videos published through social networks or television is of great importance to those who do not wish to be recognized. In this paper, a face detecting and coding system is designed with the goal of solving this problem. Mathematical models to generate chaotic orbits are deployed. One of them applies the diffusion technique to scramble the pixels of each face while another implements the confusion technique to alter the relation between plain text and ciphered text. Afterward, another two orbits are utilized for the steganography technique to modify the least significant bit (LSB) to conceal data that would allow authorized users to decipher the faces. To verify the robustness of the proposed encryption algorithm, different tests are performed with the Lena standard image, such as correlation diagrams, histograms, and entropy. In addition, occlusion, noise, and plain image attacks are performed. The results are compared with those of other works, and the proposed system provided high sensitivity at secret key and a large space for the encryption keys, good speed for ciphering, disorder in the cryptogram, security, data integrity, and robustness against different attacks.

1. Introduction

Facial recognition techniques are widely used in searching for missing people and enable their hasty identification from information stored in databases. For example, the OpenFace tool performs this task by implementing neural networks [1]. A facial-characteristics extraction dictionary was also developed to enhance the identification process [2]. In addition, a technique fusing two types of virtual sampling with mirror faces and symmetrical faces, added to the original one, was proposed to correct the issue with insufficient samples in the training period and enhanced the recognition rate [3]. However, the detection of biometric characteristics is not always deployed for legal activities: ill-disposed users can access data from other users through information and communication technologies (ICT) in order to, subsequently, harm them.

For this reason, it is crucial to implement techniques to safeguard and protect a person’s identity, such as a system in which biometric data is encrypted and then concealed in images by implementing steganography techniques [4]. In other studies, color palettes were exchanged to render zones unrecognizable because when regular palettes are employed, there is a better chance for an attacker to decipher them [5]. Furthermore, fingerprints and facial characteristics were embedded in images through watermark methods [6]. A cryptosystem deploying palm-vein and iris biometrics was proposed. This system extracted characteristics to be encrypted with the Blowfish symmetric algorithm [7]. Another study utilized the Eigenvalue algorithm to identify faces and generate keys from the coding of fingerprints and a header. Later, steganography was employed to conceal the key in the face and, finally, scramble it [8].

For cryptography, chaotic systems can be broadly implemented to encrypt biometric characteristics due to their intrinsic properties, such as ergodicity, mixture, and sensitivity to their parameters and initial conditions [9]. There are studies in which chaotic orbits generated by mathematical models were applied to code data and information [1013]. It is also possible to employ the technique proposed by Pecora and Carroll in which two chaotic systems can be coupled [14] to encrypt and send data safely once they have been synchronized [15]. Additionally, the logistic map was implemented with a key produced from the characteristics of the iris to cipher [16]. Furthermore, a scheme to encrypt fingerprints to prevent identifying theft was presented. This scheme applies basic encryption techniques, i.e., diffusion and confusion, by employing the hyperchaotic Rössler system [17].

In this research, a system to detect and code faces in videos or photographs is proposed with the purpose of safekeeping identities and preventing them from being easily identified. The proposed technique allows the environment surrounding the faces to remain visible, affording the opportunity for transmission through open television or social networks. Afterward, users can recover the faces as long as they have the keys that were utilized for encryption and steganography. The system detects faces, applies steganography, and implements a new robust and effective encryption system. The novel system employs a key space that can be doubled depending on the security that will be implemented. It also possesses excellent properties against different types of attacks.

The remainder of this paper is organized as follows. In Section 2, the mathematical models implemented in this system are explained, while in Section 3, the face detecting and coding operation system is detailed. Section 4 presents the decryption method. Section 5 contains the results of the tests that were performed. Finally, Section 6 presents the conclusions of this research.

2. Chaotic Mathematical Models

2.1. Logistic Map

This is a simple discrete time system with a nonlinear dynamic that exhibits chaotic behavior and can be expressed by where the dynamic variable is and is the control parameter that, when varied, causes the system to show linear, periodic, or chaotic behavior when [18, 19].

2.2. Sine Map

This nonlinear discrete system displays chaotic behavior similar to that of the Logistic map, except that this system involves a sine function with entry values . This is defined the following equation.The dynamic variable is and exhibits chaotic behavior when the control parameter is [18].

3. Face Detecting and Coding System

The proposed system can be implemented to detect and code faces in videos. The videos were divided into the frames that comprise them and each was addressed separately. Afterwards, the pixel values were extracted. These values ranged between 0 and 16777215 in accordance with those corresponding to 24 bits used for red, green, and blue (RGB) combinations and eight bits for each color. This process is presented in Figure 1.

The system operation schematic is shown in Figure 2 and can be explained as follows:(1)Face detection and extraction from each frame occur first.(2)Face encryption occurs next.(3)The cryptogram is then embedded into the original frame.(4)A message is prepared with the necessary information for decoding.(5)Steganography that modifies the least significant bit (LSB) is implemented to conceal the data for face decoding.

3.1. Face Detection and Extraction Phase

Face detection was performed with the OpenCV Library, which traces specific objects such as frontal faces, eyes, and full bodies. Once the face has been located, the selection data were generated. Selection data contains the pixel coordinates from the selection’s initial point, in addition to face width and height. This procedure is illustrated in Figure 3.

Later, the ImageIO Library was employed to cut out the face according to the selection data.

3.2. Encoding Phase

This algorithm requires two orbits for its proper performance, and these orbits can be generated with any chaotic model desired. In this paper, logistic map equation (1) was implemented to apply confusion to the face pixels, while sine map equation (2) was deployed to apply diffusion to the pixels.

Nomenclature Handled for Encryption: The original face selected from the image or frame, in the case of processing a video.: Codified face with the proposed algorithm.

Ciphering Keys Handled for Cryptogram Generation: Number of segments into which the original face will be divided., : Parameter and initial condition employed to resolve logistic map discrete system, (1), in its chaotic regimen., : Parameter and initial condition deployed to resolve sine map, (2), when the latter generates chaos.

In the following section, the phases implemented to codify the original face are explained.

3.2.1. Confusion Phase

In this phase, the integer values of each pixel were changed by others generated from a chaotic orbit. The steps used in the procedure are as follows:(1)Calculate the number of pixels inside by multiplying the width and height of the image. The result is stored under the variable :(2)Retain in the array named of length the values of all pixels from consecutively. These values range from 0 to 16777215 according to their color intensity:(3)Resolve logistic map equation (1) by implementing the values of the ciphering keys ( and to generate a number between and , and the result is assigned to the variable .(4)Store in the resulting value by rounding off the product of multiplying by :(5)Store in the array the integer obtained by the operation between a value of and :This process is illustrated in Figure 4.(6)Repeat steps (3) through (5) for each element from the array. Upon completion, a with quantity of values is generated.

3.2.2. Diffusion Phase

In this phase, the array generated in Section 3.2.1 is fragmented into segments. Diffusion is applied to each segment, scrambling the order of their values. Once all of the parts are processed, they are reassembled to create the cryptogram.(1)Calculate the number of pixels from the array corresponding to each segment and divide (total number of elements) by :(2)Select the corresponding values from the current segment.(3)Calculate a value between and and resolve the system in (2) with its corresponding keys and . The result is stored in .(4)Round off the product of multiplying by to generate an integer between and . The result is stored in the variable :(5)Place the value of the current segment from into the location of the same segment number from the array. This process is presented in Figure 5. If it is occupied, it is important to verify whether a value has already been generated in position If it is occupied, then a vacated location is searched for by revising the previous placements in . If the beginning of the array has been reached and a position is not available. The search continues from the last position until an available location to store the value is found.(6)Rearrange all values from the current segments in the array and repeat steps (3) to (5).(7)Repeat steps (2) to (6) for each segment until all segments have been scrambled. Afterward, assemble the c   and arrange the segments of generated in step (6) consecutively. This process is shown in Figure 6.

3.3. Reincorporation of the Cryptogram in the Photograph

To insert the coded faces, a function called the ImageIO Library was implemented. This function takes the original image, selection data, and the cryptograms generated as entries for its task. Figure 7 depicts this process.

3.4. Message Preparation

Once the cryptograms have been embedded in the image, users would require information on the coordinates and size of each face in order to recover them. Therefore, in this section, the method to generate and conceal a message with this data is explained. The required information is hidden inside the photograph (container image) to send the information unnoticed by a third party by implementing a steganography technique. Thus, only authorized users can decrypt the faces through the use of the correct keys.

The message is composed of two parts: size and data. This is subdivided into several fields according to the total number of detected faces in the image. It has two sections when a single face is detected in the image, three for two detected faces, four for three, and so on. This is shown in Figure 8.

The size conveys a value that indicates the quantity of characters present in the data portion of the message. For example, in Figure 8, the size has a value of 013, meaning that there are thirteen characters in the data portion. This is shown in Figure 9.

The data is stored as explained in detail in Table 1.

In Figure 10, an image containing four faces is shown. Therefore, the number of fields in the data portion increases accordingly.

In Table 2, the information stored in each field according to the selection data from Figure 10 is exhibited.

3.5. Steganography Technique

In this system, a steganography technique proposed by Maricela et al. [26] was implemented.

Nomenclature: The photograph with the encrypted face. The message with the data to decode these will be embedded within the container.: Message generated in Section 3.4.: The with the hidden message.

The pixels that form the were divided into their three RGB subpixels of 8 bits each. The three combined convey all of the colors and their different intensities, ranging from 00000000 00000000 00000000, representing black, to 11111111 11111111 11111111, resulting in pure white. These properties were used to apply steganography that deploys the LSB scheme to modify the LSB of each subpixel. The method used chaotic mathematical models to generate two orbits. The first selects the pixel-to-modify and the second selects the RGB subpixel. This procedure is explained briefly below:(1)Convert into its respective chain of bits, as shown in Table 3.(2)Implement the ciphering keys to generate chaotic orbits. These will be deployed to select a subpixel of some RGB color [26]:(3)Take a bit from and compare it with LSB of . In the case of their being the same, the bit is left unmodified; otherwise, it is replaced. This is presented in Table 4.(4)Repeat steps (2) and (3) until all the bits of are embedded in .

4. Decryption System

To decode the face and return the photograph to its original state, the following phases are required:

4.1. Recovering the Message

Chaotic orbits were generated using the ciphering keys implemented in step (2) of Section 3.5; afterward, the RGB subpixel was selected. Finally, each LSB was taken until was recovered.

4.2. Extracting Cryptograms

Based on the information about the coordinates, i.e., the height and width of the faces obtained from in Section 4.1, the cryptograms of the photographs were extracted.

4.3. Decrypting the Cryptograms

For decoding, it is necessary to possess , the number of segments , and the parameters and initial conditions of each chaotic map (, , , ) used as ciphering keys. Subsequently, the next steps are as follows:

4.3.1. Removing Diffusion

First, the is segmented. Diffusion is removed by rearranging the values of each of the segments in their original position. The procedure is explained below:(1)Store the pixels from the in the vector and the array length .(2)Define the number of pixels per segment of the arrays (Step (1) from Section 3.2.2).(3)Select the corresponding values from the array for the current segment.(4)Repeat steps (3) and (4) from Section 3.2.2 to generate .(5)Take the value placed in of the current segment and place it in the next available location of . This is exhibited in Figure 11.(6)Repeat steps (4) and (5) until all pixels from the current segment have been returned to their original placement. If the value of one in the array has already been relocated, another value is taken from a previous location that has not been moved. In the case of reaching the beginning of the array without finding one, the search continues from the end of the array until one is found. The obtained value is placed in the next empty location of the array.(7)Repeat steps (3) to (6) with each segment and place them at the end of until all pixels have been returned to their original location.

4.3.2. Removing Confusion

(1)Repeat steps (3) and (4) of Section 3.2.1 to generate .(2)Apply the operation between a value from the and arrays to recover the original pixel value:This process is depicted in Figure 12.(3)Repeat steps (1) and (2) until all of the original values of have been recovered. The original image is recovered at the end of this process.

4.4. Face Reincorporation

Faces were reinserted in their original location using Section 3.3 of the face detecting and coding system.

5. Results

In this section, tests and analyses were performed to measure the sturdiness of the proposed encryption technique.

Figure 13(a) displays the original Lena image deployed to test the face detecting and coding process; the resulting image is presented in Figure 13(b). Afterward, the decryption and recovery system were implemented. The recovered image is displayed in Figure 13(c).

Other tests were also performed as shown in Figure 14. Four faces were detected in Figure 14(a), coded as shown in Figure 14(b), and decrypted as shown in Figure 14(c).

5.1. Statistical Analysis

In this section, the correlation diagrams and histograms obtained from the images displayed in Table 5 are exhibited. These images were obtained from Figures 14(a)14(c).

To measure the differences existing between the original faces the cryptograms presented in Table 5, the correlation diagrams shown in Figures 15(a)15(d) were constructed. These coefficients were equal to -0.02656, -0.03343, -0.02797, and 0.10136, respectively. It can be appreciated that these results are very close to 0; therefore, the correlation between the original images and their cryptograms was practically nonexistent. This indicates that the confusion and diffusion techniques implemented in the system provided sturdiness and complexity, rendering it difficult for an attacker to recover the information by searching for relationships among the original faces, ciphering keys, and cryptograms.

Additionally, the diagrams displayed in Figures 16(a)16(d) compare the original faces and the deciphered ones in Table 5 to verify the data integrity through the recovery process. The four correlation coefficients of can be observed. This indicates that the original images were identical to the recovered ones.

The histogram in Figure 17 was obtained from the original face (a) in Table 5 to represent graphically the distribution and frequency of the pixels. The vertical axis displays the number of times the same pixel value repeats across the image, while the horizontal access presents the value corresponding to the color.

In Figure 18, the histogram corresponding to the cryptogram (a) in Table 5 is exhibited.

Comparing the histograms in Figures 17 and 18, it can be observed that there is more homogeneity in the frequencies displayed in Figure 18. This confirms that the system was robust against attacks focused on finding relationships between the original image and the resulting cryptogram to detect the keys used for codification.

The standard Lena image in Figure 13(a) was utilized to perform the histograms shown in Figures 19(a)–19(c) according to RGB. Also, it can be observed in Figures 19(d)–19(f) that the histograms of the image encrypted in its entirety with the proposed system displayed a greater uniformity. Therefore, it would be more difficult for an attacker to determine the relationship between the plain image and the cryptogram.

5.2. Security Analysis
5.2.1. Sensitivity of the Key

To test the sensitivity of the encryption keys, the Lena image was coded with key1 (=3.9329, =0.34908, =1.0, =0.5762, =50), key2 (= 3.9329, =0.34907, =1.0, =0.5762, =50), and key3 (= 3.9329, =0.34907, =1.0, =0.5761, =50). Subsequently, the correlation was carried out between the cryptograms obtained with these keys that all varied by one single digit. Table 6 presents the values of the coefficients obtained and those generated by Murillo et al. [20].

5.2.2. Entropy

To measure the complexity of the encrypted data, an analysis of the entropy of the cryptogram generated from the Lena image was conducted and compared with those mentioned in other investigations. As shown in Table 7, it can be seen that all are close to 8. Therefore, the implemented encryption was robust because it presented a great degree of disorder.

5.2.3. Attacks

To verify the robustness of the system to an attack of the plain image, Figure 20(a) was used. This image was composed of all of its pixels in black to code it with the algorithm and formed in the cryptogram depicted in Figure 20(b). Subsequently, only the confusion technique of the encryption algorithm was implemented in order to cipher the Lena image and resulted in the cryptogram of Figure 20(c). Finally, Figure 20(b) was employed as a key to apply the inverse of the confusion technique in an attempt to recover the Lena image and resulted in the image shown in Figure 20(d). Thus, the proposed system was robust against this type of attack.

When a cryptogram is transmitted through a data network, it is possible for it to lose data. For this reason, it is necessary for the proposed system to retrieve the rest of the information. Therefore, it must resist an occlusion attack. In Figure 21(a), the cryptogram is shown with a data loss of 6.25%, and in Figure 21(b), the resulting recovered image is displayed. Figure 21(c) corresponds to the cryptogram with a data loss of 12.5%. When this was deciphered, Figure 21(d) was obtained. Figure 21(e) is the cryptogram with 25% less information and, when deciphered, Figure 21(f) was obtained. Finally, 50% of the data in the cryptogram of Figure 21(g) was eliminated and when it was decrypted, Figure 21(h) was obtained. As can be seen, the Lena image could be deciphered by recovering the remainder of the information even with losses in the cryptogram. In conclusion, the system was resistant to an occlusion attack.

To verify the error between the cryptogram and the original image, the mean square error (MSE) analysis technique was employed. The greater it is, the greater the robustness of the system is. On the other hand, when it approaches 0, the images are very similar. In Table 8, the result of the present system is compared with others.

The MSE was also calculated by comparing Figures 21(b), 21(d), 21(f), and 21(h) with the original. The results are illustrated in Table 9.

An attack was made on the cryptogram of the Lena image where Gaussian noise was incorporated with a standard deviation (SD) ranging from 0 to 0.25. This was later decoded and shown in Figures 22(a)22(f).

Table 10 exhibits the value of the MSE parameters from Figures 22(a)22(f) with Gaussian noise with respect to the original image.

5.2.4. Speed Analysis

The encryption-decryption process was implemented in the Java NetBeans ver. 8.2 platform on a laptop with i5-6300HQ CPU at 2.30 GHz, 8.0 RAM, Windows 10 x64 bit OS, Intel® HD Graphics 530 and NVIDIA GeForce GTX 950M Graphics Cards, and ADATA SU800 256 GB solid-state hard drive.

The algorithm proposed in this work quickly encodes and also has the quality of being robust. In Table 11, a comparison of this system with others found in the literature is presented. The latter allows verification of the time of encryption and decryption for each.

5.2.5. Key Space

The encryption system uses four keys (, , , and ) that implement a decimal precision of 10−15; therefore, 10−15x10−15x10−15x10−15=10−60. These are duplicated for each segment indicated in the fifth key (). In addition, when this technique is implemented with the scheme proposed by Maricela et al. [26], another six keys are used, where three correspond to the parameters and another three to the initial conditions of the chaotic system implemented. Therefore, 10−15x10−15x10−15x10−15x10−15x10−15=10−90. In Table 12, the comparison is shown regarding the encryption key of this system with others.

6. Conclusions

When performing the tests, several issues with the OpenCV Library were encountered. On certain occasions, the library mistakenly identified zones of the image as faces and caused them to be encrypted by the algorithm. Therefore, it was necessary for the photographs to contain frontal faces of good quality. Nonetheless, the system performed face detection, encryption, and decryption in photographs or videos by deploying chaotic cryptography and steganography.

In addition, any chaotic mathematical model can be implemented because this system only requires two orbits for encryption and two additional ones for steganography. It requires three orbits in the case of working with videos, with the latter increasing the number of keys. Further, diffusion was applied by segmenting the image and scrambling each of these segments, and security was independently increased by requiring an attacker to know the pixel number in each segment and the key used for decryption.

Another remarkable feature of the system is that it does not encrypt the photograph entirely and allows publication in media without showing the individuals appearing in them. In addition, the system prevents facial recognition by humans or systems and maintains integrity by recovering 100% of the information in the decryption process. On the other hand, when comparing the system with others, it was observed that this system was highly sensitive to encryption keys and the entropy was very close to 8, although other references provided a slight improvement in the latter. It was also robust in terms of occlusion and noise attacks and also permits increasing the number of keys depending on the segments in which it is encrypted. Finally, it demonstrated excellent speed for encryption and decryption.

Data Availability

The algorithms, figures, and pixel data used to support the findings of this study are included within the article.

Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

Acknowledgments

This work is supported by CONACYT in Project 743187 and 887565.