## 4 Software System
### Three-Dimensional Modeling of the Lasted Upper
#### 4.1.3 Transformation Curve for Displacement to Height Conversion  
Through the aforementioned thinning process, a precise centerline of the laser stripe is obtained, representing the pixel displacement relative to a defined reference. The next step involves converting this displacement into an actual height value using geometric triangulation. However, due to the nonlinear projection geometry inherent in laser triangulation systems, the horizontal displacement of the laser stripe is not linearly proportional to the corresponding surface height. To address this, a calibration procedure is conducted using 650-series industrial-grade gauge blocks manufactured by the U.S. precision tooling company Griffin, as shown in Figure 12a. These blocks serve as reference objects to establish the mapping between pixel displacement and physical height. For each gauge block of known height, the corresponding laser stripe position is recorded. As illustrated in Figure 12b, the imaging position of the laser stripe shifts with height--higher gauge blocks result in lower \(y\)-axis coordinates in the image. This inverse relationship is later modeled using polynomial regression to form the basis of the height-displacement conversion function. Figure 11: (**a**) Original laser image. (**b**) Binarization and closing. (**c**) Contour tracing. (**d**) Centerline extraction. Figure 12: (**a**) Industrial-grade gauge blocks. (**b**) Laser-line displacement for gauges with varying block heights, using the green line as the reference for displacement. Once the calibration curve is established, it is applied to the centerline data obtained from the lasted upper to compute the relative height of each point with respect to the reference plane. During the calibration process, images can only be acquired using a limited number of gauge blocks with fixed heights. However, the lasted upper surface features continuous height variations. To address this, interpolation is employed to establish a conversion function between displacement and height based on a finite set of reference data points. Experimental results confirm that the relationship between displacement and height is nonlinear. Accordingly, the least squares method is applied to fit a quadratic polynomial to the measured data, providing a continuous mapping from pixel displacement to real-world height. In the experiment, multiple pairs of two-dimensional data (\(x_{i},y_{i}\)) are collected using the gauge blocks of known heights, where \(x_{i}\) denotes the physical height and \(y_{i}\) represents the corresponding pixel displacement observed in the image. These data points are then used to perform curve fitting, resulting in a second-order polynomial, as shown in Equation (1). The coefficients \(a,b,\) and \(c\) are determined via the least squares method and characterize the displacement-to-height mapping function. \[y=ax^{2}+bx+c \tag{1}\]  
The objective is to minimize the sum of squared errors between the measured data and the quadratic curve, as expressed in Equation (2). \[E=\sum_{i=1}^{n}\Bigl{(}y_{i}-\Bigl{(}ax_{i}^{2}+bx_{i}+c\Bigr{)}\Bigr{)}^{2} \tag{2}\]  
Express the aforementioned quadratic curve in matrix form:  
\[\mathbf{E}=\mathbf{Y}-\mathbf{X}\cdot\mathbf{\beta}\]  
where the observation vector \(\mathbf{Y}\) represents the measured displacement data, the design matrix \(\mathbf{X}\) represents the polynomial expansion of the input height values, and the parameter vector \(\mathbf{\beta}\) denotes the coefficients of the quadratic function to be estimated, and they are  
\[\mathbf{Y}= \begin{bmatrix}y_{1}\\ y_{2}\\ \vdots\\ y_{n}\end{bmatrix} ,\,\mathbf{X}= \begin{bmatrix}x_{1}^{2}&x_{1}&1\\ x_{2}^{2}&x_{2}&1\\ \vdots&\vdots&\vdots\\ x_{n}^{2}&x_{n}&1\end{bmatrix} ,\,\mathbf{\beta}= \begin{bmatrix}a\\ b\\ c\end{bmatrix}  \tag{3}\]  
Using the least squares method, the objective is to minimize the sum of squared residuals, i.e., \(\|\mathbf{X}\mathbf{\beta}-\mathbf{Y}\|^{2}\).