Before-After Morph
Produce smooth morph videos that sell the emotional impact of a simulated outcome — ideal for iPad 咨询室展示.
Pipeline
- Align both images via eye-nose anchor similarity transform
- Cross-dissolve 0–100% over 2–3 seconds (simple)
- Mesh morph landmark-interpolated warp (premium)
- Export MP4 + GIF + WebM
Alignment (required)
Misaligned morphs look like lighting changes, not structural change.
import cv2
import numpy as np
def align_faces(before, after, src_pts, dst_pts):
M, _ = cv2.estimateAffinePartial2D(src_pts, dst_pts)
h, w = before.shape[:2]
return cv2.warpAffine(after, M, (w, h))
Anchor points: left eye center, right eye center, nose tip (stable across warps).
Morph Types
| Type | When | Quality |
|---|---|---|
| Dissolve | Quick preview | ⭐⭐ |
| Landmark lerp | Same person, structural change | ⭐⭐⭐⭐ |
| Optical flow | Subtle skin/filler changes | ⭐⭐⭐ |
Export Specs
- Resolution: match before image, max 1080p for display
- Duration: 2.5s loop (before→after→hold→reverse optional)
- FPS: 30
- Add corner label:
SIMULATION
Script
python scripts/morph_sequence.py before.jpg after.jpg --output morph.mp4 --duration 2.5
python scripts/morph_sequence.py before.jpg after.jpg --output morph.gif --fps 15
Creative Variations
- Split-screen wipe: after image wipes left over before
- Slider export: generate 10 frames for interactive before/after slider UI
- Slow reveal: mask expands from nose region outward (rhinoplasty reveal)
See examples.md for ffmpeg post-processing (fade, logo overlay).