Skip to content

Add Line Trace image import algorithm for line drawings#345

Open
olavl wants to merge 3 commits intojeffeb3:masterfrom
olavl:feature/line-trace-image-import
Open

Add Line Trace image import algorithm for line drawings#345
olavl wants to merge 3 commits intojeffeb3:masterfrom
olavl:feature/line-trace-image-import

Conversation

@olavl
Copy link

@olavl olavl commented Feb 17, 2026

Summary

  • Adds a new Line Trace image import algorithm that extracts actual drawn lines from line drawing images, instead of raster-scanning with brightness modulation
  • Uses skeleton-tracing-js (Zhang-Suen thinning + polyline extraction) to skeletonize the image into single-pixel-width centerlines, then connects them into a single continuous path via nearest-neighbor ordering
  • Exposes three new settings: Threshold (binarization cutoff), Min segment length (noise filter), and Simplify tolerance (Douglas-Peucker smoothing)
  • Fixes imageAmplitude option missing isVisible guard (was incorrectly shown for Waves)

Motivation

The existing 6 image import algorithms (Squiggle, Spiral, etc.) all treat the image as a tone map and modulate waveforms based on pixel brightness. For images that are already line drawings, users want the sand table ball to trace the actual lines rather than producing a raster pattern. This new algorithm fills that gap.

How it works

  1. pixelProcessor applies brightness/contrast/inversion (existing controls)
  2. 3x3 box blur smooths JPEG compression artifacts
  3. Threshold to binary (configurable)
  4. TraceSkeleton.fromBoolArray() skeletonizes and extracts polylines
  5. Short segments filtered (configurable min length)
  6. Douglas-Peucker simplification (configurable tolerance)
  7. Nearest-neighbor connects all polylines into one continuous path

Test plan

  • npm run build succeeds
  • All 125 existing tests pass
  • Upload a line drawing image, select "Line Trace" from the Type dropdown
  • Verify only Threshold/Min segment length/Simplify tolerance appear (plus global brightness/contrast/inversion)
  • Adjust threshold — captures more/fewer lines
  • Export as GCode and verify single continuous path

🤖 Generated with Claude Code

olavl and others added 3 commits February 17, 2026 15:22
Adds a new image import mode that traces actual drawn lines from line
drawing images, instead of raster-scanning with brightness modulation.
Uses skeleton-tracing-js (Zhang-Suen thinning + polyline extraction)
to extract centerlines, then connects them into a single continuous
path via nearest-neighbor ordering — suitable for sand table output.

New settings: Threshold, Min segment length, Simplify tolerance.
Also fixes imageAmplitude missing isVisible guard (was shown for Waves).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allow users to draw directly on the preview canvas with mouse or touch.
A pencil toggle button activates draw mode; mouse-up finalizes the stroke
as a new Drawing layer with Douglas-Peucker simplification and Chaikin
corner-cutting smoothing. Layers support free scaling and all existing
transforms/effects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…her res

- Replace greedy nearest-neighbor path connection with Graph + Chinese
  Postman + Eulerian trail for optimal traversal of all detected segments
- Add residual recovery pass that finds ink pixels missed by the skeleton
  tracer and traces them as additional polylines (toggleable checkbox)
- Increase image canvas resolution from 800x600 to 1600x1200 to preserve
  fine details like eyes and thin strokes
- Add "Thicken lines" (dilation) option for very faint line drawings
- Reduce snap radius from 3 to 1 to prevent merging distinct nearby features
- Default to zero simplification and zero min segment length for max fidelity

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant