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 *p*_{1} = (*x*_{1}, *y*_{1}) and *p*_{2} = (*x*_{2}, *y*_{2}), we compute the tangent vector *v* = (*x*_{2}*− x*_{1}, *y*_{2}*− y*_{1}). So, the normal vector at *p* is given by *n* = (*y*_{2}*− y*_{1}, *x*_{1}*− x*_{2}, 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

{\nu}_{i}^{\prime}=\frac{\left({\nu}_{i-2}+4{\nu}_{i-1}+6\nu +4{\nu}_{i+1}+{\nu}_{i+2}\right)}{16},

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:

n\left(s\right)=\left(nx\left(s\right),ny\left(s\right),0\right)=\left({y}^{\prime}\left(s\right),-{x}^{\prime}\left(s\right),0\right).

Our task is to compute a 3D normal

n\left(p\right)=\left(nx\left(p\right),ny\left(p\right),nz\left(p\right)\right),

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:

\begin{array}{ll}\hfill {n}_{x}\left(p\right)& =\frac{{\int}_{C}\frac{{n}_{x}\left(s\right)ds}{{\left|p-C\left(s\right)\right|}^{2}}}{w\left(p\right)},\phantom{\rule{2em}{0ex}}\\ \hfill {n}_{y}\left(p\right)& =\frac{{\int}_{C}\frac{{n}_{y}\left(s\right)ds}{{\left|p-C\left(s\right)\right|}^{2}}}{w\left(p\right)},\phantom{\rule{2em}{0ex}}\end{array}

where

w\left(p\right)={\int}_{C}\frac{ds}{{\left|p-C\left(s\right)\right|}^{2}}

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:

{n}_{z}\left(p\right)=\sqrt{1-{n}_{x}{\left(p\right)}^{2}-{n}_{y}{\left(p\right)}^{2}},

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:

w\left(p\right)={\int}_{0}^{2\pi}\frac{ds}{{\left(x-\text{cos}\left(s\right)\right)}^{2}+{\text{sin}}^{2}\left(s\right)}=\frac{2\pi}{1-{x}^{2}},

and

{n}_{x}\left(p\right)={\int}_{0}^{2\pi}\frac{\text{cos}\left(s\right)ds}{{\left(x-\text{cos}\left(s\right)\right)}^{2}+{\text{sin}}^{2}\left(s\right)}=\frac{2\pi x}{1-{x}^{2}}.

As n_{y} (*p*) *=* 0 by the symmetry, {\text{n}}_{\text{z}}\left(p\right)=\sqrt{1-{x}^{2}}. 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:

\overline{n}({p}_{i})=\left(1-\phi \left(\frac{d({p}_{i}}{{d}_{max}}\right)\right)(k-n({p}_{i}))+\left(n({p}_{i})\phi \left(\frac{d({p}_{i})}{{d}_{max}}\right)\right).

Where, \stackrel{\u0304}{n}\left({p}_{i}\right) 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

\phi \left(x\right)=\frac{-cos\left(\pi x\right)+1}{2}

Figure 7 shows the depth operator applied to a sphere.