## Figures

## Abstract

In this study, we propose a restoration algorithm for distorted objects using a curvature-driven flow. First, we capture the convex-hull shaped contour of the distorted object using the mean curvature flow. With the supplemented mass on the captured feature, we evolve the constraint mean curvature flow to a steady state, preserving the non-distorted region. With respect to the mass, we select a restorative shape by considering the square of the curvature derivative. The Allen–Cahn and Cahn–Hilliard equations are applied to the generated restored image from the implicit curvature motions represented by the order parameter. We impose the Dirichlet boundary condition for the order parameter and the Neumann boundary for the chemical potential to fix the feature and to inherit the mass conservation, respectively. We provided examples of the restoration of half-circle and parentheses-shaped objects to reconstruct a circle shape.

**Citation: **Lee S, Choi Y (2023) Curvature-based interface restoration algorithm using phase-field equations. PLoS ONE 18(12):
e0295527.
https://doi.org/10.1371/journal.pone.0295527

**Editor: **Xin Yong,
State University of New York at Binghamton: Binghamton University, UNITED STATES

**Received: **July 9, 2023; **Accepted: **November 21, 2023; **Published: ** December 14, 2023

**Copyright: ** © 2023 Lee, Choi. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.

**Data Availability: **All relevant data are within the paper and its Supporting information files.

**Funding: **The first author (S. Lee) was supported by “Regional Innovation Strategy (RIS)” through the National Research Foundation of Korea (NRF) funded by the Ministry of Education (MOE) (No. 2023A-02-06-01-010). The corresponding author (Y. Choi) was supported by Basic Science Research Program through the National Research Foundation of Korea(NRF) funded by the Ministry of Education(2022R1I1A3072824). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

**Competing interests: ** The authors have declared that no competing interests exist.

## Introduction

Image data in electronic formats can be damaged in storage or transmission [1]. In medical tomography, imaging scans can be easily distorted by artificial effects, causing interference and interruption [2]. For example, in surgical imaging, a part of a medical image showing the skeleton could be accidentally damaged, which might cause difficulty in distinguishing the characteristic signs of some conditions or diseases [3]. Therefore, considerable effort has been devoted to the study of the reconstruction of distorted images.

Image inpainting techniques reconstruct image data using information around damaged parts. Fig 1 shows a well-known 2D schematic of a conventional method to generate gray values in part of a vacant region. Fig 1(a) shows a given image containing a missing domain, and Fig 1(b) shows an image reconstructed using an image inpainting technique. Many models have been proposed to obtain a reasonable reconstruction [4–8] based on modifications of the Allen–Cahn and Cahn–Hilliard equations [9–11]. These successive binary image inpainting methods have been extended to a wide variety of applications [12–15] such as colored images and slice data in three-dimensional problems.

Reprinted from [9] with permission from Elsevier (Digital Signal Processing).

By contrast, an image domain (surface mesh) could be destroyed along with the image value, as shown in Fig 2. This has been investigated in terms of hole-filling or surface inpainting. In 3D cases, a volumetric reconstruction may be considered. However, in the present work, we discuss only surface restoration [16–23]. We refer interested readers to a survey of the relevant literature [24]. In [16], volumetric diffusion method was proposed as an algorithm to restore a complex surface. Moreover, several methods have been proposed that considered geometric properties such as curvature [17, 18, 21, 23]. In [19], a mesh generation and self-intersection from the projected boundary points on a plane were used to update surface mesh points inside a hole in a piecewise manner. In [20], an advancing front mesh algorithm was applied to fill in a hole, and the Poisson equation was used to heal over inside points. In [22], a sparsity-based hole-filling algorithm was proposed to find a low-dimensional intrinsic structure from a Laplacian eigenbasis dictionary.

Reprinted from [19] with permission from Elsevier (Computer-Aided Design).

In comparison, to distinguish surface restoration with image inpainting, the latter indicates the reconstructing of function values at grid points in the damaged region (in the case that we already know the locations of the grid points on a flatted 2D image), whereas the former reconstructs grid points for a damaged curved 2D image. To discuss this clearly, we consider the concept of interface restoration, which aims to recover a parametric curve from a destroyed curve. For example, given the open curve with two endpoints in Fig 3(a), we aim to find the closed curve that links the two points, where we assume that the original is closed, smooth, and non-twisted.

In this study, we propose a curvature-based interface restoration method. The desired curve is selected by the minimized curve of the curvature variation. We provide the proposed algorithm with a simple example in which a circle shape is partially lost. For example, refer to Fig 3. First, we denote the domain generated by connecting two points as *D*_{0}, and its area by *V*_{0}. Moreover, we define *D*_{ΔV} as the curvature minimization shape with the area of *V*_{0} + Δ*V*. Then, we select the desired curve by considering the curvature variation with respect to the increment of volume Δ*V*.

We employ the Allen–Cahn (AC) equation *ϕ*_{t} = −*μ* and the Cahn–Hilliard (CH) equation *ϕ*_{t} = Δ*μ*, where *μ* = *ϕ*^{3} − *ϕ* − *ϵ*^{2}Δ*ϕ* is the chemical potential. These equations are considered to use the properties of curvature-driven flows [25–27], which were originally introduced to describe motion of interfaces in materials [28, 29]. Various studies are being conducted on the AC equation that conserves mass [30]. This can be used instead of the CH equation, but since the characteristics of the two equations are slightly different [31], so the CH equation is used in this research. In addition, we define a narrow band shape to represent the given damaged curve and the outer boundary to approximate the desired restored curve. We consider the Dirichlet boundary condition for both the AC and CH equations to fix the boundary near the undamaged curve, and the Neumann boundary condition for the CH equation to preserve the supplemented area. We described the detailed algorithm in the Numerical method section.

The remainder of this study is organized as follows. In the Numerical method section, we present the proposed numerical method with restoration algorithms defining capture and restorations step. In the Numerical results section, we describe the results of numerical simulations including half-circle and parentheses shapes. Finally, Conclusion section presents a discussion of our conclusions.

## Numerical method

In this section, we describe each step in interface restoration in detail. The overall process is shown in Fig 4. First, we consider a narrow band to approximate the given shape in Fig 4(a). The steady-state solution of the AC equation is the shape of *D*_{0} in Fig 4(b), and we calculate its area *V*_{0}, which is referred to as the capture step. Evolving the CH equation with the supplemented area *V*_{0} + Δ*V*, we obtain a steady-state solution *D*_{ΔV}, referred to as the reconstruction step in Fig 4(c). Finally, we select a reasonable shape depending on the curvature derivation in Fig 4(d).

The proposed restoration algorithm consists of the following two sub-steps. The first step (capture) identifies the overall structure, including the missing part, and the second step (reconstruction) restores the shape through curvature minimization.

- The capture step sets the order parameter to capture a given damaged feature by using the AC equation with one Dirichlet boundary condition.
- The reconstruction step reconstructs an implicit surface from obtained in the previous step under the given volume
*V*_{0}from the captured feature by using CH equations with one-Dirichlet and zero-Neumann boundary conditions.

The given damaged and captured features are respectively represented by the boundary control function in the capture and reconstruction steps. A boundary control function was investigated to solve PDEs numerically in complex domains [32–36]. In the present work, we use the boundary control function in a surface restoration algorithm with a proper boundary condition.

Let Ω = (0, *L*_{x}) × (0, *L*_{y}) be a domain, Ω_{c} ⊂ Ω be a computational domain, Ω_{d} ⊂ Ω be the domain of the given damaged feature, and Γ be the boundary between Ω_{c} and Ω_{d} (See Fig 5(a)). Here, the boundary control function is considered in a discrete sense to represent each domain on the set of the cell-centered grid points with the space step size *h* and the number of grid points *N*_{x} = *L*_{x}/*h* and *N*_{y} = *L*_{y}/*h* in the *x*- and *y*-directions, respectively. Furthermore, let and (See Fig 5(b)). Then, the discrete boundary condition function *G*_{ij} at is defined as follows.
(1)

(a) Ω_{c} is a computational domain. (b) is represented by closed circles, and (c) *G* = 1 at closed circles and *G* = 0 at open circles.

Moreover, we extend the definition of *G*_{ij} to the cell-edged grid points as follows (See Fig 5(c)).
(2)

### Capture step

The governing equation of the capture step is the AC equation with one Dirichlet boundary condition for , as follows.
(3)
(4)
where *ϵ* is the coefficient related with an interface thickness. The initial condition is satisfied in that its values are defined as 1 for and its zero-contour covers Ω_{d}.

At this point, (3) and (4) can be discretized on as follows.
(5)
(6)
where is the approximations of , and Δ*t* is the time step size.

The capture step is complete when reaches a steady state.

### Reconstruction step

The reconstruction step is governed by the types of the CH equations using the boundary control function
(7)
(8)
with one-Dirichlet and zero-Neumann boundary conditions for *ϕ* and *μ*, respectively.
(9)

Here, the initial condition is set by the steady-state solution of the capture step.

The discretization of the system (7) and (9) on can be expressed as follows. (10) (11) where (12)

Because the summation by parts is satisfied for [36], discrete mass conservation holds as follows. (13)

## Numerical results

We set the tolerance for the numerical simulation as *tol* = 0.5 ⋅ 10^{−6}.

### Grid-independent test

To confirm our method, we first perform the numerical simulation that gives independency of the number of grid points before full restoration steps. Here, we set a zero-Neumann boundary condition and the initial condition
(14)
where on the two-dimensional domain Ω = [0, 1] × [0, 1]. The obstacle was defined as the middle of hemicircles with radii of 0.2 and 0.24. The center of the circles is the center of the computational domain. Fig 6 shows the relative *l*_{2}-error ‖*ϕ*(*x*, *y*, *T*) − *ref*(*x*, *y*)‖_{2}/‖*ref*(*x*, *y*)‖_{2} where Δ*t* = 10^{−8} and *T* = 0.2 with various numbers of grid point *N*_{x} = 2^{k} for *k* = 5, …. 10. The slope of graph represents the second-order accuracy consistenting with the theory in [32]. Moreover, it indicates a grid-independency that the scaling of error is smaller than 10^{−1} in spite of the small number of the grid point.

### Half-circle shape

We begins by evolving the solution of the AC equation with a zero-Neumann boundary condition and the initial condition same as above. Fig 7 shows the evolution of the solution of the AC equation in blue and the obstacle shape in red. Because the AC equation can be explained as the mean curvature flow, the initial circle rapidly shrinks before the iso-contour contacts the given obstacle. Then, they evolve into half-circle shape, preserving the convex hull property.

Next, using the steady-state solution from the AC equation, we evolve the CH equation with the same obstacle to the steady state. For the numerical simulation of a desired volume *V*_{β} with a parameter of *β*, we set an initial condition
(15)
where , , and . With the initial condition (15), we consider the steady-state solution of the conservative mean curvature flow with the specific volume *V*_{β}.

Fig 8 shows the evolution of the solution for the CH equation with several parameters of *β*. The last column indicates the numerical steady-state solution such that the consecutive error of the solution is less than *tol*. The red-solid and black-dashed curves represent the obstacle and the final solution for the AC equation, respectively. Owing to the nature of the mean curvature flow, the iso-contour of the solution for CH equation near the obstacle tends to remain while the other region is searched for the optimized circle-like shape. With increasing values of *β*, the final solutions converge on the intended circle.

To investigate the curvature distribution with respect to the volume, we compute the curvature on the zero-contour of the steady-state solution with various *β*. To numerically compute the curvature, we generate the contour points using the DistMesh algorithm [37]. Fig 9 shows the curvature plots for the various values of *β*. The blue line shows the zero-contour of the final solution at *t* = *t*_{f}, and the red line represents the curvature value on the zero-contour. With increasing *β*, the distribution of curvature is smeared and the high magnitude near the endpoints decrease.

The corresponding values of : (a) 10900, (b) 5190, (c) 1750, (d) 330, (e) 8.85, and (f) 1.14.

To characterize the steady-state shape using the curvature distribution, we consider the integration of the square of curvature derivative as (16)

The corresponding values of of Fig 9 are 10900, 5190, 1750, 330, 8.85, and 1.14, respectively. Fig 10 shows the curvature variation with the various *β*, the value of which monotonically decreases. It should be noted that choice of a too large area *V*_{0}(1 + *β*) could make an interface diverge from the target shape in spice of the obstacle and the Dirichlet boundary condition. Therefore, a standard is required to make a reasonable choice, and we thus adopt the steady-state solution for *β* = 0.9 and *β* = 1.

### Parentheses shape

We begin by evolving the solution of the AC equation with a zero-Neumann boundary condition and the initial conditions, as given below. (17) where on the two-dimensional domain Ω = [0, 1] × [0, 1]. The obstacle is defined as the middle of parentheses shapes describing parts of a circle with radii of 0.2 and 0.24. The center of the circles is the center of the computational domain.

Fig 11 shows the evolution of the solution for the AC equation in blue and the obstacle shape in red. Similarly, for the results of the previous section, the initial circle rapidly shrinks before the iso-contour contacts the given obstacle and then evolves into the tablet shape, preserving the convex hull property.

Next, using the steady-state solution from the AC equation, we evolve the CH equation with the same obstacle to the steady state. For the numerical simulation of a desired volume *V*_{β} with a parameter of *β*, we set an initial condition
(18)
where
(19)
(20) , and . With the initial condition (18), we consider the steady-state solution of the constraint mean-curvature flow with the specific volume *V*_{β}.

Fig 12 shows the evolution of the solution for the CH equation with several parameters for *β*. The last column indicates the numerical steady-state solution such that the consecutive error of the solution is less than *tol*. The red-solid and black-dashed curves represent the obstacle and the final solution for the AC equation, respectively. Owing to the nature of the mean curvature flow, the iso-contour of the solution for the CH equation near the obstacle tends to remain, and the other regions are searched for the optimized circle-like shape. By increasing the value of *β*, the final solutions converge to the circle.

Fig 13 shows the curvature plots for the selected parameters of *β*. The blue line is the zero-contour of the final solution at *t* = *t*_{f} and the red line presents the curvature value. The corresponding values of are 6350, 752, 14.5, and 1.30, respectively.

As shown in Fig 14, the curvature variation monotonically decreases with the various *β*, as shown in as Fig 10. In this case, the steady-state solutions for *β* = 0.35 and *β* = 0.4 appear to be the reasonable choices.

### Skull shape in CT image

The previous research [38], while conducting research on the development of skull protheses through an active contour model, restored the part of the skull if it takes damaged (missing) part from the corresponding CT image (skull). To confirm our proposed algorithm, we also choose the same CT image (Fig 15(a)) and perform the restoration with two different damaged scenarios: front left cut out [case 1] in Fig 15(b) and back of the head cut out [case 2] in Fig 15(c). The numerical results are shown in Fig 15(d)–15(f). Note that both results have good agreements with the original skull shape. We upload the basic data and visualization code for this simulation to the corresponding author’s web page (https://sites.google.com/view/yh-choi/code) and DRYAD site (DOI: 10.5061/dryad.fbg79cp2g).

Reprinted from [38] with permission from Springer Nature (Journal of Medical Systems).

## Conclusion

In this study, we proposed a restoration algorithm for a distorted object using curvature-driven flows. We captured the outer contour using the Allen–Cahn equation with the one-Dirichlet boundary condition for the distorted object. Subsequently, we evolved the Cahn–Hilliard equation to a steady state with the supplemented mass on the captured feature. Imposing the one-Dirichlet boundary condition for the order parameter and zero-Neumann boundary condition for the chemical potential, we fixed the feature and inherited the mass conservation. Finally, we chose the restored shape by considering the square of the curvature derivative. We provided two restoration examples for half-circle and parentheses objects showing how the proposed approach reconstructed a circle shape. The numerical results showed that the curvature distribution became more diffused with increasing supplemented mass, and it converged to the circle shape. The approximated retoration gave expected results; however, it may be broken when we set the too large mass since the one-Dirichlet boundary condition cannot exactly capture the fixed endpoint. We leave the problem of fixing the endpoints as a subject for future work.

## References

- 1. Nicholls D, Lee J, Amari H, Stevens AJ, Mehdi BL, Browning ND. Minimising damage in high resolution scanning transmission electron microscope images of nanoscale structures and processes. Nanoscale. 2020; 12(41):21248–21254. pmid:33063813
- 2.
Savitha G, Jidesh P. Lung nodule identification and classification from distorted CT images for diagnosis and detection of lung cancer. Machine intelligence and signal analysis. Springer Singapore; 2019.
- 3. Artico M, Ferrante L, Pastore FS, Ramundo EO, Cantarelli D, Scopelliti D, Lanneti G. Bone autografting of the calvaria and craniofacial skeleton: historical background, surgical results in a series of 15 patients, and review of the literature. Surgical neurology. 2003; 60(1):71–79. pmid:12865021
- 4. Bertalmio M, Vese L, Sapiro G, Osher S. Simultaneous structure and texture image inpainting. IEEE transactions on image processing. 2003; 12(8):882–889. pmid:18237962
- 5. Telea A. An image inpainting technique based on the fast marching method. Journal of graphics tools. 2004; 9(1): 23–34.
- 6.
Feng Z, Chi S, Yin J, Zhao D, Liu X. A variational approach to medical image inpainting based on mumford-shah model. 2007 International Conference on Service Systems and Service Management. IEEE; 2007.
- 7.
Li S, Wang H. Image inpainting using curvature-driven diffusions based on p-Laplace operator. 2009 Fourth International Conference on Innovative Computing, Information and Control (ICICIC). IEEE; 2009.
- 8. Ebrahimi MA, Lunasin E. The Navier–Stokes–Voight model for image inpainting. The IMA Journal of Applied Mathematics. 2013; 78(5):869–894.
- 9. Li Y, Jeong D, Choi J, Lee S, Kim J. Fast local image inpainting based on the Allen–Cahn model. Digital Signal Processing. 2015; 37:65–74.
- 10. Bertozzi A, Esedo glu S, Gillette A. Analysis of a two-scale Cahn–Hilliard model for binary image inpainting. Multiscale Modeling & Simulation. 2007; 6(3):913–936.
- 11. Theljani A, Houichet H, Mohamed A. An adaptive Cahn–Hilliard equation for enhanced edges in binary image inpainting. Journal of Algorithms & Computational Technology. 2020; 14:1748302620941430.
- 12. Duan J, Pan Z, Zhang B, Liu W, Tai XC. Fast algorithm for color texture image inpainting using the non-local CTV model. Journal of Global Optimization. 2015; 62:853–876.
- 13. Cherfils L, Fakih H, Miranville A. A Cahn–Hilliard system with a fidelity term for color image inpainting. Journal of Mathematical Imaging and Vision. 2016; 54:117–131.
- 14. Duan J, Pan Z, Liu W, Tai XC. Color texture image inpainting using the non local CTV model. Journal of Signal and Information Processing. 2013; 4(3):43.
- 15. Li Y, Shin J, Choi Y, Kim J. Three-dimensional volume reconstruction from slice data using phase-field models. Computer Vision and Image Understanding. 2015; 137:115–124.
- 16.
Davis J, Marschner SR, Garr M, Levoy M. Filling holes in complex surfaces using volumetric diffusion. Proceedings. First international symposium on 3d data processing visualization and transmission. IEEE; 2002.
- 17.
Verdera J, Caselles V, Bertalmio M, Sapiro G. Inpainting surface holes. Proceedings 2003 International Conference on Image Processing (Cat. No. 03CH37429). vol. 2. IEEE; 2003.
- 18. Clarenz U, Diewald U, Dziuk G, Rumpf M, Rusu R. A finite element method for surface restoration with smooth boundary conditions. Computer Aided Geometric Design. 2004; 21(5):427–445.
- 19. Jun Y. A piecewise hole filling algorithm in reverse engineering. Computer-aided design. 2005; 37(2): 263–270.
- 20. Zhao W, Gao S, Lin H. A robust hole-filling algorithm for triangular mesh. The Visual Computer. 2007; 23:987–997.
- 21. Caselles V, Haro G, Sapiro G, Verdera J. On geometric variational models for inpainting surface holes. Computer Vision and Image Understanding. 2008; 111(3):351–373.
- 22. Zhong M, Qin H. Surface inpainting with sparsity constraints. Computer Aided Geometric Design. 2016; 41:23–35.
- 23. Rusu RE. An algorithm for the elastic flow of surfaces. Interfaces and Free Boundaries. 2005; 7(3):229–239.
- 24. Guo X, Xiao J, Wang Y. A survey on algorithms of hole filling in 3D surface reconstruction. The Visual Computer. 2018; 34:93–103.
- 25. Pego RL. Front migration in the nonlinear Cahn–Hilliard equation. Proceedings of the Royal Society of London. A. Mathematical and Physical Sciences. 1989; 422(1863):261–278.
- 26. Ilmanen T. Convergence of the Allen–Cahn equation to Brakke’s motion by mean curvature. Journal of Differential Geometry. 1993; 38(2):417–461.
- 27. Wang H, Yuan X, Liang H, Chai Z, Shi B. A brief review of the phase-field-based lattice Boltzmann method for multiphase flows. Capillarity. 2019;2.3:33–52.
- 28. Allen SM, Cahn JW. A microscopic theory for antiphase boundary motion and its application to antiphase domain coarsening. Acta metallurgica. 1979; 27(6):1085–1095.
- 29. Cahn JW, Hilliard JE. Free energy of a nonuniform system. I. Interfacial free energy. The Journal of chemical physics. 1958; 28(2):258–267.
- 30. Chai Z, Sun D, Wang H, Shi B. A comparative study of local and nonlocal Allen–Cahn equations with mass conservation. International Journal of Heat and Mass Transfer. 2018;122:631–642.
- 31. Lee D, Kim J. Comparison study of the conservative Allen–Cahn and the Cahn–Hilliard equations. Mathematics and Computers in Simulation 2016;119:35–56.
- 32. Shin J, Jeong D, Kim J. A conservative numerical method for the Cahn–Hilliard equation in complex domains. Journal of Computational Physics. 2011; 230(19):7441–7455.
- 33. Li Y, Jeong D, Shin J, Kim J. A conservative numerical method for the Cahn–Hilliard equation with Dirichlet boundary conditions in complex domains. Computers & Mathematics with Applications. 2013; 65(1):102–115.
- 34. Li Y, Choi JI, Kim J. Multi-component Cahn–Hilliard system with different boundary conditions in complex domains. Journal of Computational Physics. 2016; 323:1–16.
- 35. Jeong D, Yang J, Kim J. A practical and efficient numerical method for the Cahn–Hilliard equation in complex domains. Communications in Nonlinear Science and Numerical Simulation. 2019; 73:217–228.
- 36. Shin J, Choi Y, Kim J. The Cahn–Hilliard equation with generalized mobilities in complex geometries. Mathematical Problems in Engineering. 2019; 2019:1–10.
- 37. Persson PO, Strang G. A simple mesh generator in MATLAB. SIAM review. 2004; 46(2):329–345.
- 38. Chen YW, Shih CT, Cheng CY, Lin YC. The development of skull prosthesis through active contour model. Journal of Medical systems. 2017;41:1–10. pmid:28889357