Im2Pencil: Controllable Pencil Illustration from Photographs

Yijun Li, Chen Fang, Aaron Hertzmann, Eli Shechtman, Ming-Hsuan Yang

Introduction

Image stylization—the process of transforming photographs into artistic renderings—is a long-standing challenge in computer graphics. While traditional Non-Photorealistic Rendering (NPR) methods offer high levels of control, they often lack the organic texture and nuance of human-drawn sketches. Conversely, modern deep learning approaches like Image-to-Image translation and Neural Style Transfer often struggle with pencil drawings due to a lack of paired training data and the inherent complexity of the medium, which combines structural outlines with tonal shading.

Im2Pencil addresses these challenges with a two-branch neural network framework designed to generate highly controllable, realistic pencil illustrations. By decoupling the generation of outlines and shading, the system allows for fine-grained adjustments to stroke styles, "sketchiness," and hatching patterns.

Methodology: The Two-Branch Framework

The core innovation of Im2Pencil is its separation of concerns, mirroring the workflow of a human artist. The framework consists of an Outline Branch and a Shading Branch.

Overcoming the Data Scarcity Problem

A primary hurdle in training neural networks for this task is the absence of perfectly aligned photo-sketch pairs. Im2Pencil bypasses this by using an "abstraction trick." Instead of mapping photos directly to drawings, the researchers take real pencil drawings and apply algorithmic filters (such as Extended Difference-of-Gaussians, or XDoG) to strip away textures, leaving only basic edge and tone maps. This creates synthetic "abstracted input -> real drawing" pairs. At inference time, a photograph is similarly abstracted, allowing the network to translate it into the pencil domain.

Overview of pencil outline and shading styles supported by the Im2Pencil framework.

Outline and Shading Synthesis

  • Outline Branch: This branch uses an autoencoder with residual blocks to translate XDoG-extracted edges into realistic pencil strokes. Users can choose between "rough" and "clean" styles, as shown in the figure above.
  • Shading Branch: To avoid the "gradient trap"—where networks produce unnatural, localized squiggles by following micro-gradients—the authors implemented a two-stream architecture. The primary stream processes a structural edge map, while a secondary stream provides weak guidance from a tone map. This forces the model to generate natural, sweeping hatching strokes.

Stylistic Control and Datasets

To train these branches, the authors curated a specialized dataset from web-scraped pencil drawings. The Outline Dataset contains 60 drawings categorized as "rough" or "clean." The Shading Dataset includes 80 drawings across four distinct styles: hatching, crosshatching, blending, and stippling. Through data augmentation, these were expanded into thousands of training patches. This categorization enables users to mix and match styles, such as pairing clean outlines with stippled shading, to achieve a specific aesthetic.

Results and Evaluation

Qualitatively, Im2Pencil produces distinct, directional strokes that avoid the "gray smudge" artifacts common in baseline methods like CycleGAN. Quantitatively, a user study involving 50 subjects showed a strong preference for Im2Pencil. In comparisons against both CycleGAN and leading procedural NPR methods, Im2Pencil was preferred 78.3% of the time on original tone images. Even when baselines were aided by tone-adjustment preprocessing, Im2Pencil maintained a 60.3% preference rate.

Conclusion and Future Work

Im2Pencil demonstrates that separating structural and tonal components is key to realistic neural stylization. While the method currently depends on the quality of initial abstraction filters—which can struggle with highly textured scenes—it represents a significant step toward combining the realism of AI with the procedural control of classical graphics. Future work aims to provide even more granular, parameter-driven tweakability within the neural framework.

Summary updated

BibTeX
@inproceedings{li2019im,
  author = {Yijun Li and Chen Fang and Aaron Hertzmann and Eli Shechtman and Ming-Hsuan Yang},
  title = {{Im2Pencil: Controllable Pencil Illustration from Photographs}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2019},
  doi = {10.1109/cvpr.2019.00162},
}
Figure