# Cutting Blade Measurement of an Ultrasonic Cutting Machine Using Multi-Step Detection
## 3 Curvature-Based Binarization Method  
### Image Binarization  
The gray image needs to be converted into the binary image for accurate determination of the thickness and length of the cutting blade. The generally used Otsu method extracts the objects with similar brightness values using the image histogram by finding a value that maximizes the between-class variance [11]. This method works well under the assumption of bimodal images with implicitly uniform illumination; conversely, it is limited by many factors involving the small object size and the presence of a large amount of noise requiring image restoration [12]. When the designated image is composed of \(L\) gray-level pixels, where the number of pixels whose brightness value is \(i\), \(i\in\{1,\,\dots,\,L\}\) is \(f_{i}\), the total number of pixels in the image is the image is \(N\), and the probability \(p_{i}\) for such a pixel can be obtained as follows:  
\[N=\sum_{i=1}^{L}f_{i}, \tag{1}\]  
\[p_{i}=\frac{f_{i}}{N}. \tag{2}\]  
On the basis of the pixels' gray levels, the image can be divided into two classes, \(C_{0}\) and \(C_{1}\), where the pixels with gray levels \([1,\,\dots,\,k]\) are in the class \(C_{0}\) and the pixels with gray levels \([k+1,\,\dots,\,L]\) are in class \(C_{1}\). If the probability distribution of each class is called \(\omega_{0}\) and \(\omega_{1}\), respectively, while the overall average of the original image is \(\mu_{T}\), the threshold value of Otsu can be obtained by finding \(K\), which maximizes the distribution, \(\sigma_{B}^{2}(k)\), between classes using Equations (3) and (4). The ROIs of the captured image and the binary image by the Otsu method are shown in Figure 4a,b, respectively. A comparison between the gray levels of the input image and that obtained from the Otsu method along a smaller line segment at the same position in the ROI are provided in Figure 4c, which shows that due to the specific limits of binarization standard and diffraction of light, the Otsu method is unable to detect the exact thickness of the cutting blade:  
\[\sigma_{B}^{2}(k)=\frac{\left[\mu_{T}\,\omega(k)-\mu(k)\right]^{2}}{\omega(k) [1-\omega(k)]}, \tag{3}\]  
\[\sigma_{B}^{2}(k^{\prime})=\max\sigma_{B}^{2}(k),\,1\leq k\leq L. \tag{4}\]  
It is hard to divide the target accurately by defining the standard of binarization based upon the brightness value by using the Otsu method, which can be seen in the previous example. This phenomenon occurs due to the diffraction of light. The problem can, however, be addressed if the high curvature value position in the gray-level profile of the pixels is defined as the binarization reference. In this paper, we propose the curvature-based binarization method for accurate detection of the cutting blade used in the ultrasonic vibration cutting machine. The curvature value is calculated from the horizontal line profile in the ROI of the gray image. The first order and the second order derivatives of the gray value profile at the given reference position for the given pixel are expressed as Equations (5) and (6). Where \(P(n)\) is the gray level of the \(n\)-th position where \(P^{\prime}(n)\) is the first derivative, which represents the variation of the gray level, and \(w\) is the increment along the \(x\) axis and \(P^{\prime\prime}(n)\) is the second order derivative of \(P(n)\):  
\[P^{\prime}(n)=\frac{P(n+t)-P(n-t)}{w}, \tag{5}\]  
\[P^{\prime\prime}(n)=(P^{\prime}(n))^{\prime}. \tag{6}\]  
The curvature, \(k(n)\), can be expressed in terms of \(P^{\prime}(n)\) and \(P^{\prime\prime}(n)\) as given in Equation (7):  
\[k(n)=\frac{P^{\prime\prime}(n)}{\left(P^{\prime}(n)^{2}+1\right)^{\frac{3}{2} }}. \tag{7}\]  
The result of the cutting blade detected by using the curvature-based image binarization method is given in Figure 5. Figure 5a shows the ROI image of the cutting blade obtained in the previous section.