3.1. Theory
To obtain the real size of the object, we need to construct a mapping from the image coordinates to the world coordinate system (as seen in
Figure 4). Here, for simplicity, the image coordinate origin, which is conventionally located in the upper-left corner, was shifted to the center (parallel to the world coordinate), as seen in
Figure 4. Let us assume that we have a small segment d
s with an incline angle
θ; thus, its projection into the horizontal segment d
u and vertical segment d
v can be expressed as
where
θ is measured by the inclinometer cemented to the beam splitter.
The segment d
s has been recorded in the image, where its pixel length is denoted as d
s’. Accordingly, the horizontal pixel segment d
x and vertical pixel segment d
y can be expressed as
where
, and (
xi1,
yi1) and (
xi0,
yi0) are the coordinates of the spots’ centroids in the image coordinate system.
Therefore, the relation between the image coordinates and the world coordinate system can be expressed as
where (
x,
y) is the middle point of d
s’,
h(
x,
y) is the measured scale in the
x direction, and
g(
x,
y) is the measured scale in the
y direction.
In the device, the measured scale
h(
x,
y) at (
xi,
yi), which is located at the middle point of the line formed by the two centroids of the laser spots, represents the scale for d
s’ in an average sense. According to Equation (9), the scales at this point can be expressed as
where
,
;
and
are the horizontal and vertical projections of the spot pair distance (
S).
Through the set
h(
xi,
yi)and
g(
xi,
yi), we can reconstruct the full-field scale map. With the scale map, we can measure all the geometry inside the image. Many methods are used to reconstruct the surface [
18]. Among these methods, piecewise low-order fitting and polynomial fitting are the two most frequently used tools. However, high-order polynomial fitting can lead to ill-conditioned matrices, while piecewise low-order fitting results in discontinuities. To overcome the difficulty mentioned above, we introduce the moving least squares (MLS) method [
19]. MLS method is a method of reconstructing continuous functions from a set of unorganized point samples via the calculation of a weighted least squares measure biased towards the region around the point at which the reconstructed value is requested. The MLS method is useful for reconstructing a surface from a set of points. In the following section, we use measured scale
h(
xi,
yi) to reconstruct the scale map
H(
x,
y) in the x direction. Suppose the scale function (i.e., MLS approximant)
H(
x,
y) consists of polynomial and undetermined coefficients as
where
pi(
x,
y) is a complete monomial basis of order
m and
ai(
x,
y) is the undetermined coefficient. Since the undetermined coefficients are location-dependent, Equation (12) can be rewritten at the subdomain centered at (
x,
y) as
where
are the points in the subdomain centered at (
x,
y). Since the scale is nonlinear, we use a quadratic basis as
In this case,
m is equal to 6. The weight function can be expressed as
where (
xI,
yI) is the known node, ((
x,
y)- (
xI,
yI)) represents the distance between the undetermined point and the node, i.e.,
.
There are a number of weight functions that are used for the MLS method. Here, we use a cubic spline function as
where
is the normalized distance,
l is the distance and
is the influential radius. The characteristic of the cubic spline weight function is demonstrated in
Figure 5, where we set the unit along
X and
Y axis equal to
, and (
xI,
yI) equal to (0, 0).
To avoid the singularity in the MLS algorithm,
is set to be a proper value to include sufficient nodes in the subdomain [
20]. In this paper, the influential radius is determined by the quadrant method [
21].
is obtained via
, where
k is the positive number between 1.2 to 2.5 and
li is the nearest distance from the interpolation point (
x,
y) to the known node for each quadrant, respectively, as seen in
Figure 6.
Note that the local approximant
can be expressed by the known nodes (i.e.,
is replaced by
). The weighted sum of squared errors at all nodes has the following form
where
N is the node number, and it is required
.
To obtain the best approximant of
,
J can be minimized with respect to
a(
x,
y) as
Equation (19) has the matrix form
The undetermined coefficient
can be expressed as
where
Thus, the approximant based on MLS can be expressed as
The inverse of matrix
A is a critical step in the MLS algorithm. In the algorithm, we first obtain the determinant of matrix
A. If it is zero, the matrix
A is singular and we need to increase the influential radius to include more nodes to form matrix
A. Alternatively, one can determine the invertibility of matrix
A by checking its rank via singular value decomposition or rank-revealing QR decomposition. A full rank square matrix is invertible. There are many methods for matrix inversion and we used Gaussian elimination method in the following examples [
22]. The computational efficiency of the MLS method will be discussed in our future work.
It is noted that
G(
x, y) (the scale map in the y direction) can be obtained in the same manner. Once the scale functions
H(
x, y) and
G(
x, y) have been obtained, the object length in the image can be calculated via the integration method with d
s. d
s can be expressed as
Similarly, the area of the object in the image can be calculated via integration with d
A. d
A is expressed as
3.2. Algorithm
Since the spots have identical shapes, they can be recognized by the algorithm. An edge detection method [
23,
24] was used to detect the spot edge, as shown in
Figure 7. Once the edges of the two spots have been detected, the pixel length between two spots’ centroids can be calculated. The centroids (
xi0,
yi0) and (
xi1,
yi1) are obtained via a set of discrete points (denoted as array (
x,
y)) on the edge as
Subsequently, h(xi, yi) and g(xi, yi) can be calculated via Equations (10) and (11), respectively. Finally, H(x, y) and G(x, y) can be obtained via the MLS approach.
To summarize, there are two critical steps in the proposed method. The first one is the image processing algorithm, which is used to obtain a single virtual scale. The second one is the MLS algorithm, which is used to build the full-field scale map. The detailed flowchart can be seen in
Figure 8. Due to the characteristics of the device (outputting two identical spots), every single virtual scale can be calculated automatically. When the full-field scale is reconstructed by the MLS algorithm, high-precision measurement is possible. Verification will be done in the next section.