1th step: Reduce Image Color
Because the smooth and flat area of the bilateral filter keeps the edges clear at the same time, it is ideal for converting RGB images to cartoons. Although the speed seems to be slower, one technique is to repeat (for example, by num_bilateral = 77 times) To apply a small bilateral filter instead of just one large bilateral filter.
3rd Step: Creating Outlines
After noise reduction, you can safely apply adaptive thresholds to create outlines. Even if there is some image noise, blockSize = 9 of the CV2. The Adaptive_thresh_mean_c algorithm also ensures that the threshold value is applied to the average of the 9x9 neighborhood minus C = 2.
4 steps: Combining outlines and color images
The final step is to combine the processed color image (Img_color) with the Edge Mask (Img_edge). At this point, a cartoon can be a picture of the original code is written. Picture effect a bit of the aesthetics of science and technology, not enough literature and art, the effect lost to Photoshop, but in the efficiency of a city.
Finally, the above code is encapsulated into a function. Import Python's OS module to facilitate file processing.
J into the group: 125240963 to get dozens of sets of PDFs Oh!
Since the python, I have not used PS! Take you to the photo into a cartoon picture!