#### Abstract

The Internet of Things connects billions of intelligent devices that can interact with one another without human intervention, and during communication, a large amount of data is exchanged between the devices. As a result, it is critical to secure digital data using an encryption technique that provides a suitable degree of security. Numerous existing encryption techniques do not offer sufficient security. Therefore, it is critical to figure out which encryption technique is most appropriate for a particular kind of data. When it comes to manually deciding which encryption technique to use, the process might take a long time. In this research, we present a novel technique for selecting Encryption Algorithms (EAs) based on a particular application using pattern recognition and machine learning techniques. To accomplish this goal, we also prepare a dataset. Several machine learning techniques, such as Support Vector Machines (SVMs), Linear Regression (LR), -Nearest Neighbour (KNN), Naïve Bayes (NB), Decision Trees (DT), and Random Forests (RF), are evaluated. Based on the evaluation, the SVM has been chosen as the best option for the intended technique because its classification accuracy is 98.7%. The experimental results, including accuracy, precision, recall, and F1-score, are used to gauge the performance of the suggested technique. The proposed technique is also compared with the existing techniques to demonstrate its effectiveness.

#### 1. Introduction

Nowadays, the Internet of Things IoTs is extensively used in a variety of industries and applications, including manufacturing, agriculture, e-health, home automation, and smart cities. According to Erickson, by 2022, the world will have around 28 billion linked smart devices. Additionally, about 15 billion devices make use of Machine-to-Machine (M2M) connectivity [1]. Additionally, according to a Cisco research, the internet will be connected to about 500 billion devices by 2030 [2]. In this way, it is easy to see why the IoT has attracted the interest of developers, and researchers have given the revolutionary changes it has brought to human existence. The IoT facilitates the sharing of multimedia data across a broad number of applications, including smart transportation, smart health, smart buildings, and industry [3]. As billions of network devices interact and share potentially sensitive data, the most essential concern in the IoT is data security and privacy [4–6]. Figure 1 shows the data transmission between the several linked devices.

Different types of Encryption Algorithms (EAs) are developed over the past few decades to secure digital images during transmission between multiple connected devices for IoT applications. One advantage of EAs is their efficiency in terms of computation time. However, insufficient encryption, as evidenced by patterns visible even after encryption, indicates a flaw in the EA [7, 8]. For proper concealment and a sufficient level of encryption of textual data, conventional Data Encryption Standard (DES) and Advanced Encryption Standard (AES) are well-known techniques [9, 10]. There are multiple rounds of encryption involved, making these classic image encryption techniques unsuitable for real-time applications. In the case of image encryption, traditional EAs are not suitable for real-time applications because they contain several encryption rounds. To overcome such issues, several cryptosystems have been proposed in recent years [11–13]. To break the correlation between the image pixels, permutation and substitution are the most widely used techniques to secure digital images [14, 15]. In [16], Shannon proposed a theory that any EA that contains confusion (referring to permutation) and diffusion (referring to substitution or any other process that can change the pixel value) may be considered a strong cryptosystem.

Generally, two things must be offered by the EA: (a) strong security (b) and computational efficiency. There will always be a trade-off between security and complexity in terms of time. At times, a strong security algorithm may take longer to execute due to the number of mathematical operations it contains [17]. Time-efficient encryption techniques are always required for real-time applications. Various forms of pixel transformations may be employed in image encryption, including permutation, substitution, the Discrete Wavelet Transform (DWT) [18], the Discrete Cosine Transform (DCT) [19], and the Discrete Fourier Transform (DFT) [20]. All of these approaches have been extensively utilised over the last several decades and proposed a variety of algorithms, some of which are resistant to various types of security attacks, including ciphertext-only attacks, brute force attacks, and plaintext-only attacks. A cryptosystem that is vulnerable to security attacks may have two fundamental problems: (a) it is unable to adequately encrypt the plaintext image due to the identical patterns included within it. Similar patterns also correlate to a high degree of correlation between image pixels; (b) it is computationally inefficient, making it unsuitable for low-profile applications such as data transmission from a drone to a base station, which needs high-speed encryption. On the other side, to propose a time-efficient technique, one may reduce the mathematical operations used in encryption schemes, compromising security and allowing the original image’s patterns to be visible in the encrypted image. The plaintext images with the smooth patterns are shown in Figures 2(a)–2(h). This indicates that there is a significant degree of correlation between the pixels, whereas Figures 2(i)–2(p) depict the corresponding ciphertext images that have been encrypted using various existing encryption schemes [21–24].

**(a) Plaintext image**

**(b) Plaintext image**

**(c) Plaintext image**

**(d) Plaintext image**

**(e) Encryption using the scheme proposed in [21]**

**(f) Encryption using the scheme proposed in [25]**

**(g) Encryption using the scheme proposed in [26]**

**(h) Encryption using the scheme proposed in [27]**

**(i) Plaintext image**

**(j) Plaintext image**

**(k) Plaintext image**

**(l) Plaintext image**

**(m) Encryption using the scheme proposed in [23]**

**(n) Encryption using the scheme proposed in [24]**

**(o) Encryption using the scheme proposed in [28]**

**(p) Encryption using the scheme proposed in [29]**

The patterns in Figures 2(i)–2(l) may be visualized, indicating that such images are encrypted using weak encryption techniques. While Figures 2(m)–2(p) are encrypted using secure encryption techniques, the plaintext image’s patterns have been properly encrypted and are not visible, and the processing time required to encrypt the plaintext image is quite high.

For instance, if the image pixels have a low correlation, it is unnecessary to employ the majority of the resources available to encrypt the data included in the image. Generally, an encryption technique that employs a large number of mathematical operations is considered inefficient but extremely secure [28, 30]. Similarly, reducing the number of mathematical operations in an EA makes it more time-efficient, but it may compromise its security level [31]. In the proposed technique, EAs are categorized on the basis of computational complexity. For instance, EAs with processing times of [0.001, 1.00], [1.001, 2.000], and [2.001, ] are referred to as low-processing-time encryption (ELPT), moderate-processing-time encryption (EMPT), and high-processing-time encryption (EHPT), respectively.

Several metrics such as entropy, correlation, contrast, and energy [32] are evaluated in the suggested study to assess the patterns in the image, whether they are smooth or rough. After evaluating the patterns in the image, the appropriate encryption technique for that specific data may be chosen. The security parameter values may also be determined manually, but it may take a lot of time. As a result, a machine learning-based method is designed to examine the patterns in the plaintext image and suggest a suitable encryption technique, whether the image should be encrypted using a strong EA or concealed using a faster EA. The suggested approach is applicable to images in both colour and grayscale. When a colour image is used, it must be decomposed into three grayscale components, such as red, green, and blue.

##### 1.1. Contributions

The major contributions of this work are as follows: (i)A machine learning model is proposed for pattern recognition-based selection of an appropriate encryption technique(ii)The security parameters are used to identify the patterns in the plaintext image and set the appropriate intervals for each security parameter to achieve the desired task(iii)Various machine learning algorithms are evaluated on the proposed work to find the best one(iv)To improve the overall accuracy of the proposed model, -fold analysis is performed to develop several models for the proposed work. The developed models are called -models(v)Voting mechanisms such as hard and soft voting are used to choose the final model from the several -models(vi)To gauge the performance of the proposed work, several tests and analyses such as accuracy, precision, F1-score, and recall are incorporated

The rest of the paper is as follows: Section 2 is dedicated to a review of the available schemes in the spatial and frequency domains. Section 3 contains preliminaries to the proposed research, including an explanation of SVM and DT. Section 4 discusses the proposed model for selecting an appropriate EA. Section 5 contains an assessment and comparison of the proposed work to previously published work. Finally, Section 6 finishes the proposed work.

#### 2. Related Work

For secure communication, data encryption is necessary before transmission. To overcome the security issues, data can be encrypted either in the spatial domain or in the frequency domain. In the spatial domain, one can directly manipulate the pixel values. While in frequency domain encryption, first, pixels convert into their frequency domain and then further process. For instance, if a DWT is applied to the image pixels, it will convert into four different frequency subbands. Once the pixels are converted into their frequency subbands, the mathematical operations can be applied to them for further encryption. EAs can be used according to the applications and patterns existing in the plaintext image. The patterns having high correlation always required strong security EAs, whereas, in drone applications, a fast encryption speed is also required with strong security. Therefore, it is necessary to observe and analyze the patterns present in the image to select the right EA. There are several EAs that have been proposed in the last few decades which are based on either spatial domain or frequency domain.

##### 2.1. Image Encryption in Spatial Domain

Spatial domain encryption has advanced significantly since incorporating chaos theory to secure digital images [18]. In the past few decades, chaos has been widely used in image encryption due to its several tremendous properties, such as sensitivity to initial conditions, nonperiodicity, and ability to generate pseudorandom numbers.

In [21], Anees et al. proposed an image encryption scheme comprised of two major components. One is a chaotic map, and the second is multiple substitution boxes (S-boxes). Both the components are used to break the high correlation between the image pixels. Moreover, several drawbacks of using a single S-box are addressed. To overcome the vulnerabilities that exist in using a single S-box, multiple S-boxes are used. The S-boxes are selected based on the random sequence generated using the chaotic logistic map. Using statistical analysis, it is proved that the multiple S-box scheme can perform better than the single S-box encryption scheme. However, the patterns of the plaintext image can be visualized. In [33], Ahmad and Hwang made a few improvements to the scheme proposed in [21] by adding noise in the plaintext image prior to the conversion of the noisy image into blocks. To manipulate each block of pixels, a Xor operation is performed that gives the final encrypted image.

In the encryption schemes, nonlinear components such as S-boxes also play a vital role in securing digital images. Therefore, it is crucial to use an S-box that exhibits strong cryptographic properties. In [34], Shafique et al. proposed a new methodology to construct an S-box based on a cubic logistic map, which has been given the name C-logo S-box. The purpose of proposing the S-box is to strengthen the overall EA so that the pixels of the plaintext image can be properly concealed. Several tests and analyses, such as Strict Avalanche Criterion (SAC), Bit Independent Criterion (BIC), and nonlinearity, are carried out to show the strength of the proposed S-box. A comparison reveals that the C-logo S-box performs significantly better than the other S-boxes that are present in the literature [35, 36].

In [37], Li and Yang introduced an image encryption technique based on chaos and discrete Fractional Wavelet Transforms (FWT). Confusion and diffusion operations are implemented independently, which results in a slight increase in the processing time required for encryption. Additionally, numerous cryptographic components, such as FWT, chaos, and quantum theory, are employed to increase the security of digital images. While using many encryption components sequentially may result in higher security, the processing time required for encryption may increase. Lin et al. [38] proposed a novel method for secure communication based on chaos theory in which mathematical operations to convert the plaintext picture to the ciphertext image are performed sequentially rather than concurrently. Liu et al. [39] proposed a four-dimensional chaotic map-based encryption system with two encryption rounds and one hashing round. Multiple round encryption techniques often perform much better in terms of security but are not suited for real-time applications due to their increased computing time requirements. The encryption presented in [40] encountered computational complexity concerns because of the method’s one-by-one encryption of the HSV components of colour images. Time complexity may be reduced by encrypting the HSV components in parallel. To make the chaos-based encryption scheme more robust, Lidong et al. [41] and Lu et al. [26] used S-box in their proposed cryptosystems. In [41], image compression is also incorporated, followed by encryption to reduce the encryption computational time. Moreover, the scrambling process is applied to the compressed image to break the correlation between the image pixels. To satisfy the criteria of confusion-diffusion proposed by Shannon [16], S-box is applied to create the diffusion in the scrambled image. A single S-box is not enough to secure the image against the deferential attack, specifically, when the image contains smooth patterns. In [26], a new chaotic map called the Logistic-sine System (LSS) is proposed, which has a wider chaotic range. The LSS is then used with the S-box in the proposed encryption scheme, which makes it comparatively more robust than the scheme proposed in [41].

##### 2.2. Image Encryption in Frequency Domain

Apart from spatial domain encryption, frequency domain cryptosystems are also frequently used to secure the images from adversaries. Both of these types of encryption are useful to disturb the patterns of the pixels present in the image. Without a specific pattern in the image, it is difficult to read the information. Therefore, it is necessary to disturb the pixel patterns so that no one can read the information present in the image.

In [42], Rehman et al. proposed a cryptosystem in which both spatial and frequency domain sections are included. For spatial domain encryption, multiple chaotic maps used are known as chaotic logistic amp and chaotic sine map. These chaotic maps are used to generate random sequences for permutation purposes. Moreover, a chaotic sine map is also used to generate random images for diffusion purposes which are achieved using XOR operation performed on the precipher image with the random image. It is not always required to use a forward operation of any frequency transform such as DWT; one can also use its reverse operation Inverse Discrete Wavelet Transform (IDWT) to secure the digital images [43]. In [18], Shafique et al. proposed a DWT-based cryptosystem in which chaos and bit-plane extraction are the major parts. The whole scheme is consisting of three sections; the first and last sections are dependent on the spatial domain encryption while the middle section is devoted to the frequency domain section. The proposed is designed specially for those images that consist of a large number of the same patterns. As a lot of mathematical operations are included in the proposed scheme, it is somehow slower than the other existing schemes [13, 44–46]. Therefore, the scheme proposed in [18] is not suitable for real-time applications. The image encryption schemes presented in this section are based on chaos theory, bit-plane extraction, frequency transformation, and spatial domain transformation. Some of them can be used for specific purposes. For instance, the scheme proposed in [47] is useful to encrypt the image properly that can resist several security attacks, but it is not suitable for low-profile or real-time applications. Therefore, using the encryption scheme proposed in [47] is not the right choice when anyone wants to encrypt the image faster. Here, it can be noted that the orthodox selection of EA is very important for the particular kind of data. Therefore, a machine learning-based model is proposed to learn the image pattern for the selection of suitable EA.

#### 3. Preliminaries

In the proposed work, several machine learning algorithms such as Decision Tree (DT), Support Vector Machine (SVM), Random Forest, -Nearest Neighbour, and Logistic Regression (LR) are evaluated in which SVM and DT exhibit approximately comparable accuracy and precision. As a result, the preliminary section includes a discussion of SVM and DT. Moreover, among DT and SVM, the final selected ML algorithm is SVM as its accuracy is better than DT and other comparable ML algorithms.

##### 3.1. Support Vector Machine

SVM implementation requires training on training data, since it is a supervised learning algorithm that takes training data as an input and predicts the label of the output based on training [48]. The training and testing datasets may or may not vary in size. The whole dataset’s dimension is determined by the number of features employed. For instance, if the dataset has fourteen features, it will be fourteen-dimensional [49]. The general form of the dimension of the dataset is given below: where is the dependent output label and represents the number of independent features. The number of features may vary depending upon the output. A line that is a support vector is necessary to separate the data with maximum margins in the two-dimensional dataset. In the case of a higher-dimensional dataset, on the other hand, a plane is utilised to divide the data points rather than a line.

The proposed work makes use of an eight-dimensional dataset. As a result, it is required to determine the optimal plane for separating the data points in order to properly classify the unseen sample. The categorization function may be defined as follows: where and are the weight vector and the intercept, respectively. However, can be calculated as

##### 3.2. Decision Tree

DT is also a supervised learning technique to classify the data into specific classes. The growth of the tree may depend on the number of attributes used in the dataset. For determining the computational cost and classification performance, the heuristic plays a vital role in tree-growing [50]. Mostly, decision trees use an impurity-based heuristic which computes the purity of the resulting subset once the splitting attribute is applied to split the training data [51]. To build the tree for the classification purpose, a root node must be selected, which can be determined by calculating the Information Gain (IG), and the one with the highest IG will be selected as the splitting feature [52]. IG can be calculated as where represents the training events or feature vectors, represents the feature and represents its value, represents the subset of containing occurrences with , and entropy () may be determined as follows: where can be evaluated as the probability of the events belonging to in and is the number of labels present in the dataset.

#### 4. Proposed Model

Numerous encryption techniques have been proposed in recent years, including chaos and transformation-based algorithms. Analyzing the statistical results of EAs indicates that some of them are insecure and do not provide enough protection [53–56].

In this article, a machine learning model that incorporates SVM is developed to determine the optimal encryption technique for the data in the form of images. The proposed work is shown schematically in Figure 3. The process for constructing the proposed model is as follows: (i)Take a large collection of plaintext images () having size ( and ) in which a different amount of information is present. For instance, a few images from the dataset are shown in Figure 4 in which a significant amount of information lies in Figures 4(a)–4(d) as compared to the information present in Figures 4(e)–4(h)

**(a)**

**(b)**

**(c)**

**(d)**

**(e)**

**(f)**

**(g)**

**(h)**

##### 4.1. Features Used in the Proposed Work

Security parameters such as entropy, energy, contrast, correlation, homogeneity, histogram uniformity, and irregular deviation are considered features to select which plaintext image contains the highest, lowest, and moderate amount of information. On the other hand, peak signal to noise ratio and mean square error, both of which are security metrics, need at least two images, such as plaintext and ciphertext, in order to quantify the difference between the two. In our case, only plaintext images are considered in the proposed work.

###### 4.1.1. Entropy

Entropy is used to find the randomness in an image. Furthermore, the entropy value corresponds to the high randomness [57]. The relation between entropy and randomness is given below:

The maximum entropy value for every image is determined by its bit count. For example, the maximum entropy values for an eight-bit and binary image are 8 and 2, respectively. Entropy may be stated mathematically as where is the probability of occurrence of message and represent the number of pixels present in plaintext image.

The entropy value of an image increases in proportion to the complexity of the patterns contained inside. As seen in Figures 4(a)–4(d), the patterns are visible, indicating that the entropy value for such images is low. Similarly, the entropy values for the images shown in Figures 4(e)–4(h) will be rather high, as indicated in Table 1.

To classify the plaintext images to be encrypted either with fast, moderate, or slow processing EA, three intervals are defined in Table 2.

###### 4.1.2. Contrast

Contrast analysis of an image allows the observer to identify the objects in the image [57]. Mathematically, it can be calculated as where and represent the number of rows and columns of the image. represents the number of gray levels in the occurrence matrices. The value of contrast reflects that the image contains less information. The relationship between the image pattern and contrast values is given in

As demonstrated in Table 1, the contrast values for the images in Figures 4(a)–4(d) are smaller than those in Figures 4(e)–4(h). This implies that the images (Figures 4(a)–4(d)) must use a robust encryption scheme to preserve the image’s patterns. Using additional resources to encrypt the images (Figures 4(e)–4(h)) is not a viable option. It may be encrypted using a faster-processing encryption technique with a moderate level of security. The following intervals are given in Table 3 for the categorization of images that may be encrypted using either category of encryption methods.

###### 4.1.3. Energy

Energy values reflect the amount of information present in the image. The higher the values of energy, the greater amount of information is present in the image [58]. Energy can be calculated using Equation (10), whereas the relationship between the amount of information and energy is given in Equation (11). where shows the total number of pixels in an image ():

Table 1 contains several energy values for various images, and it can be seen that the energy values for the images (Figures 4(a)–4(d)) are higher than the images shown in Figures 4(e)–4(h), implying that the images (Figures 4(a)–4(d)) require strong security algorithms to secure the patterns of the plaintext images. Table 4 shows the intervals for the classification of different EAs.

###### 4.1.4. Correlation

Correlation indicates the similarity of two or more objects, i.e., correlation between the whole image or a subset of its pixels. Correlation coefficients increase as the object’s similarity increases [59]. In digital images, a gradient pattern has a higher degree of correlation between the pixels than texture patterns, which indicates that images with more gradient patterns will have a higher correlation value, necessitating the use of a powerful encryption technique to break the correlation. In comparison, texture patterns in digital images have less correlation between pixels, which is very simple to eliminate even with a moderate or poor security level encryption techniques. Correlations between image pixels may be calculated using where and denote neighbouring pixel values, respectively, and denotes pixel correlation. Correlation coefficients are in the range of . and denoted the correlation between neighbouring pixels’ lowest and maximum values, respectively. The 2500 pixel pairs are taken from the plaintext image in three distinct directions: horizontal, vertical, and diagonal. Figures 5(b)–5(d) and 5(f)–5(h) illustrate the horizontal, vertical, and diagonal correlations of image pixels, respectively. As can be observed, the pixels are closer together, indicating a significant correlation. In comparison, the distribution of pixels in Figures 5(j)–5(l) and 5(n)–5(p) is relatively random, indicating a weaker correlation. Thus, images with a low correlation may be easily secured using a simple, mathematically structured encryption approach. Digital image encryption is classified according to the intervals specified in Table 5.

**(a) Plain image with high correlation**

**(b) Horizontal correlation**

**(c) Vertical correlation**

**(d) Diagonal correlation**

**(e) Plain image with high correlation**

**(f) Horizontal correlation**

**(g) Vertical correlation**

**(h) Diagonal correlation**

**(i) Plain image with comparatively low correlation**

**(j) Horizontal correlation**

**(k) Vertical correlation**

**(l) Diagonal correlation**

**(m) Plain image with comparatively low correlation**

**(n) Horizontal correlation**

**(o) Vertical correlation**

**(p) Diagonal correlation**

###### 4.1.5. Homogeneity

The Grey-level Co-occurrence Matrix (GLCM) illustrates the brightness of pixels. Those images that contain high information have higher homogeneity values. This means that encrypting images with high homogeneity values is difficult and requires a strong encryption scheme. Homogeneity can be calculated as where is plaintext image and shows the pixel position. Table 6 contains the intervals used to classify encryption schemes. If the plaintext image’s homogeneity values fall within the range , it may be encrypted using a strategy that requires less mathematical operations and requires less processing time.

###### 4.1.6. Histogram Analysis

Histogram analysis is often used in image encryption to determine the security of ciphertext images. To offer effective encryption, the encrypting images’ pixel distribution must be constant, which means that the histogram must be flat, which corresponds to the image pixels being properly concealed. Plaintext images contain more information than encrypted images, indicating a less uniform pixel distribution. The histograms of multiple plaintext images are provided in Figure 6, along with the pixel distribution.

**(a)**

**(b)**

**(c)**

**(d)**

**(e)**

**(f)**

**(g)**

**(h)**

The relationship between the information present in the plaintext image and uniformity of the histogram is given as

According to Equation (19), less uniformity in the histogram indicates that the corresponding image has a greater quantity of information. This implies that images with flat histograms are simple to encrypt and can be made secure by using an encryption strategy with less mathematical operations and processing time. Equation (20) may be used to compute the statistical value of the histogram analysis: where represents the number of gray levels and . According to the existing work [60], must be less than 293.24783 to achieve the uniformity in the histogram. represents the variation in the peaks of the pixels. Based on the values, plaintext images are categorized into three intervals as shown in Table 7 for encryption purposes.

###### 4.1.7. Irregular Deviation

The uniformity of the histogram also relates to the irregular deviation () in the image pixels. may be used to determine image quality. The more information is present in the plaintext images, the higher the value. It may be defined as the degree to which the histogram deviation distribution and the uniform distribution are similar. can be calculated as where and are the histogram deviations at the and positions, respectively, and the mean value. The less consistent the histograms, the lower the value. The interval is specified in Table 8 to classify encryption techniques for plaintext images. The summary of the features used in the proposed work is given in Table 9. (i)A dataset is created using the security parameters as a feature and the intervals defined in Section 4.1. The collection is vast and includes the bulk of textual image categories that we see in everyday life, such as medical images and war images. As a consequence, this dataset is often referred to as the source domain for the proposed model training, validation, and construction. Table 10 includes a subset of the detailed data. The dataset is split into the training and test sets at a ratio of 0.8 : 0.2, as specified in(ii)After extracting statistical features from plaintext images, save feature values in an array to create unique vector streams (V.S), also referred to as feature vectors. Vector streams may be expressed as follows in terms of their features as given:

The feature values for each feature are , , , , . The provided dataset (22) is separated into two sections for the purpose of training the proposed model (training and testing). Each part is further separated into categories, such as -train and -train for training purposes and -test and -test for testing purposes. Train various machine learning algorithms on the training dataset to identify plaintext images based on the information contained in them. The purpose of comparing various machine learning algorithms is to determine which method outperforms the others on the provided dataset. A few instances of categorization for numerous plaintext images are shown in Table 11.

#### 5. Results and Discussion

Two distinct tools such as MATLAB 2014a and a Jupyter notebook (for Python, version 3.7) are used to construct the proposed model. Several characteristics including accuracy, precision, recall, and -score are examined while evaluating the proposed model, and their values may be simply computed using the confusion matrix. This is a two-dimensional array that contains True Positive (), True Negative (), False Positive (), and False Negatives (). Figure 7 shows the generalised confusion matrix and the confusion matrices for the proposed work when DT, K-NN, RF, NB, and SVM are used.

**(a) Confusion matrix**

**(b) Confusion matrix for when SVM is incorporated**

**(c) Confusion matrix for when K-NN is incorporated**

**(d) Confusion matrix for when DT is incorporated**

**(e) Confusion matrix for when NB is incorporated**

**(f) Confusion matrix for when LR is incorporated**

The terms , , , and are defined below according to the proposed model. (i)True positives ()

The proposed technique predicts that a strong EA (EHPT) is required to encrypt such a plaintext image that contains a bulk of information. (ii)True negatives ()

The proposed technique predicts that such an EA is required that offers moderate security (EMPT) to encrypt a plaintext image that contains moderate amount of information, or the proposed technique predicts that such an EA is required that offers weak security (ELPT) to encrypt a plaintext image which contains less amount of information.
(iii)False positives **(****)**

The proposed technique predicts that a strong EA (EHPT) is required to encrypt such a plaintext image that contains moderate or less amount of information. (iv)False negatives ()

The proposed technique predicts that such an EA is required that offers moderate security (EMPT) to encrypt a plaintext image that contains a bulk of information, or the proposed technique predicts that such an EA is required that offers weak security (ELPT) to encrypt a plaintext image that contains a moderate amount of information.

The mathematical equations and corresponding values calculated using the proposed mode are shown in Table 12.

To enhance the overall accuracy of the proposed model, -fold analysis is performed in which five different values of () are selected to build five models (, , , , and ). For instance, if , a total of twenty iterations will be performed and take the average accuracy for . The mathematical representation for calculating the average accuracy for () is shown in Equations (24) and (25), whereas for other classifiers at different values of are displayed in Table 13:

Finally, voting techniques such as soft and hard voting are applied on the proposed -models to classify the labels in a more sophisticated way.

##### 5.1. Hard Voting

This technique works on the majority of votes. For instance, there are five models for the proposed work (). Three of them classify the upcoming event as ELPT, one each is for classes EMPT and EHPT. Therefore, according to the hard voting technique, the new event will belong to class ELPT as shown in Figure 8.

##### 5.2. Soft Voting

The probability-based classification can be performed using soft voting. In this technique, the probability of each class occurring is calculated separately, and then, the decision will be in favour of the class which has the highest probability value, as shown in Figure 9.

The probability of occurring in each class (ELPT, EMPT, and EHPT) using the generated -models is calculated individually according to where , , and is the probability of occurring in the events ELPT, EMPT, and EHPT, respectively. According to the calculated probabilities, Equations (29), (30), and (31) become

According to Equations (29), (30), and (31), the upcoming event will belong to class ELPT.

The statistical values of the performance metrics for the proposed and existing work are displayed in Table 14. Several machine learning algorithms, including SVM, NB, LR, DT, RF, and K-NN, are evaluated when comparing the proposed work to current models. Based on the comparative study, it is evident that, among the machine learning algorithms used in the proposed work, SVM offers the highest accuracy. Moreover, comparable schemes are significantly less accurate than the proposed approach. However, the technique suggested in [61] has a 95% accuracy rate, which is comparable to the accuracy offered by the proposed work.

#### 6. Conclusions and Future Research Directions

The proposed research presents a pattern recognition-based machine learning technique for selecting the most appropriate encryption technique for a specific kind of data contained in digital images. Digital images are classified into three categories based on the amount of data present in them. Images containing highly correlated data which are transferred between the IoT devices should be encrypted through EHPT, while images containing textures should be encrypted through ELPT. Several machine learning algorithms are evaluated in the proposed study in order to determine the optimal ML algorithm to achieve the desired task. SVM outperforms all other machine learning methods in terms of accuracy, and it classifies the images with an accuracy of 98.7%. As a result, it is selected for the proposed technique. Moreover, a detailed comparison reveals that the proposed technique performs better than the existing ones.

In the future, we may use the proposed technique to secure digital images. Moreover, the dataset utilised in this research may be improved by incorporating more number of features.

#### Data Availability

The dataset generated and analyzed during this research study are available from the corresponding author on reasonable request.

#### Conflicts of Interest

The authors declare no conflict of interest.