- OpenCV 4 with Python Blueprints
- Dr. Menua Gevorgyan Arsen Mamikonyan Michael Beyeler
- 344字
- 2021-06-24 16:49:57
Creating a black-and-white pencil sketch
In order to obtain a pencil sketch (that is, a black-and-white drawing) of the camera frame, we will make use of two image-blending techniques, known as dodging and burning. These terms refer to techniques employed during the printing process in traditional photography; here, photographers would manipulate the exposure time of a certain area of a darkroom print in order to lighten or darken it. Dodging lightens an image, whereas burning darkens it. Areas that were not supposed to undergo changes were protected with a mask.
Today, modern image editing programs, such as Photoshop and Gimp, offer ways to mimic these effects in digital images. For example, masks are still used to mimic the effect of changing the exposure time of an image, wherein areas of a mask with relatively intense values will expose the image more, thus lightening the image. OpenCV does not offer a native function to implement these techniques; however, with a little insight and a few tricks, we will arrive at our own efficient implementation that can be used to produce a beautiful pencil sketch effect.
If you search on the internet, you might stumble upon the following common procedure to achieve a pencil sketch from an RGB (red, green, and blue) color image:
- First, convert the color image to grayscale.
- Then, invert the grayscale image to get a negative.
- Apply a Gaussian blur to the negative from step 2.
- Blend the grayscale image (from step 1) with the blurred negative (from step 3) by using color dodge.
Whereas steps 1 to 3 are straightforward, step 4 can be a little tricky. Let's get that one out of the way first.
The next section shows you how to implement dodging and burning in OpenCV.
- Flink SQL與DataStream入門、進階與實戰
- Bulma必知必會
- Python Geospatial Development(Second Edition)
- Java EE 7 Development with NetBeans 8
- MySQL數據庫管理與開發(慕課版)
- Visual Foxpro 9.0數據庫程序設計教程
- Learning Apache Karaf
- Building Wireless Sensor Networks Using Arduino
- Couchbase Essentials
- Machine Learning for OpenCV
- Python 快速入門(第3版)
- Learning ROS for Robotics Programming
- Apache Kafka 1.0 Cookbook
- Python深度學習入門:從零構建CNN和RNN
- Python深度學習:基于PyTorch