# An Automatic Detection Method for Cutting Path of Chips in Wafer
## 2 Materials and Methods
### Automatic Detection Algorithm of Chip Cutting Path
#### 2.3.4 Determination of Cutting Path  
Because the template matching result inevitably has a deviation from the center of gravity of the chip region, when the deviation exceeds the safety threshold, the laser cutter will damage the chip when cutting the wafer along the cutting path determined by the matching result. However, the interlayer is still in the matching area, so the street can be located according to the interlayer, and then the cutting path can be determined. In order to solve the impact of template matching deviation, we found the location of the interlayer in the determined chip region. The interlayer is the white area marked with B in Figure 3. There is an obvious gray level change between the interlayer and the adjacent area. When the gray level changes from left to right or from right to left, the gray level value of the pixel closer to the interlayer is larger and the change is more intense. According to this feature, the interlayer positions on the left and right sides of the chip area are determined. According to the obvious gray-level change on both sides of the interlayer, when the gray-level value suddenly changes dramatically in the search process, this position is considered the edge of the interlayer. In order to improve the stability of searching for the interlayer, when searching for the interlayer, the sum of the gray values of ten vertically adjacent pixels was taken as the evaluation value of peak detection, and then the interlayer position was determined according to the area where the interlayer is located, as determined in the previous section. In order to eliminate the influence of pixel value fluctuation, when the difference between the peak and valley is greater than 1, it is considered an effective peak. The first effective peak is located at the edge of the interlayer and marked with discrete points, as shown by the green discrete points in Figure 3. The discrete points on the left side of the chip are marked as \(P_{jL}^{q}\) and the right discrete point is marked as \(P_{jR}^{q}\). Q represents the number of discrete points and \(j\) represents the number of columns of the chip. The cutting path is determined by the marked discrete points. The improved RANSAC algorithm is used to fit the discrete points. During the fitting process, the fitting line will be constantly modified to remove the abnormal discrete points and reduce the influence of incorrect judgment of the interlayer. The RANSAC algorithm is shown in Formula (16):  
\[L=ransac\big{(}\big{\{}p_{1},\cdots,p_{Q}\big{\}},\rho,d,\alpha\big{)} \tag{16}\]  
where \(L\) is the determined fitting straight line, \(\{p_{1},\ldots,p_{Q}\}\) is \(q\) discrete points to be fitted, \(\rho\) is the number of discrete points randomly selected for fitting, and it is considered that when the distance between the discrete point and the fitting straight line exceeds \(d\), it is an abnormal point. \(\alpha\) is the proportion of assumed normal discrete points in the data, and assuming that the fitting straight line needs to be iterated \(k\) times, the probability of at least one abnormal point at the selected point during fitting is \(1-\alpha^{p}\) and the probability of randomly selected p points as normal points is:  
\[z=1-(1-\alpha^{p})^{k} \tag{17}\]  
According to Equation (17), the number of iterations is:  
\[k=\frac{\log(1-z)}{\log(1-\alpha^{p})} \tag{18}\]In iteration \(k\), we select the fitting line with the least abnormal points as the final fitting result, and the fitting on the left side of the column \(j\) of chip regions is:  
\[L^{O}_{jL}:y^{O}_{jL}=a^{O}_{jL}x+b^{O}_{jL} \tag{19}\]  
The right fitting line is defined as \(L^{O}_{jR}:y^{O}_{jR}=a^{O}_{jR}x+b^{O}_{jR}\), as shown by the orange dotted line in Figure 3. Because the fitting lines on both sides of the street should be parallel when determining the cutting path, it is necessary to modify the fitting lines so that the slopes are equal. Based on determining the slopes, we used Equation (16) to refit the discrete points.