skills/cv/stroke-normalize-simplify-pipeline/SKILL.md
Normalize raw stroke coordinates to 0-255 range, resample at uniform arc-length spacing, then apply Ramer-Douglas-Peucker simplification
npx skillsauth add wenmin-wu/ds-skills cv-stroke-normalize-simplify-pipelineInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Raw hand-drawn strokes have arbitrary coordinate ranges and irregular point spacing. A three-step pipeline — normalize to [0, 255], resample at uniform arc-length intervals, then simplify with Ramer-Douglas-Peucker — produces clean, compact stroke representations. This reduces point count by 3-5x while preserving shape fidelity, improving both storage efficiency and model performance.
import numpy as np
import math
def resample(x, y, spacing=1.0):
output = []
px, py = x[0], y[0]
cumlen, offset = 0, 0
for i in range(1, len(x)):
dx, dy = x[i] - px, y[i] - py
seg_len = math.sqrt(dx*dx + dy*dy)
cumlen += seg_len
while offset < cumlen:
t = (offset - (cumlen - seg_len)) / seg_len
output.append((px + t*dx, py + t*dy))
offset += spacing
px, py = x[i], y[i]
output.append((x[-1], y[-1]))
return np.array(output)
def normalize_strokes(strokes):
all_pts = np.concatenate([np.array(s).T for s in strokes])
mn, mx = all_pts.min(axis=0), all_pts.max(axis=0)
rng = max(mx - mn)
result = []
for s in strokes:
pts = np.array(s, dtype=float).T
pts = (pts - mn) / rng * 255
resampled = resample(pts[:, 0], pts[:, 1], spacing=1.0)
result.append(np.round(resampled).astype(np.uint8).T.tolist())
return result
(pt - min) / max_range * 255data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF