In this work, we propose a novel formulation for the normal field inside each region. This normal field enables the application of illumination effects, like Phong model, providing 3D impression to the cartoon. Our normal definition is accurate and sphere-preserving, which leads to smooth and coherent illumination.
Normal field of the curves
For each region, we first compute the normal field of the boundary [4]: given two consecutive boundary points p1 = (x1, y1) and p2 = (x2, y2), we compute the tangent vector v = (x2− x1, y2− y1). So, the normal vector at p is given by n = (y2− y1, x1− x2, 0).
The coordinate z = 0 indicates that the image plane is the projection plane relative to the viewer and the curve belongs to the object's silhouette.
Since we are working in an 8-connected neighborhood, the normal vector obtained above is restricted to these eight directions. This constraint has as consequence a low quality at the illumination effect. Thus, if a point p
i
has normal v
i
, a smoothing process is obtained by applying a discrete Gaus-sian filter to the normal vi′. The new normal vector vi′ is
where v
i−
2, v
i−
1,v
i
+1 and v
i
+2 are the normal vectors of the p
i
neighbors. The normal vectors of the internal curves of the region are computed in a similar way.
Normal field of the interior
The normal field of the interior of the region is interpolated from the boundary normal field. Our proposed formulation is described in the continuous domain:Let C be a closed curve parameterized by arc-length, C (s) = (x(s), y(s)), and let R be a region delimited by C. The normal vector n(s) at each point of C (s) is given by:
Our task is to compute a 3D normal
for each point p = (x, y, z) in ℝ.
First of all, we compute the components n
x
and n
y
. This is done by integrating the normal contributions along the curve C, where the contribution of each point C (s) is weighted by the inverse square distance from p to C (s). So, for each p ∈ R, n
x
(p) and n
y
(p) are obtained by:
where
The next step is to calculate the n
z
component. This step is similar to [14]. We consider that the normal field we want to reconstruct is over a surface that rises smoothly from the curve C (s) contained in the image plane (where n
z
= 0). This normal field points toward the viewer, so the n
z
component is positive. In addition, nz should be calculated so that the normal vector field is normalized. So, the nz component is obtained by:
If the region has internal curves, the normal vectors of theses curves may be used to compose the final normal field of the interior of the region during the interpolation process presented above. If these internal curves are not considered during the interpolation process, only the boundary curves will affect the normal field of the region.
Normal field analysis
We now do an analysis of the surface "generated" by our normal interpolation method. Is it smooth? How it behaves over its domain (the image plane)? First of all, we demonstrate that if C is a circle our interpolation technique provides exactly the normal field of a sphere.
Proof In the case that C is a circle, C (s) = (cos(s); sin(s)). Due to the properties of functions sine and cosine, we considered just the case when p = (x, 0), with − 1 < x < 1. For the others values, we can simply rotate the coordinate system or get them by symmetries. Applying the symmetry once more, n
y
(p) must be zero, since the contribution of C (s) is canceled by the contribution of C (−s). After performing the integration, we conclude:
and
As ny (p) = 0 by the symmetry, . Therefore, the normal field is exactly the same of a sphere of radius 1 centered at the origin.
When we consider internal curves to interpolate the normals, points on these curves are presented as singularities on the surface. On the other hand, if we consider only the boundary, the surface behaves smoothly over the domain.
Unlike Johnston [14], where an approximated normal propagation is obtained to calculate the normal map, our explicit formulation is accurate. Moreover, due to the flexibility of the proposed structure, it is possible to choose which curve contributes in the region interpolation process. This makes it possible to obtain effects as shown in Figure 5.
Normal operators
The proposed region-tree structure is also suitable for applying attribute operators to the regions and to the curves of the cartoon. As the flexibility of our region-tree allows quick access to topological structures present in the cartoon, we can modify, in an efficient and independent way, the attributes of curves and regions. Some attributes are color, thickness, normals, depth, etc. To demonstrate this flexibility, we implemented two normal operators: the scale region operator, and the depth curve operator.
Scale operator
Given a region R, the operator consists in scaling the n
x
, n
y
, or n
z
normal coordinate. If the scale is applied on the n
z
coordinate, the visual effect is to lift the curve when illumination is applied. Figure 6 shows two different z-scales applied to the normal mapping of the smallest circle.
Depth operator
This operator deals with the idea of rising/sinking the selected curve C located in a region. The user controls the affected area surrounding the curve C and may rise or sink this curve. To do so, we calculate the distance information of each pixel located in a tubular neighborhood of C whose radius is the maximum distance d
max
chosen by the user. All pixels located in the tubular region will have their normal affected by the depth operator. For each pixel p
i
, with normal n(pi), we obtain its distance d(pi) to the curve and calculate its new normal n(pi) by adding an increase vector u(pi) to the vector n(pi). The increase vector u(pi) is calculated by some function considering that it converges to (0, 0, K ) if p
i
is near to the curve, and converges to (0, 0, 0) if vector p
i
is away from the curve. We implemented the following equation:
Where, is the new normal vector of the point p
i
, n(pi) is the normal vector of the point p
i
, k = (0, 0, 1) and φ is a function where φ(0) = 0 and φ(1) = 1. We used
Figure 7 shows the depth operator applied to a sphere.