Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cartoonizing real images

does anybody know we can translate from real image captured using cameras be converted to the cartoon space ?

Please note that my goal is not to create animations or the likes, but just to translate to "cartoon colors" if possible.

will simple requantization to a space where there is less quantization levels work Or some other specific transforms are better ?

any help will be useful, as I wasn't able to find any material on this.

Thnx in advance.

like image 618
Egon Avatar asked Oct 17 '10 17:10

Egon


2 Answers

Pyramid mean shift + outline of detected edges seems does the job.

The code:

cv::Mat segmented, gray, edges;
cv::pyrMeanShiftFiltering(input, segmented, 15, 40);
cv::cvtColor(segmented, gray);
cv::Canny(gray, edges, 150, 150);
cv::cvtColor(edges, edgesBgr, CV_GRAY2BGR);
cv::Mat result = bgr - edgesBgr;

Here is a result i got: Church after cartoon filter

Details: OpenCV Tutorial Part 6

like image 110
BloodAxe Avatar answered Oct 19 '22 22:10

BloodAxe


What you're trying to do is most commonly done from 3D models and is called cel-shading, or "toon-shading". Basically, you try to force uniform colors and force abrupt transitions at certain angles with respect to the light source.

Obviously, this does not translate well to 2D input images. What you can do, is to requantize but making sure you uniformly fill regions and break where the image gradient is high.

Non-linear diffusion is a denoising technique that forces regions to become uniform to remove noise. If you let it loop for too many iterations, you get a cartoon-looking image.

I've implemented that maybe 2-3 years ago and it worked suprisingly well considering it was not so hard to implement. However, you're going to want a GPGPU implementation because it is slow!

like image 22
André Caron Avatar answered Oct 19 '22 23:10

André Caron