## 2 Method
### Method of Label Images Synthesis
#### 2.1.1 Improved Image Quilting  
In order to ensure the efficiency and quality of the generated images, this study proposes a fast and efficient image synthesis method that is based on the Image Quitting algorithm. The speed of image synthesis is greatly improved with guaranteed quality of images using the gradient and color information of the edges in the image obtained via the database technology. In the Image Quilting, the image is synthesized by calculating the total error of overlap of the blocks to be synthesized and the synthesized one, and the color error is introduced as similarity metric. \[cost=\sum_{ \begin{array}{c}p\in N_{1},q\in N_{2}\\ N_{1},N_{1}\in overlap\end{array} }\sqrt{\left(R(p)-R(q)\right)^{2}+\left(G(p)-G (q)\right)^{2}+\left(B(p)-B(q)\right)^{2}} \tag{1}\]  
where the \(cost\) is the error of two texture blocks in the overlap area \(N\), and \(R\), \(G\), and \(B\) are the values of three primary colors, respectively. Obviously, the similarity is higher if the error of two texture blocks is smaller. Since the asphalt is made up of bitumen and small gravels whose structural feature is more prominent, the synthesized images of asphalt are readily distorted and mismatched, thus taking the color error as the only similarity metric is obviously unreasonable. Moreover, each new texture block to be synthesized is selected randomly and the similarity is calculated repeatedly. Only if the similarity meets the requirement of similarity metric, the new block could be stitched to the synthesized area. Obviously, the image synthesis is time-consuming, and as a result the synthesis time is disturbed by the similarity metric. A small metric would prolong the image synthesis. Therefore, an improved algorithm for image synthesis that is based on Image Quilting is proposed and the improvements are as follows:  
1. Improvement of similarity matching metric  
The gradient that represents the structure is added to the RGB and feature information on the texture block is defined by:  
\[info(N)=\sum_{p\in N}\left[\alpha[R(p)+G(p)+B(p)]+\beta grad(p)\right] \tag{2}\]  
where \(p\) denotes the pixel and grad is the gradient of the image. Furthermore, \(\alpha\) and \(\beta\) represent the contribution coefficients of color and gradient, respectively, and they satisfy condition \(\alpha+\beta=1\). The definitions of \(\alpha\) and \(\beta\) are:  
\[\alpha=\frac{\sum\limits_{p\in N}[R(p)+G(p)+B(p)]}{\sum\limits_{p\in N}[R(p)+G (p)+B(p)+grad(p)]} \tag{3}\]  
\[\beta=\frac{\sum\limits_{p\in N}grad(p)}{\sum\limits_{p\in N}[R(p)+G(p)+B(p)+ grad(p)]} \tag{4}\]  
The cumulative error of the overlap area is defined by:  
\[cost=\left|info(N_{1})-info(N_{2})\right| \tag{5}\]  
2. Improvement of texture block selection  
Since selecting a new texture block in a random way for image synthesis is time-consuming in the Image Quilting algorithm. An alternative method is introduced to accelerate the selection of textureblocks. Before the image is synthesized, feature information on the edge of texture blocks is calculated by (2) and is stored into the database. Smaller cost means higher similarity. However, if the size of overlap area and blocks' type change, the value of cost may change as well. For improving the versatility, a similarity of texture blocks is defined by:  
\[\lambda=\left(1-\frac{\left|info(A^{\prime})-info(B^{\prime})\right|}{info(A^{ \prime})}\right)\times 100\% \tag{6}\]  
The \(\lambda_{0}\) is considered as a minimum of similarity metric and each similarity in the overlap should meet the condition \(\lambda\geq\lambda_{0}\). Thus, the required feature information of the corresponding border at the required block is limited by:  
\[\lambda_{o}info\big{(}A^{\prime}\big{)}\leq info\big{(}B^{\prime}\big{)}\leq(2 -\lambda_{o})info\big{(}A^{\prime}\big{)} \tag{7}\]  
During the process of image synthesis, the first block is selected in a random way and is placed on the top left of the area to be synthesized.