• Chinese Optics Letters
  • Vol. 17, Issue 6, 061001 (2019)
Long Li1、2, Zhiyan Pan1, Haoyang Cui1, Jiaorong Liu1, Shenchen Yang1, Lilan Liu1、2, Yingzhong Tian1、2, and Wenbin Wang3、*
Author Affiliations
  • 1School of Mechatronic Engineering and Automation, Shanghai University, Shanghai 200072, China
  • 2Shanghai Key Laboratory of Intelligent Manufacturing and Robotics, Shanghai University, Shanghai 200072, China
  • 3Mechanical and Electrical Engineering School, Shenzhen Polytechnic, Shenzhen 518055, China
  • show less
    DOI: 10.3788/COL201917.061001 Cite this Article Set citation alerts
    Long Li, Zhiyan Pan, Haoyang Cui, Jiaorong Liu, Shenchen Yang, Lilan Liu, Yingzhong Tian, Wenbin Wang. Adaptive window iteration algorithm for enhancing 3D shape recovery from image focus[J]. Chinese Optics Letters, 2019, 17(6): 061001 Copy Citation Text show less

    Abstract

    Depth from focus (DFF) is a technique for estimating the depth and three-dimensional (3D) shape of an object from a multi-focus image sequence. At present, focus evaluation algorithms based on DFF technology will always cause inaccuracies in deep map recovery from image focus. There are two main reasons behind this issue. The first is that the window size of the focus evaluation operator has been fixed. Therefore, for some pixels, enough neighbor information cannot be covered in a fixed window and is easily disturbed by noise, which results in distortion of the model. For other pixels, the fixed window is too large, which increases the computational burden. The second is the level of difficulty to get the full focus pixels, even though the focus evaluation calculation in the actual calculation process has been completed. In order to overcome these problems, an adaptive window iteration algorithm is proposed to enhance image focus for accurate depth estimation. This algorithm will automatically adjust the window size based on gray differences in a window that aims to solve the fixed window problem. Besides that, it will also iterate evaluation values to enhance the focus evaluation of each pixel. Comparative analysis of the evaluation indicators and model quality has shown the effectiveness of the proposed adaptive window iteration algorithm.

    With the development of high-precision measurement technology, it is an important research direction to make non-contact and high-precision measurement of the surface morphology of microscopic objects by using high-resolution microscopic images. Three-dimensional (3D) reconstruction distortion is the common problem in the field of image measurement, especially when multi-focus microscopic image measurement is more prominent, and distortion of the 3D reconstruction model will seriously affect the measurement results. Depth from focus (DFF) deals with the recovery of 3D shapes from multi-focus image sequences[1,2]. DFF requires searching the best focus setting that gives the best focus at each point[3,4]. Thus, each pixel point of an object is required to be well focused in multi-focus image sequences. According to the current research status, Mahmood et al. proposed a non-linear filtering method to enhance the focus volume for accurate depth estimation[5]. Lee et al. proposed an adaptive window algorithm to enhance the focus measure, where the algorithm adjusts the window size based on median absolute deviation[6]. Mahmood et al. used the most basic operator for calculation, but optimized the genetic algorithm for fitting the focus curve to a height curve[7]. Leach explained the principle of Alicona equipment and provided a complete solution for the selection of lighting methods, the selection of the interpolation fitting algorithm of the focus evaluation function, and the way of dealing with the noise in the model[8]. Aydin and Akgul suggested an adoptive weighted window that adjusts the weights using the information from an all-in-focus image. Thelen discussed the importance of the window size and suggested an algorithm for the second stage that selects the effective window size from several neighborhood sizes based on confidence criterion[9]. All methods of focus evaluation measurement mentioned above only use a fixed window without considering the impact of iterative evaluation for depth estimation. In this Letter, we discuss the issue of window selection and enhanced focus evaluation to recover 3D shapes from the image focus accurately.

    There are two main causes of distortion in 3D reconstruction. The first is the absence of much consideration in the evaluation of focus pixels during the evaluation process at the pixel point, and the second is the window size on the focus evaluation operator being fixed, e.g., 3×3, 5×5. Thus, for some pixels, enough neighbor information cannot be covered in the fixed window and easily interfered with by noise, which results in distortion of the model. For other pixels, the fixed window is too large, which increases the computational burden.

    For example, we use the modified Laplacian (FMSML) to reconstruct the profile of semi-cylindrical model in the Alicona standard block. Two causes of distortion in the reconstruction of the specific form of the model are shown in Fig. 1.

    Depth maps of semi-cylindrical model. (a) Alicona semi-cylinder standard model, (b) semi-cylinder using window size 3×3, (c) semi-cylinder using window size 5×5.

    Figure 1.Depth maps of semi-cylindrical model. (a) Alicona semi-cylinder standard model, (b) semi-cylinder using window size 3×3, (c) semi-cylinder using window size 5×5.

    Figure 1(b) shows the obvious distortion of the semi-cylinder reconstruction using the window 3×3, while the distortion of the reconstruction model is partly improved using the window 5×5. Although the increase in the window will improve the reconstruction distortion to a certain extent, it will greatly increase computational burden. From the results of the experiment in Figs. 1(b) and 1(c), the full focus pixel point cannot be accurately obtained by one time focus evaluation.

    Therefore, the adaptive window iteration algorithm is proposed to enhance the image focus with the aim of producing accurate depth estimation.

    Human consideration in determining the clarity of the image is only limited to information captured by the eye. However, the computer uses the focus evaluation algorithm to determine the degree of focus of the image[10,11]. Because the precision mobile platform moves in the Z direction and the measured area of the object passes through the depth of field of the microscope objective, the measured area of the object will inevitably undergo “out of focus almost in focus–in focus–almost in focus–out of focus”[12,13].

    A focus measure is defined as the quantity for locally evaluating the sharpness of a pixel. It takes the small local neighborhood and computes the sharpness of a chosen center pixel. Since each object point has different surface characteristics and geometry, the values of the focus measure of the same object point from different optical settings are compared. Some popular algorithms have been applied to measure contrast, and one of them is the gray-level variance (GLV). It comes from the principle that high variance is intuitively associated with sharp image structure, while low variance is associated with blurring, which reduces the amount of gray-level fluctuation[14,15]. Therefore, GLV focus measure can be obtained by taking the variance of the gray-level values of pixels within a local window as FMGLV(x,y)=(i,j)Wn×n[I(x,y)μ]2,where Wn×n is the local window with the size of n×n centered at (x,y), I(x,y) is the value of the pixel (x,y), and μ is the mean value of pixels in Wn×n.

    Another type of method is based on derivatives. The Tenegrad focus measure (TEN)[16,17] is a gradient magnitude maximization method that measures the sum of the squared responses of the horizontal and vertical Sobel masks, shown in the following: FMTEN(x,y)=(i,j)Wn×n[Gx(x,y)2+Gy(x,y)2],where Gx and Gy are the X and Y image gradients, respectively, computed by convolving the given image I with the Sobel operators.

    The Laplace operator, a second-order differential operator in the n-dimensional Euclidean space, is defined as the divergence () of the gradient (f). Thus, if f is a twice-differentiable real valued function, then the Laplacian of f is defined by Δf=2f=·f. The latter notations derive from formally writing =(x1,,xn), and the Laplace operator in two dimensions is given by f=2fx2+2fy2. The Laplace operator, being a point and symmetric operator, is suitable for accurate shape recovery. Unlike the previous first-derivative-based gradient function, the Laplace operator uses the second derivative as the basis. The reason is that the second derivative can be further amplified compared to the first derivative to change the value of the function and extract the high-frequency components more accurately. In the original form of the Laplace operator, the second-order partial derivative of the x direction and the y direction may be opposite to each other, offset one another, and produce deviations in the focus of the image

    In order to solve the problem of zero Laplacian value and improve its robustness for weak-textured images, this operator is reformulated by Nayar and Nakagawa[16,17] to get a new equation, namely, the sum of the modified Laplacian (SML) as FMSML(x,y)=(i,j)Wn×n[(2g(x,y)x2)2+(2g(x,y)y2)2].

    To further simplify it, the discrete approximation to Eq. (3) is launched, and a variable spacing step to accommodate for possible variations in the texture element sizes is also added[1820]. Therefore, the equation is shown as ML(x,y)=|2I(x,y)I(xstep,y)I(x+step,y)|+|2I(x,y)I(x,ystep)I(x,y+step)|,FMSML(x,y)=(i,j)Wn×nML(x,y)forML(x,y)T,where T is a threshold. The higher quality the input image sequence possesses, the shorter step is the better one to use.

    In order to enhance the ability of focus evaluation to obtain an accurate 3D model, the adaptive window iteration algorithm is proposed in this Letter. The algorithm is divided into two parts: in the first part, an adaptive window algorithm is used to calculate the size of each pixel corresponding to the window; in the second part, the iteration of the focus evaluation value is performed within each pixel window.

    (1) Adaptive window algorithm

    The adaptive window algorithm can automatically adjust the size of the window according to the neighboring chromatic aberrations of a pixel. Because of the neighboring chromatic aberrations, calculation of color images will increase computational burden. Therefore, this algorithm will convert color images to gray images and then calculate the neighboring chromatic aberrations of a pixel. In Fig. 2(a), the window size for both Pixels 1 and 2 is the same, as shown in Fig. 2(b), and calculating the window size of Pixel 2 with less neighboring chromatic aberration than Pixel 1 is appropriately expanded to improve the accuracy in the 3D model recovery until an upper limit of the window size is met. Similarly, in order to reduce computational volume, the window size of Pixel 1 is decreased before the chromatic aberration meets a lower limit.

    Principle of algorithm for adaptive window size.

    Figure 2.Principle of algorithm for adaptive window size.

    Specific steps to achieve the adaptive algorithm are as follows.Step 1: Set the initial window size to P(Eg9×9). Set the maximum value of window size to Pmax(Eg17×17) and the minimum value of window size to Pmin(Eg3×3).Step 2: Use the initial window for image fusion based on time domain.Step 3: Convert time-domain fused color images to gray images and then calculate the overall average deviation (A¯total) of each pixel and average deviation [A¯(x,y)]of each pixel in the initial window of the time-domain fused image. Image size is N×M, initial window size is n×n: A¯total=(x,y)WN×MA¯(x,y)N×M=(x,y)WN×M[f(x,y)(i,j)Wn×nf(xi,yj)n2]N×M.Step 4: Updated window. ① if (A¯(x,y)>A¯total)   ⊳Compare A¯(x,y) with A¯total② if (P>Pmin)   ⊳Compare P with Pmin③  Wn×n(x,y)=P1elseWn×n(x,y)=P  ⊳Update window size to Wn×n(x,y)④ else if (A¯(x,y)<A¯total) ⊳Compare A¯(x,y) with A¯total⑤ if (P<Pmax) ⊳Compare P with Pmax⑥  Wn×n(x,y)=P+1elseWn×n(x,y)=P  ⊳Update window size to Wn×n(x,y)Step 5: Repeat the above steps to determine the window size for each pixel.

    (2) Iteration algorithm of focus evaluation value

    In Figs. 3(a) and 3(b), the image focuses on one area instead of one point due to the depth of field of the microscope. Therefore, the focus evaluation value of each pixel located in the focus area is the largest in the image sequence. A new value of the focus evaluation will be obtained by adding the focus evaluation value of the center of the pixel with the focus evaluation value of the other pixels in the window. By repeating this iteration process, the highest degree of focus pixels in the image sequence can be obtained. Thus, the new focus evaluation values FM* after iteration will be gained: FM*(x,y)=(i,j)Wn×n(x,y)N[FM(x,y,k)],1kK,where N is the iteration number, Wn×n(x,y) is the window size of the pixel (x,y), and K is the total number of image frames.

    Image focus evaluation process. (a) Image sequence acquisition, (b) regional focus, (c) fitting focus evaluation curve.

    Figure 3.Image focus evaluation process. (a) Image sequence acquisition, (b) regional focus, (c) fitting focus evaluation curve.

    For each image frame k from the total of K image frames, the focus measure FM(x,y,k) is computed at each pixel (x,y,k) in the acquired image sequences by applying a focus measure on the adaptive window centered at (x,y,k). Then, for the point (x,y), the depth(x,y) is computed by taking the frame number that produces the maximum focus measure from FM(x,y,k): depth(x,y)=argmaxk[FM(x,y,k)],1kK.

    Because image sequence I is discrete, the focus evaluation curve of pixel (x,y) in the sequence of images consists of discrete points. Therefore, this algorithm uses the polynomial curve fitting method to get a more accurate peak position. The focusing evaluation curve is shown in Fig. 3(c)[8], so we use a polynomial fit to the point near the maximum, as shown in Eq. (9): p(z)=aZ2+bZ+c.

    The exact peak position can be calculated by using the coefficients a and b, Z=b2a.

    We compare the reconstruction model of the Nth iteration with the reconstruction model of the (N1)th iteration. Note that at steady state, the high difference (HD) between Z(N)(x,y) and Z(N1)(x,y) becomes very small. So, the HD termination criterion can be written as HD={[Z(N)(x,y)Z(N1)(x,y)]2}1/2δ.

    During experimentation, for objects with bevel angles closer to 90°, we found the value δ=2. In other situations, value δ1.

    Figure 4 is the block diagram of an adaptive window iteration algorithm.

    Block diagram of the adaptive window iteration algorithm. (a) Calculate the window size for each pixel, (b) focus evaluation iteration.

    Figure 4.Block diagram of the adaptive window iteration algorithm. (a) Calculate the window size for each pixel, (b) focus evaluation iteration.

    The experimental platform of this Letter is the HP Z620 workstation, the operating system is Windows 10, and the software is MATLAB 2011b. The reconstruction object of this experiment is the profile of the slope, triangle, and semi-cylinder in the Alicona morphology standard block, shown in Fig. 5. Table 1 shows the experimental image acquisition parameters. In order to compare the performance of different focus measures quantitatively, the root mean square error (RMSE), peak signal-to-noise ratio (PSNR), and correlation coefficient (CC)[6,21] are used. If f(x,y) is the original image, and g(x,y) is the processed image, then the RMSE, PSNR, and CC are calculated as follows: RMSE=1XYx=0X1y=0Y1|f(x,y)g(x,y)|2,PSNR=10×log10XY[maxf(x,y)minf(x,y)]x=1Xy=1Y[g(x,y)f(x,y)]2,CC=x=1Xy=1Y[f(x,y)f¯][g(x,y)g¯]{x=1Xy=1Y[f(x,y)f¯]2}{x=1Xy=1Y[g(x,y)g¯]2}.

     Acquisition Parameters
    ObjectMagnificationLighting MethodAdjacent Image Distance (μm)Image SizeImage Number
    Slope5×Dark field10672×37837
    Triangle5×Dark field10812×61646
    Semi-cylinder5×Dark field10791×60040

    Table 1. Optical Conditions and Acquisition Environment

    Reconstruct the object. (a) Triangle, (b) slope, (c) semi-cylinder.

    Figure 5.Reconstruct the object. (a) Triangle, (b) slope, (c) semi-cylinder.

    Figure 6 shows depth maps obtained by three groups of focus measure operators (FMGLV, FMGLV*), (FMTEN, FMTEN*), and (FMSML, FMSML*) under varying fixed window sizes and adaptive window sizes, where FM* iterations are set once. The effectiveness of using the adaptive window iteration is clear from the results. It can be observed that the models obtained using the smaller window of 3×3 are noisy and contain spikes. On the other hand, the use of the larger window size of 11×11 has increased computational burden, and shape distortion still occurs. The distortion in object shape is clear from the figures. It means that adding the adaptive window iteration algorithm can improve the reconstruction result.

    Depth maps of triangle: FMGLV (first row), FMTEN (second row), FMSML (third row), fixed window 3×3 (first column), fixed window 7×7 (second column), fixed window 11×11 (third column), and proposed adaptive window iteration (fourth column).

    Figure 6.Depth maps of triangle: FMGLV (first row), FMTEN (second row), FMSML (third row), fixed window 3×3 (first column), fixed window 7×7 (second column), fixed window 11×11 (third column), and proposed adaptive window iteration (fourth column).

    Table 2 shows the performance comparison between conventional and proposed methods in terms of RMSE, PSNR, and CC. The proposed method adopts the adaptive window iteration algorithm, while the traditional method adopts the fixed window. From Table 2, it is clear that the proposed adaptive window iteration has provided the lowest RMSE and the highest PSNR and CC values.

      Indicator
    MethodWindowRMSEPSNRCC
    FMGLV3×34.69302.67690.9432
    7×70.886117.35440.9681
    11×110.318326.04920.9787
    FMGLV*A.W0.209529.68290.9852
    FMTEN3×35.71270.96920.9133
    7×73.82824.44600.9316
    11×112.76747.26440.9501
    FMTEN*A.W1.470212.75850.9744
    FMSML3×33.62564.91830.9266
    7×71.200314.52030.9363
    11×110.675519.51330.9688
    FMSML*A.W0.256027.94010.9816

    Table 2. Performance Comparison (Adaptive Window=A.W)

    As shown in Fig. 7, the 3D slope models are reconstructed by the FMSML* focus measure, which is obtained by using the proposed algorithm to enhance the initial focus measure FMSML. Table 3 shows the quantitative performance of the proposed method for three objects in terms of RMSE, PSNR, and CC indicators. The RMSE values are getting lower along with increasing iterations. The PSNR and CC values are getting higher along with increasing iterations. During the experimentation, it is found that the proposed method costs 3–4 iterations to achieve convergence. The performance of a focus measure is usually gauged on the basis of unimodality and monotonicity of the focus curve. Figure 8 shows these features during the iterative process. The focus curves are obtained during the iterative process for the object point (1108) of the semi-cylinder. After the three iterations, the focus curve is becoming sharper and narrower.

       Iterations
    ObjectWindowIndicatorFirst IterationSecond IterationThird IterationFourth Iteration
    SlopeA.WRMSE1.47410.48200.22380.2072
    PSNR12.024421.733633.503534.7507
    CC0.92190.94910.96390.9729
    TriangleA.WRMSE0.77110.43140.36750.3554
    PSNR18.349323.394424.785425.0765
    CC0.93850.96210.97560.9801
    Semi-cylinderA.WRMSE2.61532.34022.23112.1084
    PSNR7.61587.89028.30488.7961
    CC0.94560.95510.96020.9713

    Table 3. Changes of RMSE, PSNR, and CC Indicators in the Adaptive Window Iteration Algorithm (Focus Measure=FMSML*)

    3D shape reconstruction of objects: slope (first row), triangle (second row), semi-cylinder (third row), first iteration (first column), second iteration (second column), third iteration (third column), fourth iteration (fourth column).

    Figure 7.3D shape reconstruction of objects: slope (first row), triangle (second row), semi-cylinder (third row), first iteration (first column), second iteration (second column), third iteration (third column), fourth iteration (fourth column).

    Focus curves during the iterative process for the object point (1108) of the semi-cylinder.

    Figure 8.Focus curves during the iterative process for the object point (1108) of the semi-cylinder.

    Figure 9 shows the relationship between iterations and HD. The values of δ are 0.5, 1, and 2 for the slope, triangle, and semi-cylinder, respectively. The process of this iteration terminates when HD is less than δ. As shown in Fig. 9, after three iterations, the decrease in HD tends to be flat and reaches a relatively stable state. If iterations continue to increase, the quality of the model will only be slightly improved and the computational burden will increase. The RMSE is the most accurate and highest applied value in many indicators. Therefore, this Letter uses RMSE to judge the model quality and analyze the iterations. As shown in Fig. 10, the RMSE values are getting lower with increasing iterations, and they are gradually stabilized.

    Model improvements in terms of iterative HD. (a) Slope iteration, (b) triangle iteration, (c) semi-cylindrical iteration.

    Figure 9.Model improvements in terms of iterative HD. (a) Slope iteration, (b) triangle iteration, (c) semi-cylindrical iteration.

    Relationship analysis of RMSE.

    Figure 10.Relationship analysis of RMSE.

    In this Letter, we proposed the adaptive window iteration algorithm to enhance the focus evaluation for accurate 3D shape recovery. The algorithm can be divided into two parts: the first part uses the adaptive window algorithm to automatically adjust the window size according to the gray difference within the window in the focus evaluation process; the second part enhances the accurate focus evaluation of each pixel by iterative focusing values. The proposed method has been demonstrated by using multi-focus image sequences of Alicona standard objects. In addition, the value of the iteration termination condition δ can be changed according to actual needs. Comparative analysis has demonstrated the effectiveness of the proposed algorithm, as compared to traditional methods.

    References

    [1] S. Allegro, C. Chanel, J. Jacot. Proceedings of International Conference on Image Processing, 677(1996).

    [2] M. Cho, D. Shin. Chin. Opt. Lett., 13, 051101(2015).

    [3] E. Krotkov, K. Henriksen, R. Kories. IEEE Trans. Pattern Anal. Mach. Intell., 12, 1200(1990).

    [4] M. Subbarao, J. K. Tyan. IEEE Trans. Pattern Anal. Mach. Intell., 20, 864(1998).

    [5] M. T. Mahmood, A. Majid, T.-S. Choi. J. Photograph. Sci., 62, 217(2014).

    [6] I. Lee, M. T. Mahmood, T. S. Choi. Opt. Laser Technol., 45, 21(2013).

    [7] M. T. Mahmood, T.-S. Choi. Image Vision Comput., 28, 634(2010).

    [8] R. Leach. Opt. Meas. Surf. Topogr., 23, 35(2011).

    [9] A. Thelen, S. Frey, S. Hirsch, P. Hering. IEEE Trans. Image Process., 18, 151(2009).

    [10] C. T. Tan, Y. S. Chan, J. A. Chen, T. C. Liao, M. H. Chiu. Chin. Opt. Lett., 9, 101202(2011).

    [11] T. Zeng, J. Ding. Chin. Opt. Lett., 16, 031405(2018).

    [12] Y. Hou, L. Li, S. Wang, Q. Zhu. Chin. Opt. Lett., 15, 111203(2017).

    [13] T. Yeo, S. H. Ong, , R. Sinniah. Image Vision Comput., 11, 629(1993).

    [14] W. Du, G. Zhang, L. Ye. Sensors, 16, 675(2016).

    [15] P. Hansson, J. Fransson. Appl. Opt., 43, 3971(2004).

    [16] M. Lombardo, S. Serrao, N. Devaney, M. Parravano, G. Lombardo. Sensors, 13, 334(2012).

    [17] J. M. Tenenbaum. Accommodation in computer vision(1971).

    [18] Y. Nakagawa, S. K. Nayar. IEEE Trans. Pattern Anal. Mach. Intell., 16, 824(1994).

    [19] A. S. Malik, T. S. Choi. Pattern Recogn., 41, 2200(2008).

    [20] Y. Cheng, J. Zhu, S. Hu, L. Zhao, W. Yan, W. He, Y. He, W. Jiang, J. Liu. IEEE Photon. Technol. Lett., 29, 275(2017).

    [21] I. T. Paper. Math. Prob. Eng., 2016, 5637306(2016).

    Long Li, Zhiyan Pan, Haoyang Cui, Jiaorong Liu, Shenchen Yang, Lilan Liu, Yingzhong Tian, Wenbin Wang. Adaptive window iteration algorithm for enhancing 3D shape recovery from image focus[J]. Chinese Optics Letters, 2019, 17(6): 061001
    Download Citation