Agent-Based Image Contrast Enhancement Algorithm

One crucial step in several image processing and computer vision applications is Image Contrast Enhancement (ICE), whose main objective is to improve the quality of the information contained in the processed images. Most of the proposed schemes attack the problem by redistributing the pixel intensities in a histogram, leading to undesirable effects such as noise amplification, over-saturation, and lousy human perception. On the other hand, Agent-Based Models (ABM) are computational models that allow describing the behavior and interactions of autonomous agents when they operate cooperatively. These agents follow behavioral rules rather than mathematical formulations. This mechanism allows the implementation of complex behavioral patterns in agents through their interactions. This paper proposes a two-step method where pixels in the processed image are considered agents whose behavioral rules permit to enhance significatively the contrast. In our approach, the interactions among the agents are characterized by the differences in intensity values among the pixels or agents. In the first step, pixels or agents that present enough high differences in their intensity are modified to increase even more their differences. In the second step, pixels or agents that maintain a very small difference are altered to assume a homogeneous intensity value. The proposed approach has been tested considering different public datasets commonly used in the literature. Its results are also compared with those produced by other well-known ICE techniques. Evaluation of the experimental results demonstrates that the proposed approach highlights the important details of the image taking a lower computational execution time.


I. INTRODUCTION
Image Contrast Enhancement (ICE) has attracted the attention of researchers in recent years, that is due to its multiple applications in areas such as transportation, medicine, security, etc. [1], [2], [3], [4], [5]. The ICE techniques consist in improving the visual information contained in an image by increasing the difference among features of its different objects. Its main objective is to improve the interpretability of the information presented in an image for human viewers or make it more suitable for future processing steps in The associate editor coordinating the review of this manuscript and approving it for publication was Gangyi Jiang. any automatic computer vision system [5], [6]. In general, the ICE process modifies the pixel values through different techniques such as histogram equalization, fuzzy logic operation, or quadratic operation [1], [2], [3]. Among all these approaches, the most used is histogram equalization due to its simplicity and effectiveness [4], [6], [7], [8], [9]. In this operation, the pixels in the image are redistributed over its whole scale, considering its statistical features. In this approach, each pixel intensity value X of the original image is mapped to another value Y in the processed image, no matter the number of pixels in the original value X in the original image. Hence these schemes lead to a non-optimum redistribution of the pixel data under the presence of noise or an irrelevant set of pixels in the image. As a consequence, these approaches produce enhanced images with different problems, such as noise amplification or the generation of undesirable artifacts [10], [11], [12].
On the other hand, since real-world processes are more and more interconnected, simple models are not enough to analyze them. The wide variety of computing methods has allowed the construction and analysis of more complex models bringing with it a new field of knowledge called complex systems (CS) [13], [14]. In CS, it is studied how the systems are affected by individual behaviors. In these systems, complex behaviors of the whole system appear as a consequence of the collective interaction of individuals who can influence the systems and participate in a self-organizing process [15]. A complex system is a structure integrated by many elements or agents which interact, restrict, and correlate with one another. An image can be represented as a complex system where a high number of elementary agents or pixels adopt various states and interact in local neighborhoods. From their interactions, several different associations can be defined to solve complex image processing problems such as segmentation, contrast enhancement, or filtering, to name a few.
Agent-based modeling [16], [17](ABM) is a relatively new paradigm in artificial intelligence (AI) to model CS using individual elements. These elements perform behaviors described by simple rules and are influenced by de collective interaction with other elements in the system. Under this scheme, the behavior of the agents is maintained by the characterization of simple rules. That is, intending to emulate the individual operations of real actors when they interact with their local environment. At the same time, the system is modeled from the individual perspective, while the main properties are visualized from the global perspective. These powerful characteristics have motivated the use of ABM in several applications, such as the characterization of the immune system [13], [18], consumer behavior [19], [20], [21], [23], [24], collaborative image processing [25], image colorization [26], fire spreading [27], the spread in epidemics [28], among other [13], [16], [19], [29], [30], [31].
In this paper, an Agent-Based Image Contrast Enhancement (ABICE) algorithm is introduced. This algorithm is divided into two fundamental steps where each pixel in the original image is considered as an individual agent, which will follow simple rules according to the information provided in their neighborhood. In the first step, the followed rule by the agents highlights its features increasing the difference between the pixel and its neighborhood, giving, as a result, a contrast-enhanced image but with some areas that, due to its characteristics, form certain patterns that can be considered noise. With the aim to solve this problem in the second step, the rule followed by the agents smooths the high differences in these conflicted areas giving as result the final contrast-enhanced image. The performance of the proposed method has been tested considering several representative datasets commonly used in the literature. Its results were also compared with those produced by other well-known ICE techniques. Experimental results have shown that the proposed scheme has a better performance in comparison with other schemes in terms of several performance indexes.
The rest of the paper is organized as follows: In section II a brief introduction to Agent-Based Modeling is presented. In section III the proposed ABICE method and its rules are introduced. In section IV, the experiment to test the algorithm performance is planted, and the experimental results are presented. Finally, in section V the conclusions and future work are presented.

II. AGENT-BASED MODELING
Since real-world processes have become more interconnected, and simple models are no longer enough to analyze them, the wide variety of fast computing resources has allowed the construction and analysis of more complex models, bringing with them a new knowledge field called complex systems (CS) [20]. One of the computational schemes used to explain the behavior of CS are the agent-based models [32]. Under these models, the actions of elements in the system are emulated, considering the way these entities influence and are influenced by their environment. ABM are particularly adequate when the behavior of the interacting elements takes an important role in the final results.
Under this paradigm, agents are artificial elements programmed to execute pre-specified actions [REF]. While these elements perform their operations based on their behavior, they cooperate and compete with each other. The agents follow a straightforward structure of their operations, covering from easy decisions (such as yes or no action) to spatial movements.
Under classical modeling schemes, it is only considered to aggregate elements rather than their interactions. Furthermore, they are not completely adapted to represent complex systems. Even models in which elements consider simple interactions can produce behaviors that cannot be generated and analyzed from the classical modeling perspective without interactions [33]. Taking this into account, agent-based modeling involves individual interactions representing their effects on the system results.
Most agent-based modeling schemes use simple behavioral models and architectures. These models produce a wide variety of complex behavioral patterns due to the interactions between the agent sets [34]. In agent-based models, each element makes decisions considering programming rules. The global behavioral patterns correspond to identifiable distribution that represents spatial regularities given by these programming rules [35]. These rules characterize each agent's behavior individually in an abstract way. Making it relatively simple to describe the interactions among the agents once the relevant elements in the system are identified. Different kinds of information can be included in the rules such as qualitative and quantitative information and expert opinions. In rule construction, the aim is to find a trade-off between accuracy and VOLUME 11, 2023 simplicity. These rules should be as simple as can to capture the main theoretical elements of the system [13]. Although the model design aims to maintain the simplicity of the rules, it is also fundamental to guarantee that they maintain the accuracy level of the system. However, a lot of detail can be unproductive since it is difficult to observe the relationship between the agents and their behavior.
Generally, agent-based schemes involve the following steps. First, a group of N agents {n 1 , . . . , n N } is initialized. In this step, all agents are set in a specific state or location. After that either randomly or considering a particular order each element n i (i ∈ 1, . . . , N ) is selected. That's when the specific agent n i follows a set of rules which modify its state, location, or relationship with other agents. These rules consist of a set of conditions and relations given by the influence of the neighborhood or other agents. These steps are repeated until a certain stop criterion is attached.

III. AGENT-BASED IMAGE CONTRAST ENHANCEMENT
A complex system is a structure integrated by many elements or agents based on a set of rules they can interact, restrict, and correlate with one another. The rules define the conditions under which the agents react to the interactions with other agents. An image can be represented as a complex system where a high number of elementary agents or pixels adopt various states and interact in local neighborhoods. From their interactions, several different associations can be defined through rules to solve complex image processing problems such as segmentation, contrast enhancement, or filtering, to name a few.
In this section, the ICE problem will be faced considering an image as a complex system. Every pixel p i,j is associated with an agent A i,j which presents a cooperative/competitive behavior within its neighborhood N (i, j) of n × n elements. In our model, the interactions among the agents are characterized by the differences in the intensity values among the pixels or agents. Therefore, the behavior of an agent A i,j is determined by a set of rules that connect the relative grayscale differences between A i,j and the elements inside its neighborhood N (i, j). Consequently, the intensity value associated with A i,j can increase or decrease to produce different effects in the image as a consequence of incrementing the homogeneity or divergence of the block defined by N (i, j).
The operation of this model is iterative. Accordingly, the intensity value associated with each agent A i,j is modified in each iteration. Therefore, the intensity values of all agents modified in the iteration k represent the new scenario of interactions from which the new modifications will be done in the iteration k + 1. This process is repeated until a stop criterion has been reached.
To improve the contrast for an image, two different behaviors need to be intercalated. First, pixels or agents that present enough high differences in their intensity are modified to increase even more their differences. On the other hand, pixels or agents that maintain a very small difference are altered to assume a homogeneous intensity value. In the proposed approach, we have adopted two agent rules to model these behaviors. They are described as follows: A. RULE 1. FEATURE HIGHLIGHT Under this rule, pixels or agents that present enough high differences in their intensity values are modified to increase even more their differences. Therefore, assuming a neighborhood N (i, j) of 3 × 3 elements and a pixel configuration such as shown in Figure 1, firstly, each agent compares its intensity association value with its neighbors producing eight differences {s 1 , . . . , s 8 }. Each difference is generated as follows: where q ∈ (1, . . . , 8) . With this information, the final sign S of the neighborhood N (i, j) is determined. S is computed as follows: Under such conditions, S can produce three different results [−1, 0, 1]. Figure 1 shows the process to determine the value of the final sign of the complete neighborhood N (i, j). S = −1 represents that most of the pixels within N (i, j) have an intensity value higher than the agent A i,j . A value of S = 1 symbolizes that most of the pixels within N (i, j) present an intensity value lower than the agent A i,j . Finally, a value of S = 0 implies two distinct cases. The first one is that all   pixels inside N (i, j) present the same intensity value as the agent A i,j . The second one involves that half of the elements from N (i, j) are higher than A i,j whereas the another half is lower. Therefore, each agent A k i,j modifies its intensity value according to the following rule: Under this rule, if an agent A i,j is different than the rest of its neighbors, then it increases or decreases its intensity value in order to strengthen the contrast. This process is repeated until a stop criterion is reached. Figure 2 shows the effects of this rule in different stages of processing. As it can be seen in Figure 2, the differences among the agents are higher as the number of iterations also increases.

B. RULE 2. PATTERN SMOOTHING
Under this rule, pixels or agents that maintain a small difference in their intensities are altered to eliminate such discrepancies. This behavior is implemented through the following rule: Therefore, if an agent A i,j is different than the rest of its neighbors, then it increases or decreases its intensity value in order to homogenize the block of the neighborhood N (i, j). This rule is applied until a stop criterion is reached. Figure 3 shows the effects of this rule in different stages of processing. As can be seen in Figure 3, the differences among the agents are reduced as the number of iterations also increases.

C. AGENT-BASED CONTRAST ENHANCEMENT ALGORITHM
As can be seen in Figures 2 and 3, both rules have opposite effects that modify the resulting image, one highlighting the intensity differences and the other eliminating the discrepancies, respectively. Both rules modify de intensity value of each agent in different proportions and taking advantage of their characteristics. These rules complement each other giving as result a contrast-enhanced image. Therefore, to improve the contrast for an image, two different behaviors need to be intercalated. Taking this into account, the algorithm can be implemented in two simple steps: VOLUME 11, 2023 At the end of step 2, the algorithm will give a contrastenhanced image as a result. In Figure 3 the flow chart of the algorithm is exhibited.

IV. EXPERIMENTAL RESULTS
In other to evaluate the performance of the proposed ABICE scheme, a set of representative experiments has been conducted. The images contained in the TID2013 dataset [36] have been used. This dataset consists of 250 images distributed in 10 different sets produced from 25 reference images. Each group in the TID2013 dataset considers a different type of contrast. In our analysis, six performance indexes have been considered: Edge Preservation Index (EPI) [37], Range Redistribution (RR) [38], Structural Similarity Index Measurement (SSIM) [39], Entropy(E) [40], and Relative Enhancement Contrast (REC) [41] These indexes evaluate the quality of the processed image and have been adopted to be compatible with other works.
In order to calculate the different measures, an original image with an unsatisfactory contrast is defined as I O it's considered. Using this image as an input of the ICE method, an enhanced image I E is generated. Therefore, the EPI evaluates the conservation of the edges in the enhanced image I E with regard to the original image I O , a high value of EPI corresponds to better performance. The ileEPI value is computed as (5), shown at the bottom of the page.
The Range Redistribution (RR) index determines the way in which pixel intensities are distributed in the improved image I E . The RR index can be calculated as follows: where P(q) and P(r) are the probability density functions at the intensity values q and r, q, r, ∈ 0, 1, . . . , L − 1 of the image I E respectively. L represents the total number of grayscale levels represented in I E . A higher number of RR indicates a better distribution in the histogram without presenting intensity concentrations.
The SSIM index evaluates the similarity between the input image I O where µ I E and µ I O correspond to the mean values of the segmented and reference data respectively. σ I E and σ I O are the variance of the enhanced and the reference data, σ I E I o is the covariance of both data elements I E and I O finally, Q 1 and Q 2 symbolize two small positive constants (usually 0.001). The SSIM produces values in a range from 0 to 1. The entropy (E) is a quality measurement that indirectly evaluates the number of existing details in I E . Hence, with a larger value of E there is a higher information content in I E . The measure of E is calculated as: where P(q) is the probability density function at the intensity level q, q ∈ 0, 1, . . . , L − 1) of the enhanced image I E .
The experimental results are divided into two subsections, In the first subsection (A) the performance of the proposed ABICE is evaluated in terms of SSIM , EPI , E, REC and RR with regard to grayscale images. In the second section (B) the results of ABICE are extended for color images.

A. COMPARISON OVER GRAYSCALE IMAGES IN TERMS OF SSIM, EPI, E, RE, AND RR
In this subsection, the performance of the proposed scheme over grayscale images is analyzed. In the experiments, the ABICE is applied to all the low-contrast images contained in the TID2013 dataset. The results are compared with those produced by other well-known schemes in the literature such as Histogram Equalization (HE) [9], Gamma Correction [1], Contrast Limited Adaptive Histogram Equalization (CLAHE) [4], and Averaging Histogram Equalization (AVHE) [9], [42] all the algorithms have been configured with the same parameter values selected in their references representing according to them the best possible performance. In all the comparisons for the ABICE, the stop criteria for Rule 1 and Rule 2 were set in 4 and 8 iterations respectively. All experiments were performed on MatLab®R2019a on a Computer with an AMD Ryzen5 1600 3.6GHz processor and Windows 10 (64-bit, 16Gb or RAM) as its operating system.
With the objective to demonstrate the performance of the proposed ABICE approach for the compared image contrast enhancement techniques, the results in terms of six significative images of the previously mentioned indexes are registered in Table 1, and the average of all the images indexes in Table 1. For all de indexes, a higher value denotes a better performance.
The entropy index quantitatively evaluates the information content present in an image which makes it one of the best indexes to analyze the performance of a contrast enhancement method. As it can be seen in table 1, the ABICE method throws the higher average entropy value which evaluates the quality of the enhanced image in terms of its information content. On the other hand, the EPI and SSIM indexes are two factors that indirectly estimate the visual perception of the image, the evaluate the total information given by the edges present in the processed image. Hence, a higher value of both indexes represents a processed image that better preserves the important characteristics. As it's shown in table 1 on average, the proposed scheme reports the higher values in both indexes, meaning that the proposed algorithm has a better preservation of the important details in the image. it also is possible to see in table 2 that with a higher REC value, the proposed scheme shows a better performance with more contrast than its competitors. Another representative value is the range redistribution (RR) which evaluates the capacity of the algorithm to highlight hidden details. An algorithm that gives a high RR value image as an output indicates that more characteristics have been resalted from its processing.
In other to analyze the quantitative and qualitative results, a set of images I 1 − I 6 have been selected from the TID2013 dataset. All images are considered special cases due to their complexity. Table 2 presents the quantitative results among the algorithms for images I 1 − I 6 . The table reports the performance indexes previously mentioned.
From Table 2 it's possible to see that the ABICE scheme outperforms its competitors in the index's values. In general, the methods that show the worst results in terms of SSIM are Gamma correction and CLAHE. This may indicate that these algorithms had trouble preserving some important details in the visual perception of the image. On the other hand, it can be seen that these algorithms present good RR values but lower than the proposed ABICE algorithm, this can be seen in the visual results throwing brighter images that visually look with worst quality than the proposed scheme, this can be VOLUME 11, 2023  interpreted as the worst range distribution of the image levels in comparison with the proposed ABICE method.
In contrast enhancement schemes it is important to make a qualitative analysis of the resultant images besides the quantitative performance. This analysis aims to evaluate the presence of annoying distortions and other artifacts in the enhanced images attributed to a deficient operation of the algorithms. Figures 6 to 11 show the original gray image and its contrast enhancement results obtained by the proposed ABICE scheme and its competitors AHE, CLAHE, Gamma Correction, and HE methods. As can be seen, Gama Correction and CLAHE methods produce a relatively good image contrast enhancement, giving the Gamma Correction method an image that tends to take the intensities to the brighter zone mixing with it some important details making it difficult to appreciate them. On the other hand, in the CLAHE results the image is darker and tends to resalt the blacks, with this some details in the image are resalted however, there is a loss of some details present in the darker side of the dynamic range. Moreover, HE and AHE methods generate bad enhancement effects, since most of its images are dark and bright it is not possible to differentiate important details in the image. it can be appreciated that the proposed ABICE method presents a better visual perception that its competitors. In the enhanced images given by the algorithm important details and elements are clearly presented, while in the other methods there is a loss of certain sets and hidden structures. This can be related to rule 1 of the algorithm which increases the differences between the agents. In this subsection, the performance of the ABICE method has been extended to consider color Images. Its results are also compared with those given by schemes mentioned in the previous subsection.
In order to perform a Color Image Enhancement scheme, it is necessary to take the original RGB input image I RGB = {R, G, B} in red, green and blue format (RGB). Then transform it to the HSI space, I HSI = T {I RGB }. Once this transformation is done, the intensity channel I channel is processed for contrast enhancement as in the case of grayscale images. VOLUME 11, 2023   Finally, once the I channel is processed along with the planes H and S are transformed back into the RGB space.
With the aim to evaluate the performance of the scheme over color images, the same indexes used in the case of grayscale images were considered in our analysis: SSIM , EPI , E, REC, and RR. Additionally to these indexes, the Colorfulness (C) [43] index it's also included. This index expresses the color contents in an image from a visual 6072 VOLUME 11, 2023 A. Luque-Chang et al.: Agent-Based Image Contrast Enhancement Algorithm  perspective. With a higher value of C comes a better color perception. Considering R, G, and B as the color channels of an I RGB image, C can be calculated as follows: where In this metric the color perception is evaluated as a function of the mean µ and standard deviation σ of all pixels contained in the channel differences RG and YB defined as follows: The experiment was conducted with several color images extracted from the TID2013 dataset. However, in order to VOLUME 11, 2023    save space in the manuscript, a set of six representative images exhibited in Figure 11 has been considered. Table 3 shows the results in terms of SSIM , EPI , E, REC, RR, and C indexes for each image of Figure 11. According to this table, the proposed ABICE scheme obtains the best performance indexes among all the methods in the comparison. While the results were compared, the proposed method presents the best RR value, meaning that the proposed scheme has a better performance in the redistribution of the pixel values, giving a better contrast enhancement. Another metric that confirms this affirmation, is the results in terms of E, this allows to us see that after the process the algorithm preserves a higher information level. Furthermore, the proposed scheme throws a higher value in terms of relative contrast enhancement (REC). Another important metric analyzed is colorfulness(C) [43], as can be seen in Table 3 the proposed scheme gets the highest values. Under such conditions, it is possible to say that the ABICE method presents a more natural color in comparison with the original input image. Therefore, the enhanced visual images also show an adequate visual perception. After the analysis of Table 3, it is demonstrated that the proposed scheme exhibits the best values among the considered algorithms in terms of Most of the performance indexes. Finally, the worst results are exhibited by the AHE and HE methods respectively.
In order to analyze qualitatively the performance of the different ICE methods Figures 13-18 the visual results are depicted. After the analysis of each figure, it can be seen that the HE method is barely able to enhance the image contrast. This can be perceived due to a resultant image that might be either dark or brighter but with some kind of smooth causing a fine details loss in the image. In the case of the AHE method, with exception of Figure 12, the resultant images are slightly different from de input low-contrast image, giving as result dark images with an important loss of details in them. On the other hand, the Gamma − correction method (Gamma) give as result overexposed images that, if they can be perceived as overbright images presenting a fine detail loss. Furthermore, giving a high saturation perception in the images. After an analysis of the visual results obtained by the CLAHE scheme, it's possible to say that it performs a decent contrast image enhancement giving a balanced image in terms of brightness, and a good appreciation of details in the image. However, in the comparison between CLAHE and the proposed ABICE schemes, it can be appreciated a higher detail level given by the proposed method. Furthermore, the proposed method presents a balanced image in terms of brightness, this can be attributed to the combination of rules 1 and 2, which distribute the range to both visual ranges(dark and bright), and the details appreciated can be attributed to the application of rule 1 that improve the differences between each pixel value.

C. COMPARISON IN TERMS OF COMPUTATIONAL COST
Due to the problem characteristics, the algorithms used to give it a solution tend to a computational cost (CC) given by O(n 2 ). Hence, to compare the algorithms in terms of CC comparing the execution time in seconds (ts) is enough to decide which algorithm has a better performance in terms of CC. In Table 4 the mean execution time of the ABIC, AHE, CLAHE, Gamma Correction, and HE schemes over all the images in the TID2013 dataset is presented. After a revision of Table 4, it's clear that the proposed ABICE method has the lowest execution time. This can be related to the simplicity of the operations in rules 1 and 2 for each agent.

V. CONCLUSION
This paper proposes a two-step method where pixels in the processed image are considered agents whose behavioral rules permit to enhance significatively the contrast. In our approach, the interactions among the agents are characterized by the differences of the intensity values among the pixels or agents. In the first step, pixels or agents that present enough high differences in their intensity are modified to increase even more their differences. In the second step, pixels or agents that maintain a very small difference are altered to assume a homogeneous intensity value. These two behaviors have been implemented through two different agent rules.
The performance of the proposed ABICE scheme has been tested considering a representative set of different color and grayscale images from the TID 2013 data set. Its results were also compared with those produced by other well-known techniques such as Histogram Equalization (HE), Gamma Correction, Contrast Limited Adaptive Histogram Equalization (CLAHE), and Averaging Histogram Equalization (AVHE). Experimental results suggest that the proposed method has a better performance in comparison to other schemes in terms of different performance indexes that evaluate the enhancement quality.
As future work is planned to improve the algorithm efficiency using parallel programming due to its characteristics. Another idea is to implement stop criteria based on how the contrast enhancement increases using the original image as an input and a non-referential contrast measure. Other ideas lead to applying the proposed scheme to areas of interest such as satellite images, and medical images among others. VOLUME 11, 2023