# A Drone-Enabled Approach for Gas Leak Detection Using Optical Flow Analysis +
## 3 Methodology
### Image Stream Stabilization  
Despite the benefits introduced by using aerial platforms for inspection of industrial sites, some challenges may need to be addressed to open the door for employing drones in various applications. One of the open areas that certainly can take great benefit of using drones, is where constant monitoring and data acquisition of an area using a thermal camera for a period of time, is required. Normally, it is expected that both the camera and the specimen maintain their position to accurately analyze the temporal changes in thermal behavior. This presumption can be problematic in a drone-based inspection as the drone may experience slight movements while hovering which can disturb the post-analysis. Therefore, using a stabilization method to remove undesired motions, is a necessary step in these applications. Generally, image stream stabilization methods can be categorized into spatial and frequency domain techniques. Spatial-domain techniques use intensity patterns or features to match images and define the proper transformation model. On the other hand, frequency-domain methods determine the transformation parameters while operating in the transform domain. Spatial-domain methods normally have higher accuracy and are able to detect large transformations, but they need more computation resources. Moreover, they mostly require a certain amount of feature points to be able to minimize the estimation error. On the other hand, frequency-domain approaches define the transformation model including rotation, translation, and scale by their counterparts in the frequency domain. They are different from other methods because they look for the optimal match based on the information available in the frequency domain [25]. Phase correlation is a frequency-domain based method for image registration. Unlike spatial-domain methods, phase correlation is resilient to noise and other defects. In addition, they have lower time-complexity which makes them suitable for real-time applications using embedded systems with limited resources. One of the problems with image alignment based on correlation is that they cannot accurately define the transformation model when there is a large rotation or scale factor [26]. In this study, the main objective of using a stabilization method is to minimize the effect of the drone's unexpected motions while hovering because the presented gas leak detection method is sensitive to motions and changes in the environment. Here, a comparative analysis is conducted between four candidate methods: (a) a feature-based method with moving averaging filter for smoothing (AVS) [27], (b) a stabilization method with robust L1 optimal camera path (L1-OP) [28], (c) an approach based on phase correlation (PC-RF), and (d) an optimization-based stabilization method (OPC) [29]. The stabilization step involves the following steps: (a) perform the stabilization on the buffered frames and (c) crop out black borders resulted from the stabilization method. The phase correlation approach is a two-steps stabilization method. In this method, the first frame is considered as a reference frame, then the phase correlation method is employed to generate the preliminary transformation matrix for prealignment of the reference and current frames. Phase correlation is a frequency-domain technique providing an estimation of the rigid transformation model between two images based on Fourier shift property [30]. Then, an intensity-based image registration technique explained in [31; 32] is used to minimize the registration error. The method is an iterative optimization-based technique that uses the two frames as a similarity metric to optimize the transformation matrix initially generated by the phase correlation method. Finally, the transformation matrices are combined to align each frame to the previous frames based on the reference frame using Equation (1), where \(T_{n}{}^{G}\) is the absolute transformation based on the reference frame and \(T_{n}\) is the transformation matrix of frame \(n\).