# An Automatic Detection Method for Cutting Path of Chips in Wafer
## 2 Materials and Methods
### Automatic Detection Algorithm of Chip Cutting Path
#### 2.3.2 Wafer Image Brightness Calibration  
Due to the influence of the strength of illumination and chip category, different categories of chip surfaces reflect different intensities of the incident light, resulting in differences in the brightness of different chip regions. The images are divided into four categories, as shown in Figure 4. For the stereotypical algorithm, processing images with different brightness will output different detection results, while wafer cutting requires strict precision of the cutting path. In the algorithm, the template matching method is used to search for the center of gravity of the chip region in the image. After the template used for matching is determined, the grayscale distribution and frequency domain characteristics of the template image remain unchanged throughout the detection process. When matching images with excessive differences, such as the A area in Figure 4b, it is easy to output the wrong matching results. In addition, when searching for the interlayer, it is necessary to highlight the interlayer area, so as to ensure the stability of the interlayer search. Therefore, it is very important to calibrate the brightness of wafer images in different categories to improve the gray distribution and highlight the feature areas.  
In order to calibrate the brightness difference between different batches of images, it is necessary to adjust the overall gray distribution of the image, rather than in a specific, small range of gray intervals. Therefore, it uses the exponential transformation in the nonlinear image enhancement algorithm to transform the image gray level, enhance the contrast between the chip region and the street, and highlight the interlayer [19]. The grayscale transformation rules of the exponential method are as follows:  
\[I(m,n)=f(m,n)^{a} \tag{5}\]  
\(f(m,n)\) represents the gray value of the pixel at row \(m\) and column \(n\) in the target image, and the image size is \(M\times N\). \(I(m,n)\) is the gray value of the corresponding part after exponential calculation, and \(a\) is the exponential parameter. The selection of \(a\) is related to the overall gray distribution of the image. The value of \(a\) is:  
\[a=\begin{cases}e^{c1\times Level}-d_{1}\;Level\geq T_{d}\\ e^{c2\times\sqrt{Level}}-d_{2}\;Level<T_{d}\end{cases} \tag{6}\]  
where \(Level\) is the global threshold value of the image gray value, which is between 0 and 1. It is obtained by employing the Maximum Between-Class Variance Method [20]. \(Td\) is the evaluation threshold value for judging over darkness and overexposure, and \(c_{1},c_{2}\), \(d_{1}\), and \(d_{2}\) are constants. When the \(Level\) is greater than \(Td\), the image brightness will be reduced. When the \(Level\) is less than \(Td\), the image brightness will be increased. The value of \(Level\) is:  
\[Level=\operatorname*{argmax}_{k}(\sigma_{k}) \tag{7}\]  
\(\sigma_{k}\) is the between-class variance calculated when the gray value is \(k\):  
\[  
where \(\omega_{k0}=N_{k0}/(M\times N)\), \(\omega_{k1}=N_{k1}/(M\times N)\), and \(\mu_{k0}\) are the average gray values of the foreground area when the gray value is \(k\), and \(\mu\) is the average gray value of the image.