Bleistift-Skizze — weicher Graphit per Color-Dodge

`img.pencilSketch(strength)` ist der klassische Photoshop/ GIMP-Color-Dodge-Trick: Graustufen, invertieren, weichzeichnen, dann das Originalgrau durch `1 - geblurrtes_invertiertes` teilen. Die Division verstärkt feine dunkle Details an Kanten, sodass diese wie weiche Bleistiftstriche aussehen; flache Flächen bleiben nahezu weiß. Keine harten Sobel-Kanten — deutlich näher an einer echten Graphit-Zeichnung als naive Edge-Detect- Skizzen. `STRENGTH` ist der Blur-Sigma. 5-10 = feine Schraffur, 15-30 = breiter Graphit-Schatten (Standard 20), 40+ = ausgewaschen. Eine kleine Helligkeits-/Kontrast-Korrektur danach hält das Ergebnis davon ab, zu blass zu wirken.

INPUT
INPUT — Bleistift-Skizze — weicher Graphit per Color-Dodge
Pencil sketch
Pencil sketch — Bleistift-Skizze — weicher Graphit per Color-Dodge
JavaScript
// Pencil-sketch effect — colour-dodge classic
// demo_pencil_sketch.js
//!INPUT: INPUT
//!OUTPUT: OUTPUT
//!PARAM: STRENGTH:number=20,min=2,max=60
//!PARAM: BRIGHTNESS_TOUCHUP:number=1.05,min=0.5,max=1.5
//!PARAM: CONTRAST_TOUCHUP:number=1.10,min=0.5,max=2.0

// `img.pencilSketch(strength)` is the classic Photoshop / GIMP
// "colour-dodge" trick: convert to greyscale, invert, blur,
// divide the original grey by `1 - blurred_inverted`. The
// division amplifies subtle dark micro-detail around edges so
// they read as soft pencil strokes; flat regions stay near
// white. No edge-detection harshness, much closer to a real
// graphite drawing than naive Sobel-style sketches.
//
// `STRENGTH` is the Gaussian sigma applied to the inverted
// copy:
//   - 5–10  → tight, fine pencil hatching feel
//   - 15–30 → broader graphite shading (default 20)
//   - 40+   → washed-out, almost watercolour
//
// A small brightness/contrast nudge after the sketch keeps the
// result from going too washed-out — pencil drawings have more
// punchy mid-tones than a naive colour-dodge would give. Set
// either to 1.0 to disable.

const img = Engine.loadImage(INPUT);
img.pencilSketch(STRENGTH);
if (CONTRAST_TOUCHUP !== 1.0) { img.contrast(CONTRAST_TOUCHUP); }
if (BRIGHTNESS_TOUCHUP !== 1.0) { img.brightness(BRIGHTNESS_TOUCHUP); }
img.save(OUTPUT);
img.free();

// © 2026 Michael Lechner · mlc OpticScript · https://mlcgo.eu · Elastic License 2.0