About Cewu Lu's "combining Sketch and Tone for Pencil Drawing Production" A text pencil drawing algorithm understanding and record.

Source: Internet
Author: User

  Links to related papers: combining Sketch and Tone for Pencil Drawing Production

The first time to see "combining Sketch and Tone for Pencil Drawing Production" a article in two years ago, feel free to look at, think of the formula in the paper more, thought to achieve a certain degree of difficulty, did not go to scrutiny, recently on the author's homepage to see there [ Code of Direction Classification] part of the codes, after downloading feel still have their own implementation of the possibility, the following records of their own implementation process of some experience and experience.

Pencil painting has always been a more difficult to obtain a more ideal effect of the algorithm, I see the paper in this article should be said to be very good. Overall, the algorithm consists of two steps:

1, line Drawing with Strokes get a picture S.

2, Tone Mapping get another picture T.

3. Get the final result R = S * T;

It should be said that the first step determines the final effect, the author through the following four steps to get the S graph.

(1), The edge of the original image detection, the author's paper gives the formula is:

The effect of the implementation of this formula is actually very weak, I think the author may not actually use the modified formula, because this step on the effect of the final effect is very large, I used some other can better detect the effect of the edge detection algorithm, if Sobel or PS findeges and other algorithms.

The author thinks that the result of this formula has too much noise and the edge part of the line is many discontinuous, so it is proposed to continue a few steps to get a more stable effect.

(2) The resulting g is a convolution of 8 directions, the convolution core is 1 along the specified direction, the other values are 0 (in fact, considering anti-aliasing, with bilinear interpolation is worth the convolution core), the size of the convolution core paper is presented as the image width or height of 1/30 (this I think a bit not, when too big, There will be obvious unreasonable lines appearing), the concrete formula is as follows:

In the relevant code given in the paper, there are the following parts:

%%convolution kernel with horizontal direction kerref= Zeros (ks*2+1); Kerref (KS+1,:) =1;%%Classification Response=zeros (h,w,dirnum);  forII =0: (dirnum-1) Ker= Imrotate (Kerref, ii* the/dirnum,'bilinear','Crop'); Response (:,:, II+1) = Conv2 (Imedge, Ker,'same'); End

In fact, the convolution here is based on the specified angle of motion blur, we can use MATLAB code to verify:

For example, when the angle is 22.5 (ii = 1) and the kernel size is 5 (KS = 5), the ker variable obtained by the above code is:

The result of normalization is:

The corresponding motion-blurred convolution matrix is (the corresponding MATLAB code is: H = fspecial (' Motion ', 2*5+1, 22.5):

Visible only a very small difference.

(3) After obtaining the convolution results in each direction, the response of each pixel, which has the largest convolution value, is set to G, and the response in the other direction is set to 0, the text of the word is:

The classi?cation is performed by selecting the maximum value among the responses of all directions and is written as

I think it's a bit strange that the above statement is the maximum value, the formula given below is the minimum value, this is everyone's clerical error. (It should actually be the maximum value).

Also note that the G (P) here refers to the G in the formula (1).

(4) The response to the various aspects of the obtained direction is again convolution, namely:

This paper proposes to convolution the results and reverse-phase processing to get the result s, this actually depends on your own coding method.

Here are some intermediate results for the above 4 steps:

 

Map Edge detection Figure 22.5 degree convolution Figure 22.5 degree response graph Intermediate result graph S

About Cewu Lu's combining Sketch and Tone for Pencil Drawing Production The understanding and recording of a pencil drawing algorithm.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.