## 4 Methods
### Mosaic of borehole Video  
#### 4.3.1 Mosaic Principle of the Borehole Wall Image  
After locating the drilled hole center, the movement of the camera in the borehole could be decomposed into the axial beeline motion and circumferential rotation motion. In Figure 6, the frames A and B were used to simulate two continuous frames of front view borehole-wall images, where the green region was the annular effective region used for the image unwrapping and the blue oval was the fracture. While shooting the frame B, the camera produced a forward motion and rotation motion along the central axis of the drilled hole, which corresponded to the radial offset and angular offset (\(\beta\)-\(\alpha\)) relative to frame A, respectively.  
Figure 5: Virtual coordinate graph.  
The corresponding two rectangular images were created from two continuous frames of front view images by the proposed image unwrapping algorithm, and then were used for the image mosaic, as depicted in Figure 7. The relative displacement of rectangular images could be divided into vertical and horizontal offsets, corresponding to the radial and angular offsets of front view images respectively. These two offset values constituted the final mosaic parameters and were used to implement the mosaic of the unfolded image sequence in the axial direction and rotation correction in the horizontal direction, respectively. Since the rectangular images were generated from the annular images, the horizontal displacement region caused by camera rotation (the yellow rectangular area shown in Figure 7) could be cut to the red blank dotted rectangular area to realize the rotation correction. Therefore, the rectangular images were stitched together as one single cylindrical panorama in the axial direction according to the vertical offset between consecutive frames. In the image mosaic process, template matching (TM) was chosen to calculate the mosaic parameters.  
The objective of TM is to establish the correspondence between the source image and the examined image. TM is a process to locate the position of predefined template in the examined image, which is widely used in object detection, target tracking, image mosaic and so on. There are many kinds of TM methods, the application of which should depend on the specific circumstances of provided images and intended application. TM is illustrated in Figure 8. A template is chosen in a source image, and a search area (green area in Figure 8) is defined in an examined image. In the matching process, to find the sub-image matching with the template, the template is shifted through every location of the search area in the examined image to recognize the most similar candidate image of the same size (image part under template). In this paper, the first frame of the video sequence will initially act as the source image, and the second frame was used as the examined image. These two images were stitched together into a whole image as a new source image by the template matching method, and then matched with the third frame to update the source image. In this way, the mosaic of the whole video sequence could be successfully completed.  
Figure 8: Schematic diagram of the template matching.  
Figure 6: The relative motion of two front view borehole-wall images.  
Figure 7: The mosaic principle of unfolded images.