# GS-AGC: An Adaptive Glare Suppression Algorithm Based on Regional Brightness Perception
## 3 An Adaptive Glare Suppression ALGORITHM Based on Regional Brightness Perception
### Gs-Agc
We treat the glare region as follows:  
\[G_{glare}=\left[\log\left(\frac{\tau_{t2}+\tau_{t3}}{2}\right)/\log\left(\frac {\tau_{t4}+T_{255}}{2}\right)\right]^{R_{2}} \tag{10}\]  
where \(R=3\), \(T_{255}\) is the gray level value 255, the glare suppression function \(G_{\text{glare}}\) makes the grayscale image pixels close to the maximum gray value of the bright scene \(\log\left(\frac{\tau_{t4}+T_{255}}{2}\right)\), close to the mid-bright scene \(\log\left(\frac{\tau_{t4}+T_{255}}{2}\right)\) to reduce the visual difference, and the \(G_{\text{glare}}\) function makes the region between the threshold parameter of the bright scene and the threshold parameter of the mid-bright scene (\(\left(\frac{\tau_{t4}+T_{255}}{2}\right)\), T\({}_{255}\)) and its corresponding Gamma value both greater than 1. There is another function to control the removal of dark light, halo, and glare of the other brightness region, \(\left(\left(\frac{T_{0}+\tau_{t1}}{2}\right),\,\left(\frac{\tau_{t2}+\tau_{t3} }{2}\right)\right)\), \(\left(\tau_{t4},\,\left(\frac{\tau_{t4}+T_{255}}{2}\right)\right)\). The main role of the other regions of brightness is to remain unchanged:  
\[G_{other}=1 \tag{11}\]  
The flowchart of the GS-AGC algorithm proposed by us is displayed in Figure 5, while the steps of the algorithm are exhibited in Algorithm 2. It is worth mentioning that the suppression algorithm proposed by us can be adjusted in a specific luminance region by regional luminance pixels, resulting in the enhancement of the overall low-light image based on local glare suppression and the maintenance of a balanced state of image luminance. ```
1: Get the grayscale map \(\text{I}_{\text{gray}}\) of the input image I. 2: Obtain the brightness threshold of the image, \(\tau_{t}\), according to Equation (4). 3: Calculate the pixels in the dark light region of the processed image according to Equation (8), \(G_{\text{dark}}(\tau_{t1},\tau_{t2},\tau_{t3})\), where \(\tau_{t1},\tau_{t2},\tau_{t3}\) are derived from the luminance threshold \(\tau_{t}\) of Equation (4). 4: Adjustment of the image halation region pixels according to Equation (9), \(G_{\text{halo}}(\tau_{t2},\tau_{t3},\tau_{t4})\), where the luminance threshold parameters \(\tau_{t2},\tau_{t3},\tau_{t4}\) are also derived from Equation (4). 5: The image glare region pixels are processed according to Equation (10), \(G_{\text{glare}}(\tau_{t2},\tau_{t3},\tau_{t4})\), the rest of the luminance is adjusted by Equation (11), and the luminance threshold parameters \(\tau_{t2},\tau_{t3},\tau_{t4}\) are also derived from Equation (4). 6: Output the image after all processing according to Equation (7). ### FPGA Implementation of the Algorithm

#### 3.3.1 Image Processing Framework on FPGA Platforms

FPGA, a programmable logic device, was utilized in this study to accelerate the algorithms on the hardware platform. It offers programmability, high performance, low power consumption, and robust security. Leveraging FPGA's hardware architecture characteristics, the entire system's input and output were facilitated via a USB interface. The development methodology employed comprised High-Level Synthesis (HLS) description, along with co-programming using Python, C, and Verilog hardware description language. These approaches harnessed FPGA's high data throughput, computational prowess, and parallelization capabilities to achieve accelerated execution of the algorithms discussed in this paper. Figure 6 illustrates the image processing framework employed in the glare suppression system. The framework utilizes the AXI4 Stream protocol, which enables stream-oriented transmission without the need for memory addresses and without restricting burst length. This protocol is well-suited for high-speed big data applications. Consequently, the entire image processing framework is built upon the ARM AMBA AXI4 protocol. This choice ensures that the overall framework possesses high bandwidth, low latency, and low power consumption, among other characteristics.