CVGIP:
GRAPHICAL
MODELS
Vol. 53, No. 1, January,
AND
pp. l-6,
IMAGE
PROCESSING
1991
Expressive Brush Strokes BINH PHAM Department
of Computer
Science, Monash Communicated
University,
Clayton,
3168 Victoria,
Australia
by Norman I. Badler
Received May 24, 1988; accepted September 27, 1989
Strassmann [8] attempted to simulate brush painting in a more general fashion by modeling a hierarchy of four objects: brush as composed of bristles, stroke as a trajectory of position and pressure, dip for describing the initial state of a brush, and paper as a mapping onto a display device. Both position and pressure are interpolated using a cubic spline to give a series of nodes, and the width of the stroke at each node is calculated as a function of the pressure. For each pixel within the area covered by the stroke, a generalized polygon interpolation algorithm is used to assign its position along the stroke and the bristle which passes closest to it. As pixels are generated, they are sorted chronologically into a temporary array and then displayed. The dip is used to determine the amount of ink on a bristle at a given time and hence the color of each pixel in the stroke. Although this technique models brush painting faithfully in detail and produces good results, the computation involved is complex and expensive. Furthermore, the task of simulating pressure is neither intuitive nor simple. It is desirable, therefore, to design a simpler technique for simulating the effect of a brush stroke without imitating the exact details involved in the actual painting process. Ideally, it also should rely mainly on human visual perception and intuition. The technique described in this paper is based on the concept of variable offset cubic B-splines. Some results for generating constant offset approximation of uniform cubic B-splines were given in [6]. The aims of this technique are to facilitate the process of inputting data and to produce expressive brush strokes with the amount of computation significantly reduced. The representation of a brush stroke is also chosen so that animation can be done conveniently. The thickness of a stroke is represented by the offset distances at both sides of the stroke. Each bristle is considered as a 3D cubic B-spline where the first two coordinates are spatial and the third coordinate denotes the shade of gray. Section 2 deals with the technique for computing the offset approximation of a cubic B-spline when the offset distance is not constant along the curve. Section 3 describes in detail the representation of brush strokes to-
Expressive brush strokes are modeled using a technique based on variable offset approximation of uniform cubic B-splines. The trajectory of a brush stroke is represented as a 3D cubic B-spline and each bristle as a 3D offset cubic B-spline of this trajectory. The first two coordinates are the spatial position coordinates and the third coordinate represents the shade of each bristle. This technique facilitates the process of inputting data, simplifies the computation task, and provides some advantages in the animation process of brush strokes. o ~FX Academic PKSS. IX.
1.
INTRODUCTION
Although more advanced techniques in image generation allow realistic objects and scenes to be created, there is an increasing demand for the development of techniques for rendering objects and scenes which are artistically pleasing. In computer animation and painting, for example, people are not merely satisfied with the effects of photographic exactness, but demand the style and expressiveness produced by the artistic flair. Early painting systems were limited to building copies of static patterns repeatedly. A few later systems produced more realistic images, but were only pixel-based (see, for example, [4]). In order to find a computationally convenient method for representing shapes used in graphic arts and typesetting, Ghosh and Mudur [3] used a brush-trajectory method. They derived algebraic solutions to describe the resulting outlines for some specific brushes and trajectories of linear, circular, elliptical, and cubic types. They also used a closed convex brush defined by a fourth-order parametric equation to describe more complex shapes. Although these techniques are efficient. they are not suitable for interactive use in a painting system, as it is not easy to specify the required parameters in a painting stroke. Pang et al. [5] developed a Chinese painting system, which was based on a set of parameterized primitives of brush strokes. Procedures for representing many elements of a picture, such as leaves, branches, and waves, are built into the system. By altering parameters in the routines, different pictures can be constructed. 1
All
1049-9652/91 $3.00 Copyright 0 1991 by Academic Press, Inc. rights of reproduction in any form reserved.
2
BINH PHAM
gether with the implementation. Section 4 discusses the advantage of this representation in computer-assisted animation.
&I d
w 2. VARIABLE OFFSET APPROXIMATION CUBIC B-SPLINES
i
OF UNIFORM
=%
Cubic B-splines are very popular in free-form design as FIG. 2. A B-spline, its offset, and their knots. they provide a simple parametric curve representation and smooth curve fitting. Furthermore, the shape of a curve can be easily modified locally by using a small set of control points. Given a set of (n + 1) control vertices into control vertices for a cubic B-splines. In this paper, Vj,wherej=O,l,. . ., n, the parametric representation we have used the Gauss-Seidel iterative process derived of the ith segment C;(t) of a uniform cubic B-spline is in [9] for the inversion. Given a cubic B-spline C(t), we are interested in finding defined by a method for generating an offset cubic B-spline C(t) if the offset distances dj at knots wherej = 0, 1, . . . n are (2.1) given (see Fig. 2). The offset distances are in the direck=-2 tion of the normals to the curve C(t) at knots. Let C(t) = (X(t), Y(t)); then the direction of the normal to the curve where parametric t is such that t E [O, l] and i = 0, 1, C(t) at any point (x, y) is given by . . . ) IZ - 1. bk(t) are the basis functions given by (see Fig. 1) cos (Y = - (iz +yy2),,2 and sin (Y = (i2 +xj2),,z, b-2(t) = g-t3 + 39 - 3t + 1) b-I(t) = Q(3t3- 6t2 + 4) (2.2)
ho(t) = Q(-3t3 + 3t* + 3t + 1) b,(t) = Qt3.
where X and jt are the values of partial derivatives of X(t) and Y(t) at point (x, y) (see Fig. 3). Let the control vertices Vj, knots Pj, and offset knots Pj be such that Vj = (Uj, uj), Pj = (Xj, yj), and Pj = (q, j$). We have the following result.
Hence a cubic B-spline curve is a piecewise cubic polynoLEMMA. The coordinates of the offset knots Pi, mial which has continuity in position, and first and sec- where j = 0, 1, . . . , n, are given by ond derivatives at knots or joints of segments. These properties allow very smooth curves to be generated. xj=xj+ djMx and yj=yj+ djMy, There also exist efficient and stable algorithms for calculating cubic B-splines (see [2]). Although control vertices where h4, = (vj+ 1 - uj-i)lN and My = (aj+l - aj-1)/N, with provide some guidance for manipulating the shape of the *)*]“*e N = [(uj+l - uj-l)* f (uj+l curve, some experience on the part of a designer to In [61, we have derived this result for the case when the achieve the shape refinement is required. An inexperioffset distances are a constant (i.e., dj = d, for j = 0, 1, enced user would prefer to specify a set of points on the desired curve itself and to be able to construct the cubic B-spline through them. To attain this goal, Yamaguchi [9] developed a simple inversion algorithm to convert knots Uj-
V 6
FIG. 1. A cubic B-spline with knots Pi and control vertices Vi.
FIG. 3. Normal direction at a knot.
EXPRESSIVE BRUSH STROKES
. . . , n). The proof is similar for the case of variable offsets. Thus the coordinates for offset knots can be computed readily from those of knots and control vertices of the original curve once the offset distances are known. The inversion algorithm can again be used to obtain the control vertices, which in turn will be used to generate the offset B-spline curve. We note that the same technique may be used to generate offset curves on both sides of the original curve. 3.
REPRESENTATION
OF BRUSH STROKES
Unlike Strassman’s method, we do not attempt to simthe action of an artist during the painting process or to capture the evolution of the bristles chronologically as they move along the stroke. Instead we model the result of a brush stroke given certain constraints. Our main intention is to find a simple and efficient representation for a brush stroke, at the same time retaining its aesthetic appearance. The representation consists of three major components: the trajectory, thickness, and shade. ulate
3.1.
Trqjectory und Thickness
In Chinese brush painting, every brush stroke has a definite trajectory along which a brush is moved. The amount of ink absorbed by the paper on either side of the trajectory varies mainly with the pressure and the amount of ink put on the brush by the artist. This results in different shades for a brush stroke. The trajectory is modeled as a cubic B-spline whose knots can be input by using a mouse. The number of knots entered depends on the shape of the trajectory. However, in our experience, very few knots are required for a fairly complicated trajectory. Every stroke in Plates 1-5 was painted with only 5 knots. In [7], the thickness of the stroke is calculated as a
3
PLATE 2. Examples of scratchiness and spreading bristles.
function of pressure. As the brush is moved along the path, each bristle is updated by modifying its properties, such as relative position and color. To simplify the computation and to make use of human visual intuition, we define the thickness of a brush stroke in terms of the offset distances at knots on both sides of the path. The offset knots on the boundaries of a stroke can be input by using a mouse, and the offset distances can then be computed as Euclidean distances. Each bristle is represented as an offset B-spline curve whose knots need not be input individually. The knots can be obtained easily by using the result of Lemma I and assuming that the offset distance between each bristle is the offset distance from the path to each boundary divided by the number of bristles. Thus the path of each bristle can be automatically generated once the offset knots at the boundaries are input. The number of bristles is specified by users according to the desired thickness and density of each stroke. Both the thickness and the number of bristles can differ for each side of the path. Although the assumption of uniform spacing between bristles satisfies the basic need in brush painting, irregularity of bristle spacing sometimes occurs. A typical example is application of strong pressure to only on one side of a brush for some irregular effect. In this case, the distance between bristles can be varied by specifying the relative offset distance of each bristle from the trajectory at each knot. The absolute offset distance is then calculated, and Lemma 1 is again applied to produce the knots for each bristle. 3.2. Shades
PLATE 1. Examples of different shading effects.
To achieve realism, it is desirable to allow the shade of a bristle to vary along its path according to some constraints specified by a user. This effect can be achieved easily by modeling each bristle as a 3D offset B-spline curve whose first two coordinates are the spatial coordinates and whose third coordinate represents the shade value at each point on the bristle. The shade values at knots on each bristle may be obtained by linear interpolation. Hence an input file for shade values at knots on the trajectory together with the offset values on both boundaries is required for each brush stroke. To facilitate the inputting of shade values at knots on the trajectory and their offsets, we can display the available range of shades in a horizontal bar at the bottom of the screen. A shade
4
BINH PHAM
PLATE 3. Little sparrow.
value may then be chosen by positioning a mouse at the appropriate shade on this bar. Each bristle is thus generated as a 3D B-spline curve which consists of a series of small line segments together with a shade value at each end point of the line segment. The line segments of two adjacent bristles form a series of quadrilaterals (see Fig. 4). Each quadrilateral is then shaded with the average value of the shade values at the four vertices. As B-splines provide smoothness for curve fitting, they also blend smoothly the shades of gray from one knot to another along a bristle.
By varying the shade values and their offsets at knots, we can create any variation of shades along and across the bristles. The effect may vary in different ways and at different rates along the two sides of the brush trajectory. The main advantage of modeling the bristles as 3D Bsplines is that they provide ease and flexibility in manipulating the shape and shades of brush strokes locally. If any part of a stroke is not satisfactory, we need only change the position or the shade value at the knot located near that particular area. Plate 1 displays some examples of smooth shading effects.
PLATE 4. In the wind.
5
EXPRESSIVE BRUSH STROKES
PLATE 5. Flowers and reeds.
The above method does not confine us to generate only smoothly shaded strokes. Other effects such as dryness or scratchiness may be achieved by modifying the shading task accordingly. To attain the effect of spreading bristles, we shade every alternate bristle with the shade of the paper. The effect of scratchiness at any area can be seen by applying the same modification locally. Scratchiness at random locations along a bristle can be achieved by using a random number generator. Plate 2 shows examples of these shading effects. Abrupt changes in shading and direction of trajectory are also desirable in brush painting. Both effects can be achieved by using a well-known result concerning coincident control vertices for B-splines. If a double vertex is used, the resultant cubic B-spline has a sharper change in curve direction at the corresponding knot. Similarly, a cusp which gives a more abrupt change in direction can be produced by using a triple vertex (see, for example, [l]). When these properties are applied to shade values
FIG. 4. Quadrilaterals formed by two adjacent bristles.
instead of to spatial coordinates, the effect of an abrupt change in shading is obtained. Different types of control over shades and scratchiness of strokes can be readily adapted without sacrificing the main advantages of this method for brush stroke representation. For example, instead of specifying the shade of each knot on the trajectory manually, a user can specify a function which calculates shade values in terms of relevant parameters such as pressure, brush type, velocity of the brush, and the initial amount of ink present in the brush. This would result in extra computational costs for evaluating this function at knots. 4.
ANIMATION
OF BRUSH STROKES
The above representation makes it easier for animation of brush strokes to be adapted. In computer-assisted animation, key frames are specified and the computer is used to produce in-between frames by using linear interpolation or moving point constraints (see 171).Transformations such as scaling, rotation, and translation are needed for describing the relationship between frames. One advantage of using B-splines for curve representation is that these transformations can be performed on the control vertices instead of on the curve itself. Let S, T, and R be the scaling, translation, and rotation matrices, respectively. Let the ith segment of a cubic B-spline be transformed by these transformations into a curve segment D;(t). Then we have
6
BINH
Di(t) = SRCi(t) + T.
5. CONCLUSION
(4.1)
LEMMA 2. Di(t) is a cubic B-spfine segment whose control vertices are obtainedfrom those of Ci(t) using the same transformations.
Proof. AS c:=p, bx(t) = I, and Ci(t) is given in (2. I), we can rewrite (4. I) as
D;(t) = SR i V;+,bk(t) + i Tbx(t). h--Z A=-?
PHAM
(4.2)
We have described a simple technique for modeling brush strokes which retains the expressiveness and aesthetic essence of brush painting style. Plates 3-5 display some painting done by this method. All strokes were generated from only five control vertices. The technique is more suitable for interactive purposes since it relies mainly on human visual perception and intuition. Furthermore, it provides some advantages for using brush painting as another medium for computer-assisted animation.
Let the set of transformed control vertices be Wi ; then w;+r = SRV;+r + T.
REFERENCES I.
R. H. Bartels,
J. C. Beatty,
By substituting this into (4.2f, we obtain
D;(t) = ,Y$ Wi+kbk(t). A=-?
Morgan-Kaufmann,
Graphics
Altos,
CA,
1987.
2.
C. De Boor, 1972. 50-62.
3.
P. K. Ghosh and S. P. Mudur. The brush-trajectory figure specification: Some algebraic solutions, ACM 1984, 110-134.
4.
Hence Di(t) is the ith cubic B-spline segment whose control vertices are Wi. The transformation matrices S, R, T may be in terms of some functions of time which need not be linear. This property allows for nonlinear variation in time and in space; hence, we can specify multiple paths and speeds of interpolation in the animation process. As the shade values are represented as the third coordinate, we can also specify a separate transformation function to allow these shade values to vary from frame to frame.
Los
An Introduction to and Geometric Modeling,
and B. A. Barsky,
Splines .f;w Use in Computer
R. Green,
On calculating
The
drawing
with
prism:
B-splines,
A versatile
J. Approx.
Theory 6, approach
to
Trans. Graph 3,
graphic
input
device,
Comput. Gruph. 19, 1985, 103-I IO.
5.
Y. J. Pang, S. X. Yang. with Chinese traditional
6.
B. Pham,
Offset
and Y. Chi, Combining computer graphics painting, Comput. Gruph. 11, 1987, 63-68.
approximation
of uniform
B-splines.
CAD 1. 20, 8.
1988, 471-474. W. T. Reeves, lnbetweening for computer animation utilizing ing point constraints, Comput. Gruph. 15, 1981. 263-269. S. Strassmann,
Hairy
brushes,
Proc. SIGGRAPH
mov-
‘86 22, 1986, 22%
232. F. Yamaguchi, A new curve fitting method using a CRT computer display, Cornput. Gruph. Image Process. 7, 1978. 42.5-437.