# Intelligent Fusion Imaging Photonics for Real-Time Lighting Obstructions
## 4 Methods
### IF Algorithm  
The IF algorithm was developed to serve two different purposes: high image quality output and high response time. Image Fusion aimed to utilize the captured data to generate a high-quality image with minimal lighting obstructions. Iterative polarization can provide a high response time for utilization in dynamic scenarios. Thus, the IF algorithm applied two methods: Image Domain Focus Scanning (Figure S4) and Time Domain Focus Scanning (Figure S5), to create a versatile algorithm fitting different environments.  
**Fusion:** Image Fusion utilized the available data to construct an image with minimal lighting obstructions. As the images captured by the iNC/CMOS were stored in memory, the images were compared to analyze the impact of lighting obstructions at different polarization angles on a per-pixel basis. This is possible because the images vary purely on the polarization domain and by capturing the images at different polarization angles, the image space was segmented independent of spatial relations. In our work, the image space was segmented up to \(\left\lfloor\frac{180}{\theta_{resol}}\right\rfloor+1\) meaningful segments where \(\theta_{resol}\) is the polarization resolution, and each segment represents the unobstructed scene (\(I_{IF}\)) with the lighting obstructions at polarization \(\frac{\pi}{2}+\theta_{resol}\)\(k\) in the image domain, where \(k\) is the segment index. If a region of the image was impacted by lighting obstructions, the variance of intensity of a pixel between each index should be between \(I_{k}\ \cos^{2}\!\left(\theta_{optimal}-\frac{\theta_{resol}}{2}\right)<I_{k+1}<I_{k} \ \cos^{2}\!\left(\theta_{optimal}+\frac{\theta_{resol}}{2}\right)\) where \(I_{k}\) is the previous image, \(I_{k+1}\) is the current image, and \(\theta_{optimal}\) is the actual polarization angle of the lighting obstruction. As \(\theta_{optimal}\) was unknown, \(\frac{\pi}{4}\) was used in place of \(\theta_{optimal}\) to support maximum variance. The algorithm  
Then the next image was captured at polarization index 1. The binary validation matrix was calculated along with the weights of the two images. If the weight of the current image was greater than the previous image, the directionality of the polarizer was inverted, and the next image was captured at polarization index 0. However, if the new image had a weight lower than the previous image, the polarizer continued to step in the same direction, capturing the next image at polarization index 2. This process stopped when there were \(N\) consecutive frames where the weight difference between images were below the impact threshold, \(T_{min}\). As the algorithm continuously updated the binary validation matrix and the weights, the fusion image was also updated after each frame, where if a pixel was valid, the fusion image pixel was updated using the pixel value with lower weight. The time domain focus scanning algorithm has a safeguard to protect against dynamic objects where if more than third of the validation matrix values turned to 0, all previous data were removed, and the process restarted.