# Novel Boundary Edge Detection for Accurate 3D Surface Profilometry Using Digital Image Correlation
## 2 Methodology of the Random-Speckle Optical Detection and Processing Algorithm
### Normalized Cross-Correlation (NCC) for Edge Detection  
The normalized cross-correlation coefficient can be defined in Equation (1) [17; 18] and is commonly taken as a matching index for the correlation between the reference image subset and the measured image subset. \[C(X,\ Y)=\frac{\sum_{x,y}T^{\prime}(x,y,H)\times R^{\prime}(x,y,t)}{\sqrt{ \sum_{x,y}T^{\prime}(x,y,H)^{2}\times R^{\prime}(x,y,t)^{2}}} \tag{1}\]  
where \(T^{\prime}(x,y,H)=T(x,y,H)-\frac{\sum_{x,y}T(x,y,H)}{w\times h}\), \(R^{\prime}(x,y,t)=R(x,y,t)-\frac{\sum_{x,y}R(x,y,t)}{w\times h}\), \(H\) is the corresponding height of the reference image, \(t\) is the duration of time after the reference image is calibrated, \(w\) is the width of the subset, and \(h\) is the height of the subset. Figure 2: Optical configuration for 3D surface profilometry. Obviously, the subset size is an important parameter for best cross-correlation in terms of both measurement accuracy and efficiency. The optimal size depends strongly on the image contrast uniqueness of the speckle pattern. In general, the more unique the pattern is, the smaller the subset size required to obtain matching accuracy. Therefore, the uniqueness of the speckle pattern is first determined through cross-correlation between subset images; and a suitable subset window size is established by evaluating the uniqueness of the subset image at various locations of the reference speckle image. Traditional cross-correlation in DIC involves matching two entire image subsets in both the reference and measured sets. However, this is adequate only for a continuous surface with no contour jump. When there exists a discontinuous surface edge, subset pattern matching between the reference template and the measured image can no longer succeed because the subset random-speckle pattern, under such circumstances, is projected on both sides of the detected surface jump (or edge) with a step-height difference between the projected images. Figure 3 shows how a continuous surface edge is measured by detecting the peak of the cross-correlation coefficient curve along the scanning axis. As can be seen, a lateral scan along the surface edge reveals a decline of the curve to a local minimum, indicating a decrease in cross-correlation between the reference subset image and the measured subset image, followed by a rise back to its original level. When measuring a geometrically discontinuous surface edge, the measured subset image pattern on the detected edge is affected by edge light diffraction. The measured image pattern comprises two sub-patterns represented by the two split surfaces on either side of the measured edge. Figure 4 shows an example of the above scenario. The measured image pattern marked by a red square comprises the top-left triangular region, the light diffracted region, and the bottom-right triangular region. More importantly, the two triangular subset images correspond to their own reference heights, which represent the measured top-left and bottom-right surface contour regions, respectively. Figure 4: Measured subset image pattern formed by a surface contour edge: (**a**) measured image of multi objects; (**b**) a red square indicating measured subset image pattern along a tilting contour edge, which comprises the top-left triangular region, the light diffracted region, and the bottom-right triangular region; and (**c**) two triangular subset images corresponding to their own reference heights. Figure 3: Cross-correlation coefficient curve along the lateral scan axis on a rectangular gauge block with two surface edges. Next, the edge detection accuracy of two typical subsets was evaluated. Figure 5 shows two typical subsets formed when the template scans along a surface contour edge. The blue square represents a subset image acquired from a continuous surface contour, while the red square shows a subset image scanned on a discontinuous surface with an edge.