My app works with photos and videos of people, which I want to cartoonify. So I need an algorithm to do it manually (we use c++/Qt for our product, which has image manipulation classes) or perhaps some CLI program that will do it for me that I can call and use from our own app.
相关问题
- Finding k smallest elements in a min heap - worst-
- binary search tree path list
- High cost encryption but less cost decryption
- Is it possible to pass command-line arguments to @
- How to get a fixed number of evenly spaced points
相关文章
- What are the problems associated to Best First Sea
- Coin change DP solution to keep track of coins
- Linux - change the hostname in the CLI
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- How to measure complexity of a string?
- Select unique/deduplication in SSE/AVX
If there's some set of parameters which achieve the desired effect in the GIMP's Cartoon filter (or some other combination of filters) it can be run in a batch processing mode.
Here's some algorithms to play with:
These are fairly basic and all very easy to implement. Keep in mind that median and box blur filters can be implemented with linear time complexity w.r.t. the kernel radius.
More edits:
Once you get the idea of Huang's algorithm, implementing a box blur filter is a delicious piece of cake.
Reading material:
Other reading materials include Gonzalez & Woods' Digital Image Processing (seems to be an older edition) for segmentation and edge tracing. 8-way edge tracing can be really hard to bend your head around (choosing between on-pixel or between-pixel edges and how to latch onto edges). I'd be happy to share some code, but the hundred-liners don't exactly fit smoothly in here.
You might want to check out Freestyle, an open-source (Google Summer of Code, even) project to implement a non-photorealistic renderer for Blender. Here's an example of its output, in cartoon-mode: alt text http://freestyle.sourceforge.net/GALLERY/CARTOON/girl-color-and-lines-crop.jpg
It's relatively easy to do. Here are the steps:
bilateral filtering to simplify/abstract the photo. You may want to separate the bilateral filter so that it's faster. Perform the bilateral filter in 1d along the gradient and then along the normal to the gradient.
detect the edges. For instance, using a Difference of Gaussians algo. You may want to use the DoG in the gradient direction and smooth it following the flow lines. To get the flow lines, you would need to get the Edge Tangent Flow (ETF) which you can get via structure tensor.
quantize the colors. Actually, you quantize the luminance to simulate cel shading aka toon shading.
blend the abstracted image afer quantize and the edges you detected.
This will give you a rendered image that looks like a cel shaded cartoon.
I made some free software (for win64) that does exactly this at: http://3dstereophoto.blogspot.com/p/painting-software.html
The name of the software is "The Cartoonist" and you can see it in action here: http://3dstereophoto.blogspot.com/2018/07/non-photorealistic-rendering-software_9.html
Those are links to my blog which primarily deals with 3d photography (depth maps, photogrammetry, etc).
Not sure if this will help, but this tutorial for Photoshop suggests doing the following:
Here's the result.
I imagine that you could do something similar in your program.
I have not done this myself, but thinking about two steps that might give the image a cartoonish look.
Detect edges, and draw a fairly fairly thick line (a few pixels) on those edges.
Decrease the number of colours in your image.