Yang
Yang

Reputation: 41

convert an image into color pencil sketch in OpenCV

I want to convert an image to a color pencil sketch using OpenCV. And I have read the page I want to convert an image into pencil sketch in OpenCV .The effect which I seek is like http://www.showandtell-graphics.com/photosketch.html I used the color dodge by code

b_d = (b_2==255? 255: min(255, b_1*255 /(255- b_2)));        
g_d = (g_2==255? 255: min(255, g_1 *255/(255- g_2)));             
r_d = (r_2 ==255? 255: min(255, r_1 *255/(255- r_2)));  

It seems work not very well. PLS help.

Upvotes: 4

Views: 9853

Answers (1)

karlphillip
karlphillip

Reputation: 93468

The overall procedure is detailed in the link you gave us, so you need 3 images to achieve this effect.

Make a copy of the original image and convert it to grayscale.

Make a copy of the grayscale image and invert this image.

At this point, image #1 is the original, image #2 is grayscale, and image #3 is the inverted image.

Then, apply the color dodge to image #3 (making it white) and execute the blur. This alone will give you the pencil sketch effect in grayscale.

If you want the final result to be colored, you will have to blend image #3 with image #1.

Looking for information on blending? Check this, this and this.

Upvotes: 8

Related Questions