Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 2.93 KB

process_overview.md

File metadata and controls

49 lines (38 loc) · 2.93 KB

Process overview

####1. Color quantization The colorquantization function creates an indexed image (https://en.wikipedia.org/wiki/Indexed_color)

alt Original image (20x scale) ####2. Layer separation and edge detection The layering function creates arrays for every color, and calculates edge node types. These are at the center of every 4 pixels, shown here as dots.

alt layer 0: black alt layer 1: yellow alt edge node examples ####3. Pathscan The pathscan function finds chains of edge nodes, example: the cyan dots and lines.

alt an edge node path ####4. Interpolation The internodes function interpolates the coordinates of the edge node paths. Every line segment in the new path has one of the 8 directions (East, North East, N, NW, W, SW, S, SE).

alt interpolating alt interpolation result ####5. Tracing The tracepath function splits the interpolated paths into sequences with two directions.

alt a sequence

The fitseq function tries to fit a straight line on the start- and endpoint of the sequence (black line). If the distance error between the calculated points (black line) and actual sequence points (blue dots) is greater than the treshold, the point with the greatest error is selected (red line).

alt fitting a straight line

The fitseq function tries to fit a quadratic spline through the error point.

alt fitting a quadratic spline alt fitting line segments alt result with control points

If the fitseq function can not fit a straight line or a quadratic spline to the sequence with the given error tresholds, then it will split the sequence in two and recursively call fitseq on each part. ####6. SVG rendering The coordinates are rendered to SVG Paths in the getsvgstring function.

Ideas for improvement

  • Error handling: there's very little error handling now, Out of memory can happen easily with big images or many layers.
  • Color quantization: other algorithms?
  • Color quantization: colors with few pixels are randomized, but probably the most distant colors should be found instead.
  • Tracing: 5.1. finding more suitable sequences.
  • Tracing: 5.5. Set splitpoint = (fitting point + errorpoint)/2 ; this is just a guess, there might be a better splitpoint.
  • Tracing: 5.7. If splitpoint-endpoint is a spline, try to add new points from the next sequence; this is not implemented.
  • Tracing: cubic splines or other curves?
  • Default values: they are chosen because they seemed OK, not based on calculations.
  • Output: PDF, DXF, G-code or other output?