Advances in Numerical Analysis

Volume 2013, Article ID 858279, 8 pages

http://dx.doi.org/10.1155/2013/858279

## Modified Bézier Curves with Shape-Preserving Characteristics Using Differential Evolution Optimization Algorithm

Department of Electrical and Electronic Engineering, Bangladesh University of Engineering and Technology, Dhaka, 1000, Bangladesh

Received 27 October 2012; Accepted 6 February 2013

Academic Editor: William J. Layton

Copyright © 2013 Mohammad Asif Zaman and Shuvro Chowdhury. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

#### Abstract

A parametric equation for a modified Bézier curve is proposed for curve fitting applications. The proposed equation contains shaping parameters to adjust the shape of the fitted curve. This flexibility of shape control is expected to produce a curve which is capable of following any sets of discrete data points. A Differential Evolution (DE) optimization based technique is proposed to find the optimum value of these shaping parameters. The optimality of the fitted curve is defined in terms of some proposed cost parameters. These parameters are defined based on sum of squares errors. Numerical results are presented highlighting the effectiveness of the proposed curves compared with conventional Bézier curves. From the obtained results, it is observed that the proposed method produces a curve that fits the data points more accurately.

#### 1. Introduction

Bézier curve is a curve fitting tool for constructing free-form smooth parametric curves. Bézier curves are widely used in computer aided geometry design, data structure modelling, mesh generating techniques, and computer graphics applications [1–3]. These curves are also used in different fields of mechanical and electrical engineering for modelling complex surface geometries [1]. Because of the wide field of applications, efficient techniques for improving and controlling the shape of Bézier curves have become an important field of research [4, 5].

A standard curve fitting problem is defined by a set of raw data points, referred to as *control points*. The polygon obtained by connecting all the control points is termed as the *control polygon*. For most applications, it is required to find a free-form curve that most closely follows the control polygon. Conventional least-squares curve fitting techniques can fit a mathematical equation through the control points. However, this technique is not always applicable as the control points do not necessarily follow any standard mathematical equation models. Spline interpolation results in a continuous curve that matches the control polygon to a high degree [1], but the curve is expressed in terms of piece-wise defined functions. In many cases a single equation for the whole curve is required for mathematical operations. In such cases spline interpolations are not useful. In case of an interpolating polynomial, the interpolated curve goes through all the control points; however, the interpolated region between two control points often deviates significantly from the control polygon. This problem arises because the interpolating polynomial only tries to match the control points and does not take into account the slope variation of the control polygon. As a result, the shape of the curve between the control points is not always accurate. A Bézier curve, unlike a polynomial interpolated curve, does not necessarily go through all the control points. It goes through the two terminal control points. The number and orientation of the intermediate control points govern the shape of the Bézier curve [6]. Because of the Bernstein basis used by the Bézier curve, it creates a smooth shape and in most cases follow the general trend of the control polygon and its shape [7, 8]. This fact is illustrated in Figure 1. The data points used for the test function, , are tabulated in Table 1. The figure shows that interpolating polynomial shows highly oscillatory nature and fails to follow the shape. However, the Bézier curve follows the shape of the curve and approximates the slope of the curve reasonably accurately throughout the region of interest.

Although Bézier curves usually follow the general trend of the control polygon, it often underestimates the slope of the control polygon. Due to inherit smoothing characteristics, it fails to follow control polygons with sharply varying sides. Also, Bézier curves lack flexibility of controlling the shape of the curve. It is not possible to generate multiple Bézier curves with different shapes for the same control polygon. This flexibility is often desired to fine-tune and optimize a curve-fitting problem. For this reason, modified versions of Bézier curves with shaping parameters have been developed [9, 10]. The methods proposed in [4, 5] give satisfactory results, but require complex computations. A simpler, yet effective approach is provided in [11], but the method does not describe the process of finding the optimal shaping parameters for a given control polygon. Some work has also concentrated on modifying the basis of the curves [12, 13]. Although effective, these methods are also based on complex computations which are difficult to implement through computer coding. In this paper, parametric equations of a modified Bézier curve is presented. The proposed equations contain shaping parameters that can be used to accurately fit a given set of control points. The optimum value of the shaping parameters is calculated using Differential Evolution (DE) optimization algorithm.

DE algorithm was first developed by Storn and Price in 1997 [14]. Since then, it has been successfully used in many applications [15]. However, only a few work has investigated the use of DE algorithm for Bézier curves [16, 17]. The work of [16] concentrated on creating new set of control points, rather than changing the equation of the Bézier curve. As a result, it inherits the same weakness of conventional Bézier curves when it comes to sharply varying control points. The work of [17] does not directly relate to curve fitting problems. In this paper, the DE algorithm is used to find the shaping parameters of a proposed modified Bézier curve parametric equation. The paper presents a generalized method that can be used for curve fitting applications for any arbitrary set of control points.

The paper is organized as follows. Section 2 contains formulation of *modified Bézier curve* and definition of *optimality*. Section 3 describes the method of optimizing the shaping parameters using DE algorithm. Section 4 presents the numerical simulation results. Concluding remarks are made in Section 5.

#### 2. Formulation of Modified Bézier Curve and Defining Optimality

For a set of control points , where, , the parametric equations of the Bézier curve are given by [1]:
where
The parameter takes on continuous values. As sweeps form 0 to 1, the parametric equations defined in (1) traces a continuous curve from to . The intermediate control points determine the shape of the curve. For a given set of control points, the shape of the Bézier curve cannot be modified. To remove this limitation, additional *shaping parameters* must be introduced in the parametric equations.

To incorporate additional parameters in the Bézier curve equation, a few constraints must be presatisfied. It is required that the modified Bézier curve spans the same region as the conventional Bézier curve, which is limited by the minimum and maximum value of the coordinates of the control points. The shaping parameters should not affect the values of the curve. Therefore, the shaping parameters should appear on the parametric equation of only. The shaping parameters should provide the flexibility of both increasing or decreasing the coordinate of any curve point. Taking these requirements into consideration, the proposed modified Bézier curve equations are selected as:
Here, 's are termed as the *shaping coefficients*, which appear in the place of binomial coefficients. As proposed modified Bézier curve is expected to produce a curve that *modifies* the shape of the conventional curve, the shaping coefficients can be considered as modified versions of the binomial coefficients. The shaping coefficient can therefore be expressed as
Here, 's are defined as the *shaping parameters*. By finding the optimum values of , a desired curve that follows the control polygon can be generated.

After defining the modified Bézier curve equations, it becomes necessary to mathematically define the *optimum curve* for a given control polygon. A numerical quantity must be assigned to all possible curves obtained from (3) for different sets of shaping parameter values that define how well the curve matches the control polygon. The obvious choice for such a case is the sum of squares error between the control polygon and the modified Bézier curve. To find this error, it is first noted that for a curve fitting problem solved by computer coding, a discrete set of values of the continuous parameter must be selected. values of , uniformly selected in the range 0 to 1 as , will result in values of and obtained from (3). The following notations are used to express these points on the curve:
The corresponding point, the control polygon, , can be obtained from the linear interpolation of the control points as
Here, and are two closest control points that bound such that , and no other control points exist within this range. Now, the sum of squares error between the control polygon and the modified Bézier curve, , is given by
It is noted that is a function of . The optimal curve can be defined as the curve that generated by a specific set of shaping parameters that minimizes (7). However, this definition of optimality does not ensure a curve that follows the *shape* of the control polygon. The error defined in (7) becomes zero for a polynomial interpolated curve, which, as shown before, does not necessarily guarantee the consistency in shape. To ensure that the optimal curve follows the shape, the *slope* of the control polygon must be incorporated in the definition of optimality.

The slope of the modified curve can be calculated from using the chain rule: Completing the differentiations using (3), the slope of the curve at a discrete point corresponding to is given by The slope of the control polygon at a point can be approximated by the forward difference formula: So, the sum of squares error in estimating the slope of the control polygon, , is given by The optimal curve should have a low value of as well as a low value of .

To define the optimality of the curve, a *cost function*, , is defined in the following way:
Here, and are weight factors. It is noted that the cost function depends on the values of the shaping parameters. The weighted sum definition of the cost function ensures that both errors are incorporated. The curve created by a set of shaping parameter values that results in the lowest value of the cost function is defined as the optimum curve. The optimum set of values of the shaping parameter can be determined using DE optimization algorithm.

Although this paper concentrates on planar Bézier curves, the proposed method can be extended for general Bézier curves. The planar curves are defined by (3). In case of generalized curves, there will be additional parametric equations corresponding to each dimension. A different set of shaping parameter must be incorporated for each dimension. The error for each dimension can be calculated separately and then added together to give a single cost function. The optimum values of all the shaping parameters can be determined using the DE algorithm by minimizing cost function.

#### 3. Optimizing the Shaping Parameters Using DE Algorithm

DE is a population based heuristic evolutionary optimization algorithm [14]. The algorithm represents the potential solutions in terms of dimensional vectors defined in a solution space. The number of unknowns is equal to the dimension. The algorithm works with a predefined number of potential solution vectors simultaneously. The number of these solution vectors is called *population size*. These population of vectors are modified in each iterative step to form a new *generation*. Throughout successive generations, the vectors converge to the optimum solution.

For the curve fitting problem discussed in this paper, the solution vectors represent a set of values of the shaping parameters, . Since there are unknowns, they can be expressed by dimensional vectors . The vector in the generation can be represented as Here, the subscript denotes the generation number. If is the population size, then the generation is composed of number of such vectors, .

The solution space must be limited by defining possible range of values of vectors in each dimension. This range is selected based on the optimization problem and trial and error. In this paper, the limiting values in each dimension are selected as to . This implies that the shaping parameters can have values ranging from to . The initial solution vectors are randomly selected from a uniform distribution [14]. The successive generations are formulated using standard *mutation*, *crossover,* and *selection* operation [14, 15]. As the DE algorithm is well covered in the literature, these processes are not described here. The selection operation of DE algorithm is driven by the cost function which relates the DE algorithm with the physical problem. The DE algorithm creates successive generations with new potential solution vectors that have lower cost values. Thus, over successive generations, the DE algorithm converges to the optimum solution. The optimum solution gives the desired shaping parameters that produce the lowest value defined by (12).

#### 4. Numerical Simulation and Results

The proposed method is implemented and tested using computer coding. For simulation, the weight factors of (12) are selected as and . The allowed variation range of , for all , is selected as to . The values of these parameters are selected from trial and error methods. 40 discrete values of the parameter are selected uniformly over the range 0 to 1 for simulation. A classical DE algorithm with population size 20, mutation scale factor = 0.9, and crossover coefficient = 0.9 is selected [15]. Maximum generation number is limited to 160.

For testing purposes, the proposed modified Bézier curve is used to fit four test functions. The performance of the modified curve is measured in terms of sum of squares error between the curve and control polygon, ; sum of squares error between the slope of the curve and the slope of the control polygon, ; and cost function, . Conventional Bézier curves are also used for fitting the same test functions. The performance of the conventional curve is measured in terms of the same quantities which are represented as , , and . The test functions and corresponding results are shown in Figures 2, 3, 4, and 5. The data points of the results are highlighted in Tables 1, 2, 3, and 4. In the data table, and indicate the control points, refers to corresponding values obtained from the conventional Bézier curve, refers to corresponding values obtained from the modified curve, and refers to the values of the shaping parameters. The results show that the modified Bézier curve follows the shape of the sharply varying functions much better compared to the conventional Bézier curve. The sum of squares error of the curve and the control polygon is much smaller for the case of modified Bézier curve. The sum of squares error of the slope of the curve and the slope of the control polygon is also smaller for the modified Bézier curve.

To ensure that the DE algorithm reached convergence, the cost versus generation number plot was observed for all the test functions. All the plots show a decreasing nature in the beginning and flats out around iteration 110 to 160. The flat values of average cost and minimum cost indicate that saturation is reached [15]. For illustration purposes, only the plot for test function is shown in Figure 6.

#### 5. Conclusion

A modified parametric equation is developed by modifying the equation of Bézier curve. The resulting modified curve allows control over the shape of the fitted curve by introducing shaping parameters. Using DE algorithm, the optimum value of the shaping parameters can be found. The optimum curve matches the shape of the control polygon and the slope of the control polygon with a much higher degree of accuracy compared to the conventional Bézier curve. Multiple test functions are used to test the proposed method. A number of performance parameters are defined, which shows that the proposed method outperforms conventional Bézier curve. It is found that for sharply varying data points, the proposed method produces a curve that follows the control polygon more closely compared to conventional Bézier curve. As the proposed method is general, it can be used on any discrete sets of data of points to produce a highly accurate shape preserving curve.

#### References

- F. Curtis Gerald and O. Patrick Wheatley,
*Applied Numerical Analysis*, Pearson, 7th edition. - K. Anastasiou and C. T. Chan, “Automatic triangular mesh generation scheme for curved surfaces,”
*Communications in Numerical Methods in Engineering*, vol. 12, no. 3, pp. 197–208, 1996. View at Google Scholar - M. A. Scott, M. J. Borden, C. V. Verhoosel, T. W. Sederberg, and T. J. R. Hughes, “Isogeometric finite element data structures based on Bézier extraction of T-splines,”
*International Journal for Numerical Methods in Engineering*, vol. 88, no. 2, pp. 126–156, 2011. View at Publisher · View at Google Scholar · View at MathSciNet - W. Wen-tao and W. Guo-zhao, “Bézier curves with shape parameter,”
*Journal of Zhejiang University Science A*, vol. 6, no. 6, pp. 497–501, 2005. View at Google Scholar - Q.-B. Wu and F.-H. Xia, “Shape modification of Bézier curves by constrained optimization,”
*Journal of Zhejiang University Science*, vol. 6, no. 1, pp. 124–127, 2005. View at Google Scholar - F. A. Sohel, G. C. Karmakar, and L. S. Dooley, “An improved shape descriptor using bezier curves,” in
*Pattern Recognition and Machine Intelligence*, vol. 3776 of*Lecture Notes in Computer Science*, pp. 401–406, Springer, Berlin, Germany, 2005. View at Google Scholar - M. I. Grigor'cprimeev, V. N. Malozemov, and A. N. Sergeev, “Bernstein polynomials and composite Bézier curves,”
*Journal of Computational Mathematics and Mathematical Physics*, vol. 46, no. 11, pp. 1962–1971, 2006. View at Publisher · View at Google Scholar · View at MathSciNet - G. T. Tachev, “Approximation of a continuous curve by its Bernstein-Bézier operator,”
*Mediterranean Journal of Mathematics*, vol. 8, no. 3, pp. 369–381, 2011. View at Publisher · View at Google Scholar · View at MathSciNet - L. Yang and X.-M. Zeng, “Bézier curves and surfaces with shape parameters,”
*International Journal of Computer Mathematics*, vol. 86, no. 7, pp. 1253–1263, 2009. View at Publisher · View at Google Scholar · View at MathSciNet - Q. Chen and G. Wang, “A class of Bézier-like curves,”
*Computer Aided Geometric Design*, vol. 20, no. 1, pp. 29–39, 2003. View at Publisher · View at Google Scholar · View at MathSciNet - N. F. Fijasri, S. H. Yahaya, and J. M. Ali, “Bézier-like quartic curve with shape control,” in
*2nd IMT-GT Regional Conference on Mathematics, Statistics and Applications*, pp. 1–6, June 2006. - W.-Q. Shen and G.-Z. Wang, “A class of quasi Bézier curves based on hyperbolic polynomials,”
*Journal of Zhejiang University Science*, vol. 6, no. 1, pp. 116–123, 2005. View at Google Scholar - Ç. Dişibüyük and H. Oruç, “A generalization of rational Bernstein-Bézier curves,”
*BIT. Numerical Mathematics*, vol. 47, no. 2, pp. 313–323, 2007. View at Publisher · View at Google Scholar · View at MathSciNet - R. Storn and K. Price, “Differential evolution—a simple and efficient heuristic for global optimization over continuous spaces,”
*Journal of Global Optimization*, vol. 11, no. 4, pp. 341–359, 1997. View at Publisher · View at Google Scholar · View at MathSciNet - K. V. Price, R. M. Storn, and J. A. Lampinen,
*Differential Evolution—A Practical Approach to Global Optimization*, Springer, 2005. View at MathSciNet - P. Pandunata and S. M. H. Shamsuddin, “Differential evolution optimization for Bézier curve fitting,” in
*Proceedings of the 7th International Conference on Computer Graphics, Imaging and Visualization (CGIV '10)*, pp. 68–72, August 2010. - T. Rogalsky, “Bézier parameterization for optimal control by differential evolution,” in
*International Conference on Genetic and Evolutionary Methods*, pp. 28–34, July 2011.