11
Computers & Graphics 31 (2007) 719–729 Technical Section Capturing outlines of planar images using Be´zier cubics M. Sarfraz a,b, , A. Masood c a Department of Information Science, Kuwait University, Safat 13060, Kuwait b Information and Computer Science Department, King Fahd University of Petroleum and Minerals, Dhahran 31261, Saudi Arabia c Department of Computer Science and Engineering, University of Engineering and Technology, Lahore, Pakistan Received 21 February 2007; received in revised form 4 May 2007; accepted 7 May 2007 Abstract A technique has been designed for capturing outlines by exploiting the properties of cubic Be´zier curves. The planar images are used to extract the outline. The outline is divided into curve segments at high curvature points and each segment is processed independently for piecewise curve approximation. The proposed algorithm avoids the traditional method of least square fitting which is time consuming and presents a simple and efficient approach to find the control points Be´zier curves. Recursive segment subdivision is used to keep the approximation error within specified threshold limits. The ideas of interpolation, control point estimation and optimization of approximation curve are used. A comparative study of results is also provided at the end and various benefits of the proposed algorithm like computational efficiency, accurate representation and low approximation error are highlighted. r 2007 Elsevier Ltd. All rights reserved. Keywords: Planar images; Outline extraction; Be´zier curves; Curve approximation; Corner points; Segment subdivision 1. Introduction Curve approximation is an important research area of CAD and CAGD. The task of a curve approximation technique is to find the set of data points that can accurately represent the given curve. Splines in its original form may not properly approximate the shape of bitmap objects. There are two reasons for this problem. First, plotting of a spline curve is based on certain control points which are unknown in this case. Second, outlines of natural objects/shapes are non-parametric curves, and splines are parametric in nature. Thus, simply plotting outlines with spline may not produce accurate results. These problems can be minimized by appropriately designing the curves before use for approximation. Various techniques are proposed in the literature to pro- perly represent the bitmap shapes. Most of these techni- ques are based on least square fit. Itoh and Ohno [1] used the least square method to find intermediate control points of approximating cubic Be´zier curve and endpoints were located by computing the intersection of the adjoining curves. Plass and Stone [2] used the piecewise parametric cubic polynomial for endpoint interpolation with tangent vector specification. They also employed the least square fit to ensure a proper fit. Sarfraz and Khan [3] proposed the least square method to obtain the optimal fit of Arabic fonts. Another most frequently referred approach to curve approximation is through error minimization. Carlos et al. [4] used the normalized perpendicular Euclidean distance from the original curve as error measurement and obtained the fit by minimizing this error using the bisection method. Sarfraz and Khan [5] improved the performance of the fit by reparameterization of the curve by finding the closest point from the original curve. Goldenthal and Bercovier [6] applied various cost functions to obtain the optimal control over the knot vectors of non-uniform B-splines. These approaches are computationally heavy and are not suitable for most applications, especially for real-time applications. Some of the proposed curve approximation ARTICLE IN PRESS www.elsevier.com/locate/cag 0097-8493/$ - see front matter r 2007 Elsevier Ltd. All rights reserved. doi:10.1016/j.cag.2007.05.002 Corresponding author. Tel./fax: +966 3 860 2763. E-mail addresses: [email protected] (M. Sarfraz), [email protected] (A. Masood).

Capturing outlines of planar images using Bézier cubics

Embed Size (px)

Citation preview

Page 1: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

0097-8493/$ - se

doi:10.1016/j.ca

�CorrespondE-mail addr

[email protected]

Computers & Graphics 31 (2007) 719–729

www.elsevier.com/locate/cag

Technical Section

Capturing outlines of planar images using Bezier cubics

M. Sarfraza,b,�, A. Masoodc

aDepartment of Information Science, Kuwait University, Safat 13060, KuwaitbInformation and Computer Science Department, King Fahd University of Petroleum and Minerals, Dhahran 31261, Saudi Arabia

cDepartment of Computer Science and Engineering, University of Engineering and Technology, Lahore, Pakistan

Received 21 February 2007; received in revised form 4 May 2007; accepted 7 May 2007

Abstract

A technique has been designed for capturing outlines by exploiting the properties of cubic Bezier curves. The planar images are used to

extract the outline. The outline is divided into curve segments at high curvature points and each segment is processed independently for

piecewise curve approximation. The proposed algorithm avoids the traditional method of least square fitting which is time consuming

and presents a simple and efficient approach to find the control points Bezier curves. Recursive segment subdivision is used to keep the

approximation error within specified threshold limits. The ideas of interpolation, control point estimation and optimization of

approximation curve are used. A comparative study of results is also provided at the end and various benefits of the proposed algorithm

like computational efficiency, accurate representation and low approximation error are highlighted.

r 2007 Elsevier Ltd. All rights reserved.

Keywords: Planar images; Outline extraction; Bezier curves; Curve approximation; Corner points; Segment subdivision

1. Introduction

Curve approximation is an important research area ofCAD and CAGD. The task of a curve approximationtechnique is to find the set of data points that canaccurately represent the given curve. Splines in its originalform may not properly approximate the shape of bitmapobjects. There are two reasons for this problem. First,plotting of a spline curve is based on certain control pointswhich are unknown in this case. Second, outlines of naturalobjects/shapes are non-parametric curves, and splines areparametric in nature. Thus, simply plotting outlines withspline may not produce accurate results. These problemscan be minimized by appropriately designing the curvesbefore use for approximation.

Various techniques are proposed in the literature to pro-perly represent the bitmap shapes. Most of these techni-ques are based on least square fit. Itoh and Ohno [1] used

e front matter r 2007 Elsevier Ltd. All rights reserved.

g.2007.05.002

ing author. Tel./fax: +966 3 860 2763.

esses: [email protected] (M. Sarfraz),

(A. Masood).

the least square method to find intermediate control pointsof approximating cubic Bezier curve and endpoints werelocated by computing the intersection of the adjoiningcurves. Plass and Stone [2] used the piecewise parametriccubic polynomial for endpoint interpolation with tangentvector specification. They also employed the least square fitto ensure a proper fit. Sarfraz and Khan [3] proposed theleast square method to obtain the optimal fit of Arabicfonts. Another most frequently referred approach tocurve approximation is through error minimization. Carloset al. [4] used the normalized perpendicular Euclideandistance from the original curve as error measurement andobtained the fit by minimizing this error using the bisectionmethod. Sarfraz and Khan [5] improved the performanceof the fit by reparameterization of the curve by finding theclosest point from the original curve. Goldenthal andBercovier [6] applied various cost functions to obtain theoptimal control over the knot vectors of non-uniformB-splines.These approaches are computationally heavy and are

not suitable for most applications, especially for real-timeapplications. Some of the proposed curve approximation

Page 2: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESSM. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729720

techniques were based on search algorithms like evolutio-nary algorithms [7], genetic algorithms [8,9] and wavelets [10].Computational complexity of these algorithms is also high.Some of the researches have proposed some innovativetechniques to minimize this computation time. Amongthese techniques, Sohel etal. [11] presented the enhancedBezier curve model, with no increase in the order ofcomputational complexity, to reduce the distance betweenthe Bezier curve and its control polygon. It was ultimatelyapplied to reduce the distortion of approximating curves.Sarfraz and Masood [12] proposed a method to findintermediate control points along the endpoint tangents.Hu and Sheu [13] proposed a method for fitting quadraticB-splines for curves represented by Fourier descriptors,which were represented by a series of connected quadraticB-spline segments. Sohel et al. [14] proposed a shapedescription algorithm using Bezier curves. They used afixed length coding scheme to find the control points. Thesetechniques have the drawback of low-quality approxima-tion and low compression ratio. Sohel et al. [15] proposed adistortion measurement for generic shape coding. Thispaper addresses a fundamental limitation of the existingdistortion measures embedded in vertex-based operational-rate-distortion shape coding techniques; it introduces adistortion measurement algorithm based upon the actualdistance, rather than either the shortest absolute distanceor a distortion band. The method proposed by Yahya et al.[16] is exactly similar to that of Sarfraz and Khan [5],except that a rational Bezier cubic has been used instead ofa Hermite cubic, and hence is, comparatively, moreexpensive in cost. Sarfraz and Rashid [17] have devised arandomized knot insertion algorithm for outline capture ofplanar images using cubic spline. Although, it provides anautomation for the vectorization of the outlines of planarimages and also uses cubic spline in its description, theamount of data to be stored is too large when comparedwith the methods in Refs.[3,5].

This paper presents an efficient cubic Bezier curve designwhich can approximate the given shape with reasonableaccuracy. As a preprocessing step, the extracted outline ofbitmap object is divided into curve segments from thedetected corner points. A piecewise cubic Bezier curve fit isapplied over each curve segment. The methodology,discussed in this paper, differs from traditional approaches,in that the cubic Bezier control point estimation is carriedout for each curve segment instead of the least square fit ordata interpolation. The locations of intermediate controlpoints of cubic Bezier (P1 and P2) are then refined tooptimize the approximation of the original curve. Thescheme also differs in the approaches adopted in [5,18,19]as it introduces:

an improved and different way of extracting outlines ofthe images, � an efficient and simple way of curve manipulation, � an efficient and simple way of curve approximation and

Fig. 1. Cubic Bezier curve with its convex hull.

� a methodology for curve segment subdivision.

The proposed algorithm is compared with various othertechniques in terms of data points/approximating seg-ments, approximation error and computational time. It canbe concluded, from this comparison that this technique canapproximate the given outline in lesser time without muchcompromise to the quality of approximation. The paper isorganized as follows. Section 2 explains the basics of cubicBezier curves, its properties and the process of controlpoint estimation. Section 3 gives the methodology usedfor curve approximation. It discusses briefly the outlineextraction and detection of high curvature points. Piece-wise curve approximation and segment subdivision usingcubic Bezier curve design is then discussed in detail.A comparative study is presented in Section 4 and Section 5concludes the presentation.

2. Cubic Bezier curve design

A Bezier spline [20] can be fitted to any number ofcontrol points. The number of control points to beapproximated determines the degree of Bezier polynomial[21]. Many graphic packages provide only cubic splinefunctions, because this gives reasonable design flexibilitywhile avoiding the increased calculations needed withhigher-order polynomials.

2.1. Cubic Bezier curves

The cubic Bezier curves are generated with four controlpoints Pi ¼ (xi, yi), with i varying from 0 to 3 as shown inFig. 1. These coordinate points can be blended to produce thefollowing position vector P(u), which describes the path of anapproximating Bezier polynomial function between P0 and P3:

PðuÞ ¼ P0B0ðuÞ þ P1B1ðuÞ þ P2B2ðuÞ þ P3B3ðuÞ; 0pup1.

(1)

The four Bezier blending functions (B0, B1, B2, and B3) canbe given as

B0ðuÞ ¼ ð1� uÞ3;

B1ðuÞ ¼ 3uð1� uÞ2;

B2ðuÞ ¼ 3u2ð1� uÞ;

B3ðuÞ ¼ u3:

9>>>>=>>>>;

(2)

Page 3: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

Fig. 2. Cubic Bezier blending functions.

M. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729 721

The plot of four cubic Bezier blending functions are given inFig. 2. The form of blending functions determines how thecontrol points influence the shape of the curve for values ofparameter u over the range from 0 to 1. At u ¼ 0, the onlynon-zero blending function is B0, which has value 1. At u ¼ 1,the only non-zero blending function is B3, with value 1 at thatpoint. Thus, the cubic Bezier curve will always pass throughcontrol points P0 and P3. The other functions, B1 and B2,influence the shape of the curve at intermediate values ofparameter u, so that the resulting curve tends toward points P1

and P2. The blending functions B1 and B2 are maximum atu ¼ 1/3 and 2/3, respectively.

2.2. Properties of cubic Bezier curves

We observe following properties of cubic Bezier curves:

A cubic Bezier curve always lies within the convex hull(convex polygon boundary) of its control points. � The cubic Bezier blending functions are all positive and

their sum is always 1,

X3i¼0

BiðuÞ ¼ 1. (3)

The blending functions B0 and B3 are 1 at u ¼ 0 and 1,respectively. Thus the cubic Bezier curve will alwayspass through the point P0 and P3. � The blending functions B1 and B2 are maximum at

u ¼ 1/3 and 2/3, respectively. Thus the positions P(1/3)and P(2/3) of the cubic Bezier curve are mostlyinfluenced by the blending functions B1 and B2 atu ¼ 1/3 and 2/3, respectively.

� The slope at the beginning and end of cubic Bezier curve

is along the line P0P1 and P2P3, respectively.

For a given cubic Bezier curve, the position of its controlpoints can be located by exploiting its properties. The controlpoint estimation of a cubic Bezier curve is discussed next.

2.3. Control point estimation of cubic Bezier curves

Control point estimation is the process of searching asuitable location for four cubic Bezier control points from

a given cubic Bezier curve. Control points P0 and P3 alwayslie at the start and at the end, respectively, of a given cubicBezier curve. Thus the cubic Bezier curve starts from itscontrol point P0 and ends at control point P3. The othertwo control points P1 and P2 can be calculated as follows.From Eq. (1) we have

P1B1ð1=3Þ þ P2B2ð1=3Þ ¼ V1, (4)

P1B1ð2=3Þ þ P2B2ð2=3Þ ¼ V2, (5)

where

V1 ¼ Pð1=3Þ � P0B0ð1=3Þ � P3B3ð1=3Þ, (6)

V2 ¼ Pð2=3Þ � P0B0ð2=3Þ � P3B3ð2=3Þ. (7)

P(1/3) and P(2/3) are the contour points number n/3 and2n/3 of the given cubic Bezier curve, where n is the totalnumber of contour points of a given cubic Bezier curve.Thus V1 and V2 are constant values for a given cubic Beziercurve.We know that

B1ð1=3Þ ¼ B2ð2=3Þ;

B1ð2=3Þ ¼ B2ð1=3Þ:

)(8)

By multiplying Eq. (4) by V2 and Eq. (5) by V1 andputting the value from Eq. (8), we have

V2P1B1ð1=3Þ þ V 2P2B2ð1=3Þ ¼ V 1P1B2ð1=3Þ þ V 1P2B1ð1=3Þ.

(9)

By simplifying Eq. (9), we have

P2 ¼ kP1, (10)

where

k ¼V 2B1ð1=3Þ � V 1B2ð1=3Þ

V 1B1ð1=3Þ � V 2B2ð1=3Þ. (11)

k is the ratio between two unknown control points (P1 andP2) of the cubic Bezier curve. As noted in Section 2.2, thestraight line from control points P0 and P1 is along theslope (m) of the Bezier cubic curve at the start. Thuscontrol point P1 should be searched along the slope m. Thefollowing procedure can be used to find the control pointsP1 and P2:

1.

P1 ¼ P0

2.

Repeata. P1 ¼ P1+m

b. P2 ¼ kP1

c. Determine cubic Bezier curve using calculated controlpoints.

3.

While (approximation error from original cubic Beziercurve reduces).

The procedure of finding control points P1 and P2 isdemonstrated in Fig. 3. The selected control points (withminimum approximation error) are shown in circles. Theapproximation error is the minimum distance between twocurves.

Page 4: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

Fig. 3. Control points estimation of cubic Bezier curve of Fig. 1(a) Dots show the sequence of search of control points P1 and P2. Circled points are the

detected control points. (b) The accuracy of approximated cubic Bezier curve is shown by drawing it over the original cubic Bezier curve.

0

76

5

4

32

1

Fig. 4. Freeman’s chain code.

Fig. 5. Neighborhood search sequence.

M. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729722

3. Curve approximation

The process of capturing outlines, consists mainly offour steps. Firstly, extracting the outline (contour points)of a given 2D object and arranging the same in sequence(for example in clockwise direction). Secondly, dividing theoutline into curve segments from the detected cornerpoints. Thirdly, calculating the curve approximation overeach curve segment using cubic Bezier curves. Fourthly,subdividing the curve segment at appropriate points inorder to keep the approximation error within giventhreshold limits.

3.1. Boundary extraction

Boundary extraction is the first step in the wholeprocedure. We simply convert a grayscale image to binaryafter normalizing the intensity in the range [0, 1]. Theimage is then converted to binary at a specified threshold.If the threshold is 0.4, pixel intensity with less than 0.4 isthe white pixel and others are black pixels. Outlineextraction from a binary image is a simple procedure.Any pixel with a pixel value 0 (black) is a boundary point ifany of its four neighbors has a pixel value 1 (white). Thefour neighboring pixels are the upper, lower, left and rightpixels. This procedure will extract all boundary points(inner or outer boundary points) from the binary image. Atthis point it is difficult to distinguish which boundary pointbelongs to which boundary loop (in case of more than oneboundary loops), and also the sequence of boundary points(clockwise) around a loop is unknown.

To arrange the extracted boundary points in a sequence(clockwise direction), a boundary tracing is performed,starting from the left-top boundary pixel. The algorithm[22] for boundary tracing is as follows:

1.

Search the top left boundary point; this point P0 has theminimum column and row value of all the boundary

points. Point P0 is the starting point of the boundarytracing. Define a variable dir using Freeman’s chaincode [23] as shown in Fig. 4. It stores the direction of theprevious move along the boundary from the previouspoint to the current point. Assign dir ¼ 3.

2.

Search the 3� 3 neighborhood of the current point in ananti-clockwise direction as shown in Fig. 5, Starting theneighborhood search in the direction given belowa. (dir+7) mod 8 if dir is even.b. (dir+6) mod 8 if dir is odd.

Update the dir value as per the new point found.

3. If the current boundary point Pn is equal to the point P0

then stop. Otherwise repeat step 2.

4. The detected boundary points are represented by points

P0 y Pn�1. This makes a one loop of boundary points.

5. Delete the detected boundary points P0 y Pn�1 from

the list of extracted boundary points and repeat steps 1to 4 for the other boundary loops, till all the boundaryloops have been traced.

Page 5: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

Fig. 6. Detection of corner points: (a) determining if p is a candidate

point, (b) testing p for sharpness.

Fig. 7. Cubic Bezier curve approximation: (a) curve approximation in

anti-clockwise direction, (b) curve approximation in clockwise direction

(c) curve approximation from both directions, (d) optimized approxima-

tion.

M. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729 723

3.2. Finding corner points

Attneave [24] proposed that information along a contouris concentrated in the regions of high magnitude ofcurvature. Thus the most suitable locations for breakingthe outline into segments is the high curvature points andpiecewise curve approximation is carried out on each pieceas discussed in the next section. The algorithm for thedetection of corner points is based on the computation ofthe highest curvature at each contour point. The algorithmby Chetverikov and Szabo [25] is used, in this study, for thedetection of corner points. The algorithm works in twopasses. A brief description of the algorithm is as follows:

First pass: The sequence of points is scanned andcandidate corner points are selected. In each curve pointp the detector tries to inscribe in the curve a variabletriangle (p�, p, p+). The triangle varies between aminimum and a maximum square distance on the curvefrom p� to p, from p to p+ and the angle apamax

between the two lines a and b as shown in Fig. 6.Because the points are kept with their cartesiancoordinates, we can easily compute a. Triangles areselected starting from point p outward and stop at theconditions mentioned above. In that way a number ofadmissible triangles are defined. At a neighborhood ofpoints only one of these admissible triangles isselected—the one which has the smallest value for a.A value of sharpness is assigned to p.

� Second pass: The selection is refined and points that give

the strongest response are marked as high curvaturepoints in the curve. This is done by selecting onlypoints which have sharpness greater than that of theirneighbors.

3.3. Piecewise curve approximation

The outline marked with corner points is divided intocurve segments. Contour points between two consecutivecorners (inclusive) make one curve segment. Thus thenumber of segments is equal to the number of detectedcorner points. Cubic Bezier curve approximation is carried

out on each curve segment. In Section 2.3, we discussed theprocedure of control point estimation of cubic Beziercurves. Here, the cubic Bezier control point estimation iscarried out for each curve segment and consequently theapproximated curve is calculated using those estimatedcontrol points.As the segments (under approximation process) are not

the cubic Bezier curves, the approximation error may bevery significant as shown in Fig. 7(a). It can also be seenthat the curve approximation is better towards one side(at the start) of the curve and deteriorates at the other side(end of curve). The method of control point estimationworks fine over cubic Bezier curves, but needs someimprovements for non-parametric curves. The reason forthe low performance of curve approximation towards theend of curve is because the control point P1 is selectedalong the initial slope of the curve (at the start of a givencurve), whereas the control point P2 is calculated using theratio k. As per cubic Bezier curve properties, the controlpoint P2 should also be along the slope of the curve (at theend of curve). This property was automatically followed inthe case of cubic Bezier curve approximation (Fig. 3), but itis not necessary for non-parametric curves.To find both control points (P1 and P2) on their

respective slopes, curve approximation will be carried outfrom both directions. Fig. 7(a) and (b) show the curveapproximation from two directions. The two control pointsfound, namely P1,with curve approximation from start toend (shown with an arrow in Fig. 7(a)) and P2,with curveapproximation from end to start (shown with an arrow inFig. 7(b)), are the selected control points P1 and P2,respectively. Fig 7(c) shows the approximating curve withthese control points. To optimize the approximation, thecontrol points (P1 and P2) are moved along the samestraight lines (along the slopes at the start and at the endof the curves) till the approximation error is minimized.

Page 6: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESSM. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729724

Both control points P1 and P2 are either moved towards oraway from control points P0 and P3, respectively. One stepmovement of control points P1 and P2 must be propor-tional to the length of line P0P1 and P2P3, respectively.Fig. 7(d) shows the curve approximation after thisoptimization. Piecewise curve approximation of all seg-ments is carried out using same procedure.

Any two neighboring curve segments (in original out-lines) are either C0 continuous or higher-order continuous.In the ideal case, the two computed curve segments shouldbe stitched as per the continuity order of the originalsegments. Such dynamic continuity order is achievedautomatically by curve approximations using this method.As the approximated curve always follows the slope of theoriginal curve (at the start and at the end of the curve), ittherefore follows the continuity order of the originalsegments. Therefore the requirements of such dynamiccontinuity are achieved automatically using this method, asshown in Fig. 8.

3.4. Segment subdivision

In curve approximation, using the above method,sometimes the approximation error may exceed the giventhreshold (default value of 3) as shown in Fig 9(a). Segmentsubdivision is used to reduce the approximation error. Ifthe maximum approximation error is beyond the giventhreshold, the segment is divided into two sub-segments at

Fig. 8. Curve approximation showing that continuity follows the

continuity of the original curve at its end points.

Fig. 9. Curve approximation by segment subdivision: (a) curve approximation

division.

the point of maximum approximation error. The approx-imation error at any point of the curve is the minimumdistance from the other curve. The divided sub-segmentscan be processed for curve approximation recursively.Fig 9(b) shows the curve approximation by segment sub-division. For curve approximation, closer to the originalcurve (with lesser approximation error), the segment sub-division will increase, and therefore, the number of controlpoints will increase.

4. Comparative study

The main objective of the proposed technique was theaccurate representation of outlines without getting intocomplex computations and with fewer data points. Variouscapturing techniques are available in the literature[1,2,5,10,15–19,26–28]. By and large, these techniques werealso targeted to achieve similar objectives. Thus somecomparative study is necessary to properly analyze andevaluate the weaknesses and advantages of variousalgorithms. The analysis of results by visual appearanceis an important method which can incorporate measureslike closeness to the original curve, continuity/smoothnessand number of data points. However, a more quantitativeapproach is necessary owing to variations in the evalua-tions by different human observers. Another reason for thequantitative comparison is that some factors (such ashuman interaction, computational efficiency and complex-ity of the algorithm) are totally invisible during the generalobservation of results.Capturing results can be gauged on the basis of various

parameters such as error, complexity and continuity. Theimportant thing to understand is that these parameters arenot independent of each other, and improving oneparameter may affect the others. For example, approxima-tion with lesser data points would result in more errors.Similarly approximating a curve closer to the optimalwould need more time for computation. The amount ofcompromise between them would actually depend upon theparticular application. For example, a real-time applicationcannot compromise to time, and may even accept a lowerquality of approximation. Generally, a good algorithmis expected to maintain a good balance between theseparameters.

before segment sub-division, (b) curve approximation after segment sub-

Page 7: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESSM. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729 725

An algorithm can be judged by three basic parameters,namely, the amount of compression, approximation errorand computational time. Compression is normally ex-pressed in terms of number of data points or approximat-ing segments. However, the ratio of data points to thenumber of points in actual outline is a more expressiveparameter to represent the compression. We include bothparameters, namely the number of segments and compres-sion ratio, in our study. Similarly, there can be variousmeasurements of approximation error, and integralsquared error is the most important among them. We usean average error which is the normalized form of integralerror. This error is global in nature and tends to hide thelarge deviation on one part of the curve by close proximityon the other parts of the curve. The maximum error alongthe average error is an important measure, which canhighlight such deviations. Thus, the parameters used foranalysis of results in the proposed study are the number ofsegments, compression ratio, average error, maximumerror and computation time.

A first comparison of the proposed algorithm withdifferent algorithms, is shown in Fig. 10. The originaloutline of the ‘‘Kanji character’’ taken for the test is shownin Fig. 10(a). The result of the proposed algorithm is shownin Fig. 10(b). The selected corners and subdivision pointsare marked, with squares and circles respectively, over thecomputed outline. A similar methodology for the displayof results is used for other algorithms as well. Quantitativecomparison of these results is shown in Table 1. Theoutline captured with Itoh and Ohno [1] is shown inFig. 10(c). The approximating outline has the compressionratio of 66:84, which is very high when compared withother results. The captured outline also seems veryaccurate, which is confirmed by both in average andmaximum error values. High computation time (4.01 s) isone disadvantage of this algorithm. This is due to the leastsquare fitting with repeated reparameterization and deter-mination of the true corner position by intersection ofadjoining curves.

Fig. 10(d) and (e) shows the results of the softwarenamely ‘‘Arkan’’, which is available on the internet [26]. Italso approximates the outline using cubic Bezier and worksin two modes (automatic and semi-automatic). In the semi-automatic mode, the user selects the number of nodes, theirposition and type. Fig 10(e) shows the results in this mode.In the automatic mode, these things are detected auto-matically. Fig 10(d) shows the results in the automaticmode. Very high computational time (255 s) is one majordrawback of this algorithm in the semi-automatic mode.The results are relatively better in automatic mode. Thisalgorithm [26] performs extra smoothing of the curve,which is not desirable. A few such areas are shown by anarrow in Fig. 10(d) and (e). This algorithm [26] onlyhandles the outer loop, which is another disadvantage ofthis technique. The + sign with the number of segmentsand the -sign with compression ratio in Table 1 is also dueto the missing loops. The results of the algorithm [28] are

shown in Fig 10(f). When compared with the proposedalgorithm, the compression ratio is a little low, which isbalanced by lesser error. The difference lies in computationtime, which is about 1.65% higher.The outline captured by the algorithm [19] is shown in

Fig. 10(g). It computed the shape with 66 segments, whichis almost the number of segments taken by the proposedalgorithm. One reason for the high number of data points/segments is due to sub-optimal computation of cornerpoints It uses the Davis algorithm [29] for the detection ofcorner points. This corner detection is sub-optimal becauseit only finds the high curvature points which is highlyaffected by noise, size and resolution of shape. Thisalgorithm also suffers from corner localization. It is shownby an arrow in Fig. 10(g). High computation time (3.83 s) isanother disadvantage of this algorithm [19]. The majorreasons for high computation time are least square fitting,use of control parameters to increase the flexibility of theapproximating curve which need extra computations.Another capturing result with the algorithm [5] is shown

in Fig. 10(h). This algorithm [5] computes the approxima-tion with 31 segments, which is even less than the proposedalgorithm. The main disadvantage of this algorithm [5] isthe high computation time, higher error and inaccurateapproximation. The least square fitting and extra processof noise filtering are the two reasons for the highcomputation time in this algorithm. Both average errorand maximum error are more than double when comparedwith the proposed algorithm. The algorithm performs anoise filtering process before computation of the datapoints. This process causes a high reduction in data points,and introduces undesirable errors on the other hand. Theboundary becomes smooth after noise filtering and curvesare fitted to the cleaned boundary instead of the original,which is the main cause of the high error rate. Anotherdisadvantage of noise filtering is the extra smoothing ofshape, especially at the corners and the inaccuracy of thecomputed shape. Inaccuracy/distortion of a captured shapeis easily recognizable in a demonstrated result and this ishighlighted by arrows in Fig. 10(h). The result of thealgorithm [27] is given in Fig. 10(h). The number ofsegments (40) and computation time (4.81 s) are the twomain disadvantages of this algorithm.Another set of results is shown in Fig. 11 and Table 2.

When compared with other algorithms, the compressionratio (22:65) by the proposed algorithm is the lowest, butthe results are very accurate (Fig. 11(b)). Even fine detailsare captured by the proposed algorithm. This is alsoreconfirmed by the error values. Computation time is alsothe lowest by the proposed algorithm. The results of thePlass and Stone algorithm [2] are shown in Fig. 11(c). Itcaptures the shape with 26 segments and results in extrasmoothing at some places (highlighted by arrows). Thecomputation time by this algorithm is a little high (4.32 s).The reason for the high computation time is due to dynamicprogramming, to estimate the number of knots and the leastsquare fit. Authors use various strategies (like recursive

Page 8: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

Fig. 10. Comparison of results of different algorithms: (a) tested outline, (b) proposed algorithm, (c) Itoh and Ohno [1], (d) Arkan (semi-auto) [26],

(e) Arkan (auto) [26], (f) Schneider [28], (g) Sarfraz and Razzak [19] (h) Sarfraz and Khan [5] (i) Razzak [27].

M. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729726

division of a problem into a set of sub-problems) to containthe complexity of O(n3). The results of the Arkan algorithm[26] are shown in Fig. 11(d) and (e). The number ofsegments remains the same and vary in both the auto andsemi-auto modes. Both techniques result in the extrasmoothing of outline and hiding necessary details at variousplaces. This is marked by arrows. Therefore, the error

values of both techniques are high. The computation timeof the semi-auto mode is very high (74 s).Another set of comparative results is shown in Fig. 12

and Table 3. Generally, these results are very similar to theresults shown in Fig. 11. Extra smoothing of outline, errorvalues and computation time are again the areas of concernin this study. Again the compression ratio (50:37) of the

Page 9: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

Table 2

Quantitative comparison of results of Fig. 11

Shape Algorithm No. of Segs. Compr. Ratio Max error Avg error Comput. time (sec)

Shape of face ( ) Proposed 29 22.65 1.04 0.79 1.21

Plass and Stone [2] 26 25.27 2.65 1.95 4.32

Arkan (semi-auto) [26] 11 59.72 4.45 2.73 4.68

Arkan (auto) [26] 11 59.72 5.48 3.05 74

Fig. 11. Comparison of results of different algorithms: (a) Tested outline, (b) Proposed algorithm, (c) Plass and Stone [2], (d) Arkan (semi-auto) [26],

(e) Arkan (auto) [26].

Table 1

Quantitative comparison of results of Fig. 10

Shape Algorithm No. of Segs. Compr. Ratio Max error Avg error Comput. time (sec)

Kanji character ( ) Proposed 32 66.84 1.65 0.91 1.92

Itoh and Ohno [1] 28 76.39 1.73 1.02 4.01

Arkan (semi-auto) [26] 27+ 79.22- 2.57 1.54 5.38

Arkan (auto) [26] 14+ 152.79- 4.21 2.12 255

Schneider [28] 34 62.91 1.62 0.84 3.17

Sarfraz and Razzak [19] 66 33.42 1.40 1.13 3.83

Sarfraz and Khan [5] 31 69 3.78 1.92 3.61

Razzak [27] 40 53.48 0.98 0.79 4.81

M. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729 727

proposed algorithm is the lowest, but all other calculationsare best when compared with other algorithms [2,26].Generally, we found the following benefits of the proposedalgorithm when compared with different algorithms:

The proposed algorithm maintains a good balancebetween the compression ratio and the approximationerror. It represents the outline with the minimumsegments to properly capture the fine details. The effort
Page 10: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESS

Table 3

Quantitative comparison of results of Fig. 12

Shape Algorithm No. of Segs. Compr. Ratio Max error Avg error Comput. time (sec)

Shape of letter (G) Proposed 19 50.37 1.13 0.92 1.21

Plass and Stone [2] 14 68.36 2.41 1.62 4.93

Arkan (semi-auto) [26] 16 59.81 2.79 1.94 5.21

Arkan (auto) [26] 11 87 4.14 2.87 123

Fig. 12. Comparison of results of different algorithms: (a) Tested outline, (b) proposed algorithm, (c) Plass and Stone [2], (d) Arkan (semi-auto) [26],

(e) Arkan (auto) [26].

M. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729728

to increase the compression ratio results in extrasmoothing of shape as seen in different algorithms.

� Detected corner points by the proposed algorithm are

precise, accurate and well localized, which results inbetter approximation at the turns.

� It is a fully automatic program and needs no interaction

by the user.

� The proposed algorithm does not use the traditional

method of least square fitting, which a time consumingprocess. It presents a new method of computing thecontrol points of approximation cubic Bezier curves.This method is very simple and results in a highlyefficient algorithm.

The proposed algorithm does not guarantee an optimalsolution, but efficiently provides the curve with reason-able accuracy.

5. Concluding remarks

An outline-capturing scheme has been presented in thispaper using cubic Bezier curves. A control point estimationprocedure is used to estimate the suitable location ofcontrol points by exploiting the properties of cubic Beziercurves. If the approximation error of the computed curvesegment is beyond the specified threshold value, segmentsubdivision is done recursively to reduce this approximation

Page 11: Capturing outlines of planar images using Bézier cubics

ARTICLE IN PRESSM. Sarfraz, A. Masood / Computers & Graphics 31 (2007) 719–729 729

error. Since the approximation of one curve segment isindependent of the other, parallel processing can be used inits implementation. While approximating outlines, variablecontinuity requirements are automatically taken care of.The proposed method eliminates external interactions incapturing outlines. It can be used for many applications,like font designing, optimal character recognition andobject visualization.

The results of the proposed algorithm were comparedwith different algorithms. It has various advantages overthese algorithms like computational efficiency, accuraterepresentation and good balance between compression andapproximation error. The results can further be improvedby not using cubic polynomials, where the quadratic oreven straight lines can work. The authors are lookingforward to test this approach in future work. Some othercurve models are also under the consideration of theauthors; these might make some further improvements.

Acknowledgments

The authors are pleased to acknowledge the anonymousreferees for their valuable and healthy comments in theimprovement of this manuscript. The first author acknowl-edges the support of the King Fahd University of Petroleumand Minerals for this work against Project #ICS/REVERSEENG./312. The second author thanks the Higher EducationCommission (HEC) of Pakistan for providing funds and theUniversity of Engineering and Technology (UET) Lahorefor facilitating this research work.

References

[1] Itoh K, Ohno Y. A curve fitting algorithm for character fonts.

Electronic Publishing 1993;6:195–8.

[2] Plass M, Stone M. Curve fitting with piecewise parametric cubics.

Computer Graphics 1983;17:229–39.

[3] Sarfraz M, Khan MA. Automatic outline capture of Arabic fonts.

Information Sciences 2002;140:269–81.

[4] Carlos A, Cabrelli B, Molter UM. Automatic representation of

binary images. IEEE Transactions in Pattern Analysis and Machine

Intelligence 1990;12:1190–6.

[5] Sarfraz M, Khan MA. An automatic algorithm for approximating

boundary of bitmap characters. Future Generation Computer

Systems 2004;201:1327–36.

[6] Goldenthal R, Bercovier M. Spline curve approximation and design

by optimal control over the knots using genetic algorithms.

In:Proceedings of the international congress of evolutionary methods

in design, optimization and control with applications to industrial

problems, Cimne, Barcelona, Spain, 2003.

[7] Sarfraz M, Riyazuddin M, Baig MH. Capturing planar shapes by

approximating their outlines. International Journal of Computa-

tional and Applied Mathematics 2005;189:494–512.

[8] M. Sarfraz, A. Raza, ‘‘Visualization of data with spline fitting:

a tool with a genetic approach,’’ Proc. of Int. Conf. on Imaging

Science, Systems, and Technology, Las Vegas, Nevada, USA,

pp. 99–105, 2002.

[9] M. Sarfraz, S.A. Raza, ‘‘Capturing outline of fonts using genetic

algorithm and splines’, Proc. of International Conference on

Information Visualization, IEEE Computer Society Press, USA,

pp. 738–743, 2001.

[10] Tang YY, Liu J. Basic processes of Chinese character based on cubic

B-spline wavelet transform. IEEE Transactions in Pattern Analysis

and Machine Intelligence 2001;23:1443–8.

[11] Sohel FA, Karmakar GC, Dooley LS, Arkinstall J. Enhanced Bezier

curve models incorporating local information. In: Proceedings of

IEEE international conference on acoustics, speech, and signal

processing, 2005.

[12] Masood A, Sarfraz M. Capturing outlines of Arabic characters by

cubic Bezier approximation, In: Proceedings of the first international

conference on geometric modeling, visualization & graphics in

conjunction with the eighth joint conference on information sciences,

Salt Lake City, Utah, USA, 2005.

[13] Hu WC, Sheu HT. Quadratic B-spline for curve fitting. Proceedings

of the National Science Council ROC(A) 2000;24:373–81.

[14] Sohel FA, Karmakar GC, Dooley LS. A generic shape descriptor

using Bezier curves. Proceedings of the international Confe-

rence on Information Technology: Coding and Computing 2005;II:

95–100.

[15] Sohel FA, Dooley LS, Karmakar GC. Accurate distortion measure-

ment for generic shape coding. Pattern Recognition Letters 2006;

27(2):133–42.

[16] Yahya F, Ali JM, Majid AA, Ibrahim A. An automatic generation of

G1 curve fitting of arabic characters, international conference on

computer graphics, imaging and visualisation (CGIV’06). IEEE

Computer Society 2006:542–7.

[17] Sarfraz M, Rashid A. A randomized knot insertion algorithm for

outline capture of planar images using cubic spline. The Proceedings

of the 22nd ACM symposium on applied computing (ACM SAC-07).

Seoul, Korea: ACM Press; 2007.

[18] Sarfraz M. Some algorithms for curve design and automatic outline

capturing of images. International Journal of Image and Graphics,

2004;4(2):301–24.

[19] Sarfraz M, Razzak MFA. An algorithm for automatic

capturing of font outlines. Computers and Graphics 2002;26:

795–804.

[20] Bezier P. Mathematical and practical possibilities of UNISURF. In:

Barnhill RE, Riesenfeld RF, editors. Computer aided geometric

design. Academic Press: New York; 1974.

[21] Hearn D, Baker MP. Computer graphics. Place: Englewood Cliffs,

NJ; 1997.

[22] Sonka M, Hlavac V, Boyle R. Image processing, analysis, and

machine vision. Brooks/Cole publication 2001:142–3.

[23] Freeman H, Davis LS. A corner finding algorithm for chain-coded

curves. IEEE Transactions in Computers 1977;26:297–303.

[24] Attneave F. Some informational aspects of visual perception.

Psychological Review 1954;61:183–93.

[25] Chetverikov D, Szabo Z. A simple and efficient algorithm for

detection of high curvature points in planner curves. Proceedings of

the 23rd workshop of Australian pattern recognition group, Steyr

1999;1:175–84.

[26] Arkan software from Pixmart LLC, 2004. /http://patchmaker.net/

Arkan/S.

[27] Razzak FA. A web based automatic outline capturing of images.

MSc thesis, King Fahd University of Petroleum and Minerals

Dhahran, Saudi Arabia, 2001.

[28] Schneider P. An algorithm for automatically fitting digitized curves.

Graphics Gems 1990:612–26.

[29] Davis L. Shape matching using relaxation techniques. IEEE

Transactions in Pattern Analysis and Machine Intelligence 1979;1:

60–72.