Batch Processing of Remote Sensing Image Mosaic based on Python

— In the process of remote sensing image processing, analysis and interpretation, it is usually necessary to combine several local images into a complete image. Aiming at the shortcoming of long and complicated process of conventional semi-automatic video stitching. In this paper, using the splicing method of pixels, based on the Python interface of ArcGIS 10.1 platform, the idea of programming language is introduced and batch mosaic of remote sensing images is realized. Through the comparison with the image processing software, it is found that this method can shorten the time of image mosaic and improve the efficiency of splicing, which is convenient for later image analysis and other work under the premise of ensuring the accuracy.


Introduction
Remote sensing image mosaic is a part can't be ignored in the development of remote sensing, image mosaic is the understanding and analysis of terrain, physiognomy and monitoring work on the basis of natural disasters on the utilization of land resources [1][2]. Because the image amplitude of the sensor has a certain limit, and most of the single remote sensing images can not completely cover the study area, so many images need to be spliced into the desired complete target image.
The mosaic method of images has gradually matured. Taking the ENVI remote sensing image processing platform as an example, the more commonly used mosaic based on geographic coordinates usually requires that the image have the same number of bands, mainly refer to the map projection information of the overlapped regions, and match the brightness values to complete the stitching. Secondly, the pixel based splicing method is mainly to resample the gray value of the overlapped region in a linear or interpolated way, so as to obtain the pixel gray value of the mosaic image so as to achieve the purpose of mosaic.
In view of the following parts of the image mosaic process, scholars at home and abroad have also made research. At present, there is a parallel processing technology based on GPU and CPU. Based on the combination of morphology and Dijkstra, the image mosaic method of unmanned aerial vehicle (UAV) image is quickly embedded in [3][4][5]. With the optimization of image processing platform, the problem that should be solved at present should be the efficiency of remote sensing image mosaic.
In order to solve the problem of huge workload, cumbersome operation and low overall efficiency in the manual mosaic of multiple images. In this paper, the idea of programming language is introduced to realize automatic splicing, mainly based on the Python interface of ArcGIS 10.1. By obtaining the coordinate system of the image, the width of the grid unit is calculated, the number of bands is obtained and the batch printing is obtained, thus the transition of multiple single images to the target image is realized. Through the contrast of different number of images, the image mosaic based on Python is carried out, and the efficiency comparison experiment is carried out under the premise of guaranteeing accuracy.

2
Image mosaic

Image geometric correction
Geometric correction is the process of eliminating or correcting geometric errors of remote sensing images. In the process of imaging, the main causes of the geometric distortion of remote sensing images are the position and motion state of the remote sensing platform, the terrain fluctuation, the curvature of the earth's surface, the refraction of the atmosphere and the earth rotation, which are mainly represented by the extrusion, distortion, stretching and migration of the actual position of the pixel relative to the ground target. Therefore, geometric correction is needed for these distortions [6][7]. The main methods of geometric correction are: remote sensing image correction based on polynomial, correction of remote sensing image based on collinear equation, remote sensing image correction based on rational function, and small surface element differential correction based on automatic registration. The geometric correction schematic diagram is shown in Figure 1. Polynomial based geometric correction method: first, the spatial transformation of image coordinates. It is necessary to build a polynomial correction model to establish the correspondence between the base image and the corrected image, which is usually two yuan n polynomial, such as formula 2.1 and formula 2.2.
Among them, x, y for pixel original image coordinates, X, Y as the correction of the ground coordinates, the different selection of n value, can get different spatial transformation. Theoretically, the greater the n value, the more the correction of complex geometric distortion, in practical applications, n usually takes less than 3 values. Then select the same name point (GCP) for image coordinate space transformation. N polynomial, select at least (n+1)*(n+2) /2 ground control point on the base image and the uncorrected image. In order to make the geometric correction result better, the number of control points is far greater than the minimum number, which can be 6 times as much as the minimum number. The selection of ground control points should follow the following principles: Based on the registration object, select the easily distinguishable and accurate points on the image, such as the road intersection, the river fork, and so on; the image edge selects a certain number of feature points; the feature points should be evenly distributed on the whole image. Finally, the image pixel gray value resampling is carried out. In order to get the brightness values of each point on the image, the luminance value of each pixel in the image should be calculated according to certain rules, that is to resampling the image [8][9][10]. The commonly used methods are: nearest neighbor, bilinear interpolation and three convolution.

Cut line
The cutting line is in the inlay process, which exists in the overlapping area of two adjacent graphs, and a line is selected as the connection line of the two graphs according to certain rules. It can improve the problem which has a larger difference at the edge. The border lines usually choose rivers, roads, and other ground objects in overlapping areas to avoid high altitude buildings, such as buildings, bridges, etc., and to draw cutting lines along the river or road.

Feather processing
After geometric splicing, the corrected multiple images will form the entire image, which makes the edges of the entire image inlaid after the geometry become blurred, so that it can be well integrated into the image. According to the radius of feather, it can be feather along the edge or cut line. Therefore, feather can be divided into the emergence of edges and the cutting of line feathers.
Cutting line feathering. The principle of cutting line feathering is shown in Figure 2. The image is evenly processed within the specified range of cutting lines. If the specified distance is 20 pixels, 100% of the top image and 0% bottom image will be mixed and output mosaic images at the cutting line. Apart from the cutting distance (20 pixels), 0% of the top image and 100% of the bottom image will output the mosaic im-age. At the distance of 10 pixels from the edge line, the top and bottom images will be mixed to calculate the output mosaic image using 50%.  Figure 3. The image is evenly processed according to the specified pixel distance. If the specified distance is 20 pixels, 0% of the top image and 100% bottom image will be mixed at the edge to output the mosaic image. At the specified distance (20 pixels) from the sideline, there will be 100% top images and 0% bottom images to output mosaic images. At the distance of 10 pixels from the edge line, the top and bottom images will be mixed to calculate the output mosaic image using 50%.

Tone adjustment
In the process of image mosaic, it is necessary to avoid the phenomenon of color inconsistency and affect the effect of mosaic. Tone adjustment is an important part of image mosaic quality. Based on a pair of images, the histogram of each mosaic image is counted, and the histogram matching is used to match the other images, which makes the mosaic image have similar gray features.

3
Experimental analysis

Data description
In the use of ENVI software for image mosaic, it is necessary to edit the attributes of each image. When the mass image is operated, the process is more complicated and easy to miss the attribute editing of the image. If the selection of the base image is not appropriate, the image of the splicing failure will appear, so this paper proposes to use P in this paper. Python is used for batch image mosaic, and its running platform is ArcGIS 10.1.
Taking the DEM digital elevation data of Liaoning Province as an example, the latitude and longitude of Liaoning province is N38° 43 '~N43° 26', E118° 53 '~E123° 13', so the digital elevation data of 10 ASTER GDEM V2 in N39_E121~N39_E12 and N40_E121~N40_E125 range are obtained, and their resolution is 30 m. In order to facilitate the program to identify the data source, first of all, the preprocessed DEM data file is named *dem.tif format, and then it is stored in the same folder.

Batch mosaic based on Python
In the program, the working directory is set, that is, the storage directory of the image data; then a image under the working directory is designated as the base image to prepare for the later parameters extraction. Before splicing, the coordinate system, data type, pixel type, the width of the grid unit and the number of band number are needed to prepare the image mosaic, and the above parameters are output for the convenience of operation, as shown in Figure 4. Based on the idea of Python programming, the image coordinate system is first obtained. Generally, the remote sensing image belongs to the WGS-84 geodetic coordinate system, and the width of the grid unit is calculated by the modular language. Thus the number of bands is obtained, the batch printing and output are made, and the file name of the image to be spliced is extracted, and it is used in the working space. There are images that end with *dem.tif, and a number of *dem.tif images are embedded into one image, and the result is output to the specified folder. The following figure is the information of the output image parameters.

Comparison and analysis of results
The results of the mosaic results of ENVI software and the results of batch mosaic using Python are compared in ENVI, respectively, as in Figure 5 and Figure 6, respectively, the results of the above two kinds of mosaic. The two mosaic results are opened in ENVI and linked together for comparison. Pixel information is slightly different, as shown in Figure 7. A slight difference in pixel information has little effect on stitching effect and can be ignored. In the later period, the fifteen images and twenty images were stitching and compared. In the software, the stitching failed because of the improper selection of the reference image, and then the splicing image was modified to succeed. Through the completion time of two splicing methods, the time used for Python based stitching is based on 1/10 of the ENVI splicing, which can greatly improve the working efficiency, and it is easy to operate and is suitable for most of the working environment.

Conclusions
Image mosaic is an indispensable part of the development of remote sensing, and the means of mosaic are also constantly innovation. Now most of the operations are semi automated manual operation using software, the operation process is different, and it is very easy to make mistakes. Based on the above problems, this paper introduces the idea of programming language to realize automatic splicing, which is based on the Python interface of ArcGIS 10.1, and realizes the transition from multiple single images to target images. Through the contrast experiment of different numbers of images, it is found that the image stitching based on Python can improve the efficiency obviously on the premise of guaranteeing the accuracy, and can save the necessary time for the later image processing work, and it has certain guiding significance and reference value for similar image stitching.