CHAPTER 4 STROKE GENERATION
4.4 Sketching the Contour on Pistil
We describe the procedure of generating pistil in this section. First, we use the process similar to section 4.2 to produce the pistil’s strokes. Then, the clustering algorithm will provide the colors which approximate the colors in input image.
4.4.1 Stroke Generation
In our proposed system, users need to specify the pistil area by dragging an ellipse. Then, this pistil image is the input of the following process. First, we use the Canny Edge Detector to extract its edges. Since artists usually draw exquisitely for pistil, we choose the lower thresholds than petal’s to get more detailed information.
Then, we define strokes similar to that in section 4.2.2. We change the second restriction to eliminate the lines which are connected outside the pistil area. Since these lines do not belong to the pistil, we have to avoid them being mistakes. After defining strokes, we apply the vectorization and brush model to them.
4.4.2 Color Determination
Unlike strokes of petal, painters draw pistils with more colors. So we use a simple color clustering algorithm to determine the colors. User can decide the amount of preferred colors by adjusting the parameter num. Then, the system will select num colors which appear mostly in pistil area as reference colors. When drawing a stroke, we calculate the disparities between these reference colors and the realistic color at the same stroke in the input image. Then, we choose the most similar color to dye this stroke.
Figure 4.15 A histogram on hue
In color clustering algorithm, we firstly follow all drawing strokes and select the pixels at the same position in the input image. Then, transform the color of these pixels from the RGB domain to HSI domain to establish a histogram on H. The values of H are classified into ten subdivisions as shown in Figure 4.15. We choose the highest num colors as reference colors. The S and I components of reference colors are assigned by the average of S and I in the same subdivision. When drawing a stroke, we extract the colors in input image of all points that lie on this stroke.
Calculate their average in RGB domain. Then, select a reference color which has the minimum difference from their average color to dye this stroke. Figure 4.16 shows the experimental result.
Figure 4.16 Examples of vein generation (b) Pistil area and
reference colors
(c) Generated pistils (a) Original image
Chapter 5 Washing
In this chapter, we discuss the dyeing effect in our system. First, we get the color information from input image. Then, we simulate the washing technique that is a traditional skill in Chinese Fine-Brushwork Painting. Finally, we blend the resulting image and the stroke image. Figure 5.1 shows the flowchart of washing.
In Chinese Fine-Brushwork Painting, coloring is the procedure following the contour sketching. Washing is the most important skill for coloring. Painters often apply washing technique several times to make the creation colorful and smooth. It may have different moving direction and dyeing color in each time of washing.
In section 5.1, we talk about the washing paths generation that simulate the dyeing paths for a brush. Then, we depict our proposed washing model in section 5.2.
It contains the dyeing algorithm, parameters determination, and the mixture of colors.
In section 5.3, we introduce the dimming procedure.
Figure 5.1 Flowchart of washing
5.1 Washing Paths Generation
This section introduces how the washing paths be generated. The washing paths simulate the routes when artists apply washing skill by using watered pen. We will dye along these paths when applying washing. First, users need to specify an area for dyeing. Then, the system will generate the washing paths automatically.
5.1.1 Extremities of Washing
Before starting washing, users need to specify the starting and ending points.
Users need to specify one starting point and several ending points. Since painters always washing from pistil to petal, we set the starting point at the pistil and ends at the petal as shown in Figure 5.2. Naturally, user can set the points anywhere, and the system will apply washing technique on the specified area.
Figure 5.2 Extremities of washing
5.1.2 Washing Paths Generation
According to the user-specified starting and ending points, we can generate the paths of washing. Artists often use colored pens to apply dyestuff on the center of flower, and then they may use watered pens to dye from the center to the petal. We
Figure 5.3 Washing paths
Figure 5.3 shows the grey area where we want to dye. The points Ustart and Uend
are the starting and the ending point. We trisect the line UstartUend to get points U1
and U2. The purpose of trisection is to let these four points Ustart, U1 , U2 and Uend be the four control points of a Bezier curve. Then, we fix the point Ustart and move other points U1, U2 and Uend in the vertical direction of line UstartUend . The length of moving is preset in the system. Therefore, through the new points we get and the fixed point Ustart, we can obtain a new set of Bezier curve’s control points. Consider Figure 5.3, Bezier curve Qi’s control points are Ri,0 , Ri,1, Ri,2, Ri,3. Thus, we will get a new Bezier curve when we move three points in the vertical direction. As painting area is covered by all curves, the system will stop to generate Bezier curves automatically. At this time, all the curves are the watered pen’s paths that we anticipate as the dotted line in the Figure 5.3.
5.2 Washing Model
This section introduces how we simulate the traditional dyeing technique
“washing” (渲染)of Chinese Fine-Brushwork Painting. Our model is based on the actual painting procedure and observations. We imitate the procedures of painting and apply several methods in image processing to synthesize the result of washing. First, washing paths are constructed as discuss in section 5.1. Then, when the brush sweeps along the washing paths, we may apply an exponential function to simulate color diffusion. Finally, we mix the color pigments with background color to produce the result.
5.2.1 Washing by Water Pen
There are pigments in colored pen when washing. Watered pen just delivers water for pigments diffusion. In our proposed model, we combine the colored and watered pens and apply pigments on the watered pen directly.
It is different from sketching the contour. Since the brush for washing is softer than Hong-do pen, we use an ellipse to model the contact region of watered pen on alum-Hsuan paper. For easy of implementation, the size of ellipse is fixed. Figure 5.4(a) shows the contact region C. Variables a and b are the major axis and minor axis respectively.
Ellipse C will move along the washing paths and sweep the footprints as the color calligraphy on the canvas. It is similar to the brush model described in Chapter 4.
But, it is a little difference. Ellipse C will rotate when moving along the path.
forward along Qi, it will aim its y-axis at the direction of point Pk’s tangent on the curve.
Figure 5.4 Washing model
When C moves along with Qi, C will leave pigments on the canvas. We hypothesize that every point has its capacity. We set pigment 100 is full, 0 is empty.
When C passes though Pk, we will decide how much percentage of pigments to leave by C according to an exponential function. That is a method which we figure it out by observing artists’ washing.
To implement this method, we set two thresholds tLow and tHigh. They will influence dyeing color’s variation. Then, we pick a random number r between these two thresholds. Variable r is the power of the exponential function as shown in Eq 5.1.
We pick 100 points P on curve Qi. It means ellipse C will cover Qi one hundred times.
Nall is the total pigment number on the brush. The pigment number NPk that C left on Pk is:
(b) A path for washing (a) Contact surface
99 ,
In Eq5.1, when setting a larger r, the exponential function will vary sharply. Then, we may get intensely variation of color. In other way, if we have a smaller number of r, we generate color variation smoothly. The number of r is controlled by thresholds tLow and tHigh. We can adjust them automatically according to the input image. The
detail procedure of their determination will be depicted in next section.
When C leaves a footprint on Qi, we divide NPk equally by the amount of pixels in C and set it to the quantity of these pixels’ pigment. If it exceeds the capacity of pixel, we set it the maximum of capacity. After C passes by one Qi, system will compare the pigment distributed on Qi with the pigment on Qi-1. If the pixel on the same position already has some pigments in previous step, the more will be selected and will remain instead of adding them together. We suppose that watered pen will take some pigments away when pigment’s quantity of a pixel is too high. It avoids the situation that pixels are always at the state of saturation. In addition, to avoid that every curve Qi uses the same exponential function, this situation will lead to the result of being too smooth. So, we choose random number on every Qi again to decide variable r, the power of every exponential function. Figure 5.5 shows examples of washing.
Figure 5.5 Examples of washing with random randnum by tHigh=8, tLow=3
5.2.2 Parameters Determination
When applying washing, we need to determinate three parameters, tHigh, tLow, Nall. The last one is specified by users because it depends on the consistency of color pigment they want to dye. But parameters tHigh and tLow, can be decided by color variation of the input image.
Figure 5.6 Parameters determination
As shown in Figure 5.6, the blue one is the area we want to dye. The points Ustart and Uend are the starting and the ending point. We divide line UstartUend into four parts equally by points U1, U2 and U3. Then, we separate them into two groups, colorstart and colorend, by comparing their color in input image. We calculate the color disparities separately between Ui and Ustart, Ui and Uend. If Ui’ color is close to Ustart’s, set Ui in the group of colorstart, and vice versa. After all points are assigned, we can find the boundary of two groups, such as the line L in Figure 5.6.
Since L corresponds to the color changed sharply in input image, we determine thresholds tHigh and tLow according to L’s position. If L is close to point Ustart , we set a large thresholds to obtain dyeing color vary sharply near Ustart and vice versa.
The following List 5.1 shows the values of tHigh and tLow and Figure 5.7 shows their influence.
Table 5.1 The values of thresholds in washing L position value of tHigh value of tLow
between Ustart and U1 13 10
between U1 and U2 8 3
between U2 and U3 3 1
between U3 and Uend 1.5 1
Figure 5.7 Examples of washing by (a) tHigh=13, tLow=10 (b) tHigh=8, tLow=3 (c) tHigh=3, tLow=1 (d) tHigh=1.5, tLow=1
5.2.3 Color Mixture
Every time after simulating the effect of washing, we will start to do the color mixture. In our system we take Subtractive Color Mixture to model the overlapping of color. In section 5.2.1 we got an image with the distribution of color pigments. We still map the pigments’ quantity to color. We set the color of canvas as the background color such as yellowish brown. Because the capacity of pigment is 100, the full pigment (100) will totally cover the background. It will show the color which we want to dye. If the pigment is less than the full capacity, the percentage of pigment will determine the degree of color mixture. As Eq 5.2 shown below, Nx,y is the pixel’s quantity of pigment, colord is the color which we want to dye, and colorb is the background color. The pixel’s color colorx,y will be:
colorb
Since the process washing will be performed several times, we let the current pixel’s color be the background for the next washing process. Therefore, we can achieve the goal of multilayer color mixture. List 5.2 shows the algorithm of washing.
Table 5.2 The washing algorithm Washing Algorithm
Input: --- CloseSetClas area /* painting area and washing paths */
ImageClass inputImg /* background image */
Color col /* dyeing color */
Int Nall /* quantity of pigment in watered pen */
Double tHigh, tLow /* thresholds of exponential function */
Output: --- ImageClass outputImg /* washing image */
---
for(every points x in watered pen )
rotate the mask of watered pen, aim its y-axis atP ’s tangent; k Nx = ( NPk / watered pen.size)+ Nx ;
5.3 Dimming Procedure
After washing, we apply a dimming procedure to let the color approach traditional Chinese colors.
Since we washing with the color obtained from input photograph, the color is too brighter to simulate the traditional Chinese colors. Unlike Western Painting, Chinese painters usually use sober color to present implicit and gentle mind. Furthermore, the material of Chinese color is made by minerals or plants, so most of all are turbid and dim. To achieve this effect, we mask a gray-level image on the dyed image. We transform original input into gray-level image, and mix the dyed image with it in the ratio 8:2, as shown in Figure 5.9.
Finally, when all washing procedure is completed, the combination of sketched images and dyed images is the final result. We show them in the next chapter.
Figure 5.8 Examples of dimming procedure
(a) Gray-level image (b) Dyed image (c) Mix by 0.2*(a)+0.8*(b)
Chapter 6
Implementation and Results
In this chapter, the implementation and results are presented. The input sources are colored photographs and users need to separate them into different objects by painting software. The algorithm are implemented in C++ language on BCB with an AMD XP 2500+ CPU and 512MB DDR RAM.
Example 1 is a 800×600 image as shown in Figure 6.1. Figure 6.2 shows the intermediate results of sketching the contour and multi-washing. 6.2(a) shows the partial original image. Its extracted contours are shown in 6.2(b), and 6.2(c) shows the result after applying the brush model to it. Figures 6.2(d)-(f) show the intermediate results of multi-washing procedure. We first use washing skill from petal to pistil as shown in Figure 6.2(d). Then, use it again inversely as shown in 6.2(e). Finally, Figure 6.2(f) shows the result after dimming procedure. Figure 6.3 is the composition of Figure 6.2(c) and (f). The final result of this example is shown in Figure 6.4 and the corresponding parameters are displayed in Table 6.1. Figures 6.5 and 6.6 show the other results of washing by different times.
Figure 6.1 The original image of example 1
Figure 6.2 (a) Sub-original image (b)(c) Sketching the contour (d)(e) Multi-washing by two times (f) Dimming procedure
Figure 6.3 The composition of Figure 6.2(c) and (f)
Figure 6.4 Final result of example 1 by two times washing
procedure parameters Sketching the Contour Canny Edge Detector high=0.9, low=0.6, δ=1.2 Stroke Definition X=50
colord =RGB(229,243,254) (selected by Uend’s color ) Second Washing
from pistil to petal (showed in Figure6.2(e))
tHigt=8, tLow=3 (automatically generated by 5.2.2) Nall =1500000
colord =RGB(233,217,104) (selected by Ustart’s color ) Third Washing
Table 6.1 Parameters of example 1
Figure 6.5 (a)(b)(c) Multi-washing by three times (d) Dimming procedure
Figure 6.6 Final result of example 1 by three times washing
Example 2 is a 600×800 image as shown in Figure 6.7, and Figure 6.8 shows its final result. Figure 6.9 shows its intermediate results of washing. Figure 6.9(a) shows the result of washing from petal to pistil, and 6.9(b) shows the washing result from pistil to petal, and the result of dimming procedure is shown in (c). The corresponding parameters of this example are displayed in Table 6.2.
Figure 6.7 The original image of example 2
Figure 6.8 Final result of example 2
(a) (b) (c)
Figure 6.9 (a)(b) Multi-washing by two times (c) Dimming procedure
procedure parameters Sketching the Contour Canny Edge Detector high=0.82, low=0.4, δ=0.8 Stroke Definition X=20
colord =RGB(143,40,122)(selected by Uend’s color ) Second Washing
from pistil to petal (showed in Figure6.9(b))
tHigt=8, tLow=3 (automatically generated by 5.2.2) Nall =100000
colord =RGB(227,225,189)(selected by Ustart’s color ) Table 6.2 Parameters of example 2
Example 3 is a 800×800 image as shown in Figure 6.10, and Figure 6.11 is its final result. The result of applying first washing skill from petal to pistil is shown in Figure 6.12(a), and 6.12(b) shows the second washing result from pistil to petal.
Figure 6.12(c) shows the result after dimming procedure. The corresponding parameters of example 3 are displayed in Table 6.3.
Figure 6.10 The original image of example 3
Figure 6.11 Final result of example 3
(a)
(b) (c)
Figure 6.12 (a)(b) Multi-washing by two times (c)Dimming procedure
procedure parameters Sketching the Contour Canny Edge Detector high=0.95, low=0.8, δ=0.9 Stroke Definition X=50
Vectorization error=5.0
Brush Model start=1.0, base=2.0, k=0.2, S1=0.5,S2=0.5 Vein Generation level=2, ө=35
Pistil Color Determination num=3
Multi-Washing First Washing
from petal to pistil
(showed in Figure6.12(a))
tHigt=3, tLow=1 (automatically generated by 5.2.2) Nall =1500000
colord=RGB(211,195,117)(selected by Uend’s color ) Second Washing
from pistil to petal
(showed in Figure6.12(b))
tHigt=10, tLow=6 Nall =1500000
colord=RGB(207,45,86)(selected by Ustart’s color ) Table 6.3 Parameters of example 3
Chapter 7 Conclusion
In this thesis, we propose a method to synthesize Chinese Fine-Brushwork Painting on flowers. We simulate this style by two important processes: contour sketching and coloring. In the former process, we design a brush model to simulate Hong-do pen style and propose a complete procedure for extracting the contours from input image. In coloring, we synthesize the traditional Chinese dyeing technique, washing (渲染), and approximate the effect of multi-coloring(三暈九染)by washing several times. Therefore, users may generate Fine-Brushwork Painting style easily by using our proposed system without any painting skill.
However, there are still some issues left to be studied in the future.
(1) The contours extracting procedure is not generic. Our approach can not find correct strokes of complex flowers, such as peony. Since this flower’s petals are layered, the stroke definition process can not obtain proper strokes. So, we hope to extend our stroke definition to handle more complex flowers.
(2) Our dyeing procedure only focuses on washing skill (渲染法). Although it is the major technique of dyeing, there are still other skills of coloring in Fine-Brushwork Painting such as covering (罩色法)or foiling (襯托法) . So, integrating more dyeing techniques will help users to generate more colorful creations.
(3) Our proposed system uses the basic Subtractive Color Mixture method. This method simulates the traditional Chinese color mixture roughly but not exactly.
Moreover, the other advanced methods focus on the color mixture of Western Painting, such as KM model. We hope to find a suitable or integrate several color mixture methods for traditional Chinese colors.
Reference
[1] 王定理著,"中國畫顏色的運用與製作",藝術家出版社,1993 初版。
[2] 朱子弘著,"國畫色彩研究",藝術家出版社,1984 初版。
[3] 周士心著,"國畫技法概論",中國文化大學出版部,1986 初版。
[4] 劉玉霞繪著,"畫好國畫-工筆花鳥",藝術圖書公司,1988 初版。
[5] Bill Baxter, Vincent Scheib, Ming C. Lin, and Dinesh Manocha. DAB:
Interactive haptic painting with 3D virtual brushed. Proceedings of ACM SIGGRAPH 01, pages 461-468. 2001.
[6] John Canny. A computational approach to edge detector. IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. Pami-8, NO.6 November, 1986.
[7] Ching Chan, Ergun Akleman, and Jianer Chen. Two methods for creating Chinese painting. IEEE Computer Graphics and Application. 2002.
[8] Cassidy J. Curtis, Sean E. Anderson, Joshua E. Seims, Kurt W. Fleischer, and David H. Salesin. Computer-generated watercolor. Proceedings of ACM SIGGRAPH 97, page 421-430. August 1997.
[9] Haeberli. Paint by numbers. Proceedings of ACM SIGGRAPH 90. 1990.
[10] Aaron Hertzmann. Painterly rendering with curved brush strokes of multiple size.
Proceedings of ACM SIGGRAPH 98, page 453-460. 1998.
[11] Sheng-Wen Huang, Der-Lor Way, and Zen-Chung Shih. Physical-based model of ink diffusion in Chinese ink painting. Journal of WSCG. 2003.
[12] Jintae Lee. Simulating oriental black-ink painting. IEEE Computer Graphics and Applications.1999.
[13] Wei-Jin Lin and Zen-Chung Shih. Computer-generated Chinese painting with
[13] Wei-Jin Lin and Zen-Chung Shih. Computer-generated Chinese painting with