# Pixel Interaction Model for Contrast Enhancement: Bridging Social Science and Image Processing
## 3 Proposed Method
### Computational Procedure  
Once the mechanisms of the proposed approach are described, the proposed algorithm will be entirely analyzed in this section. Algorithm 1 details the entire computational process and serves as a comprehensive guide for implementing this technique. This algorithm outlines each step systematically, ensuring clarity and efficiency in execution. A set of N agents is arranged within a grid of m \(\times\) n elements. At the outset, each intensity value \(\mathrm{p_{ij}}\) corresponds directly to a pixel from image I, establishing a foundational link between the agents and their visual representation. After initialization, the algorithm is applied until a maximum number of iterations, itermax, is reached. The image is scanned pixel by pixel during each iteration, from top to bottom and right to left. For each \(\mathrm{p_{ij}}\), a second pixel \(\mathrm{p_{\alpha,r}}\) is randomly selected from its eight neighboring pixels to create a pair. Afterward, the difference in intensities between them is calculated. If the difference is below the threshold u, the algorithm adjusts their intensity values to reduce the disparity by decreasing the higher value and increasing the lower value. If the difference exceeds u, it indicates significant contrast, and the algorithm increases the difference by further amplifying the intensity of the higher-valued pixel while reducing the lower one. This process continues until a stopping criterion is met, enhancing the image contrast. ```
1:Input: I, \(\mathrm{itermax},\mathrm{u},\mathrm{\gamma_{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{  }}}}}}}}}}}}}}}}}\), \(\mathrm{k}=0\)
2:while\(\mathrm{k}\leq\mathrm{itermax}\)
3:for\(\mathrm{i}=1:\mathrm{m}\)
4:for\(\mathrm{j}=1:\mathrm{n}\)
5:\(\mathrm{p_{\alpha r}}\leftarrow\mathrm{SelectIndividualNeighbor}\left(\mathrm{p_{ij}}\right)\)
6:\(\mathrm{d}\leftarrow\left|\mathrm{p_{ij}}-\mathrm{p_{\alpha r}}\right|\)
7:if\(\mathrm{d}\leq\mathrm{u}\)
8:\(\mathrm{p_{ij}}\left(\mathrm{k}+1\right)=\mathrm{p_{ij}}(\mathrm{k})\mp \mathrm{\gamma_{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{ \mathrm{  \mathrm{    }}}}}}}}}}}}}}}}\)
```
9:\(\mathrm{p_{\alpha r}}(\mathrm{k}+1)=\mathrm{p_{\alpha r}}(\mathrm{k})\pm \mathrm{\gamma_{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{ \mathrm{  \mathrm{   \mathrm{    }}}}}}}}}}}}}}}} \mathrm{p_{\mathrm{\alpha r}}}\)
10:Else
11:\(\mathrm{p_{ij}}(\mathrm{k}+1)=\mathrm{p_{ij}}(\mathrm{k})\pm\mathrm{\gamma_{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{ \mathrm{ \mathrm{ \mathrm{      }}}}}}}}}}}}}}}} \mathrm{q}}\)
12:\(\mathrm{p_{\alpha r}}(\mathrm{k}+1)=\mathrm{p_{\alpha r}}(\mathrm{k})\mp \mathrm{\gamma_{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{\mathrm{ \mathrm{\mathrm{\mathrm{ \mathrm{ \mathrm{    \mathrm{      }}}}}}}}}}}}}}} \mathrm{q}}\)
13:endiffor
14:endwhile
15:Output: I  
Figure 5: The behavior of the function used to determine the value of u from d for contrast enhancement. It demonstrates how the value of u changes in relation to the difference d between pixel intensity values. In order to showcase the functionality of the proposed method, Figure 6 illustrates the result of iterative changes in intensity on an image. The image used as input for the algorithm is depicted in Figure 6a, featuring two distinct areas with varying intensity levels. The first region's pixels use a Gaussian distribution with a mean of 50 and a standard deviation of \(20(\mathrm{N}(50,20))\).