# A Seamless Image-Stitching Method Based on Human Visual Discrimination and Attention
## 3 Methods
### Optimal Stitching Line Detection and Smoothing  
In Section 3.1.3, the overlap area is segmented into smoothing areas, texture areas and other areas. We have clarified that selecting seamless in smoothing and texture areas can minimize the impact on image quality. In fact, some overlapping strong edge areas in other areas, also called safe strong edge areas, can also be used as candidate areas. Considering the phenomenon mentioned above, a reference edge map based on edge detection algorithm Canny is used for judging whether an edge pixel is a stitching line candidate or not.  
An optimal stitching line is almost invisible when it produces few discontinuous strong edges and the discontinuous weak edges are masked or located in low-saliency areas. The first step of locating the optimal stitching line is to set the two intersections of input image pair's boundaries after transforming to starting pixel and terminal pixel, respectively. Then all pixels in overlap region are divided into candidates and invalid pixels. The candidates comprise the pixels in smoothing regions or texture regions and safe strong edge pixels. Then, the dynamic programming goes into operation at the starting pixel. A parameter \(D_{ref}\) related to the distance to terminal point for each pixel is added to make sure the stitching line ends at the terminal point. \(D_{ref}\) is defined as the inverse of the Euclidean distance between the pixel under computing and the terminal one. During this procedure, we choose the adjacent candidate with the maximum WM\({}_{ref}\) as the next stitching line pixel. The chosen pixels are then added into the invalid point set for searching. The program will keep searching the ending point until it makes it. WM\({}_{ref}\) can be calculated by Equation (10):  
\[\text{WM}_{ref}=\text{WM}+D_{ref}, \tag{10}\]  
and then the obtained stitching line is simplified after the former process to then trace the final stitching line.  
Considering the diversity of the photographic circumstances and image sensors, the luminance difference cannot be ignored even though the stitching line has already reduced its impact; thus, the post processes such as white balance and illumination compensation are beneficial to obtain a visually comfortable mosaic image. In the fusion phase, the overlap area is divided into two parts by the stitching line based on HVS. The left part of mosaic image is filled by the left input image, while the other is filled by the right one. The transition is smoothed by a multi-band blending algorithm.  
The multi-band blending algorithm gives a significant result by retaining useful image information at different scales. In the first step this algorithm decomposes the image pairs into a set of band-pass filtered component images called Gaussian pyramid and Laplacian pyramid. Next, the component images in each spatial frequency band are assembled into a corresponding band-pass mosaic. Finally, these band-pass images are integrated to obtain the mosaic image. The macro features of the image are in the low-frequency component images, while the local characteristics are retained in the high-frequency ones. Therefore, a stitching line in the resultant mosaic image is almost invisible.