mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
The Automatic palette counts flat art's colours by area (a colour needs about 1% of the picture, 0.5% at Colors 100) and fits that count with median cut and area-weighted k-means. A stem, a highlight, or a near white beside a pale background (within 24 levels, so in one box) was averaged into a large neighbour; mixed-colour merging and Noise could then remove what was left. On the flat route only, after the count is fitted, rare_colours finds the colours too rare or too close for it and keeps those that are distinct (at least 2.5 in Oklab x 100 from every palette colour and from the main colour each stands for), flat (mostly one histogram bin) and drawn (a 4-connected region of their own unblended pixels of at least 8 pixels, or three of at least 4); a colour lying between two others, as anti-aliasing mixes them, must also have an inside. At most six, largest region first. They stay fixed while the other colours are refitted around them; merge_mixed leaves them alone; denoise_keeping keeps their regions of 4 pixels or more whatever Noise is (smaller specks still go). Full Tone, Limited and Automatic's continuous-tone route are unchanged, and denoise without kept labels is as before. Methods cited in the code: median cut (Heckbert 1982), k-means (Lloyd 1982), Oklab (Ottosson 2020), salient-colour preservation (Fukuda et al. 2019, doi:10.1117/12.2521607). The rule and its numbers are VectorCraft's own; Adobe does not document how its palettes are chosen. Tests (code-drawn): a rare stem or patch over 2-8 flat colours, hard and anti-aliased at 1x and 2x; near-white highlights on #FFF4E0 kept and still paths at Noise 16; a 3 px #909090 stem on #808080; scattered single pixels of the same areas add no colour; denoise_keeping at Noise 0-32. Measured on 66 synthetic flat logos (22 designs x hard 1x, anti-aliased 1x and 2x; local inputs): every key colour and no spurious one in 66 (was 39); missing key colours 0 (was 43), spurious 0 (was 2), merged pairs 0 (was 46); rendered dE00 0.348 -> 0.138. Four public-domain scan crops take the continuous-tone route and are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tBcdwNhptqtmX32JCGFzB
51 lines
3.8 KiB
Markdown
51 lines
3.8 KiB
Markdown
# Adjusting an Image Trace
|
||
|
||
Select a placed raster image, then choose **Image Trace** or a preset from its arrow
|
||
in Properties or the Control bar. The original image stays inside the tracing object so
|
||
that subsequent adjustments always use the original pixels.
|
||
|
||
To adjust the result, select the tracing object and click **Image Trace** in Properties or the
|
||
image icon in the Control bar: the Image Trace panel opens with **Advanced** expanded. An existing floating or docked panel is activated in
|
||
its current location. Opening the controls does not add a document undo step.
|
||
|
||
| Control | Range | Effect |
|
||
|---|---|---|
|
||
| Threshold (Black and White) | 0–255 | Higher values include lighter pixels as black ink. |
|
||
| Paths | 0–100% | Higher values fit outlines more closely to the image. |
|
||
| Corners | 0–100% | Higher values preserve more sharp turns. |
|
||
| Noise | 1–100 px | Suppresses small connected regions; higher values remove more small details. |
|
||
| Method | Abutting / Overlapping | Chooses shared boundaries or stacked overlapping paths. |
|
||
| Create | Fills / Strokes | Creates filled areas, stroked lines, or both. |
|
||
| Ignore Color | Color picker | Leaves out the selected color (white by default). |
|
||
|
||
Sliders apply on release, and their numeric fields can be edited directly. Each committed
|
||
adjustment re-traces the selected object as one undo step and changes the preset to Custom.
|
||
While dragging, the preset and Enhanced row stay in place until release so the
|
||
slider retains its active interaction. Committed settings are synchronized immediately,
|
||
so Undo also restores the panel values before its next frame. View can show the source image, the result, outlines, or combinations without re-tracing.
|
||
Use **Expand** when finished to turn the result into ordinary editable vector objects;
|
||
after expanding, the tracing settings are no longer available. **Release** restores the source.
|
||
|
||
**Auto Color** (the Automatic palette) counts flat art's colours by area, and also keeps colours too
|
||
rare for that count when they are distinct and drawn as regions of their own (a stem, a highlight, a
|
||
white beside a cream), at most six; scattered specks of a colour add none. Adobe does not document how
|
||
its own palettes are chosen; this is VectorCraft's own method (see
|
||
[image-trace-quality.md](image-trace-quality.md#auto-color-keeps-rare-colours)).
|
||
|
||
**Large images.** An image of more than 1500 pixels on a side is traced as any other, only more
|
||
slowly, and the trace says so: `imageTrace.make` returns the note in `warnings` and the status bar
|
||
shows it (the [results optimization](https://helpx.adobe.com/illustrator/using/image-trace-results-optimization.html)
|
||
page describes the same warning for images over 1500 px). An image of more than 64 megapixels (up to
|
||
192) is traced from a copy scaled down to 64 megapixels, and the trace says that too. A trace that would
|
||
make more than 8,000,000 anchor points (2,000,000 on the web) is refused to protect memory, with advice:
|
||
raise Noise, lower Paths or Colors, or pick a lower-fidelity preset. A trace keeps
|
||
about 90 bytes an anchor; a 4000 × 3000 photo at High Fidelity Photo makes about 1.9 million.
|
||
These controls use VectorCraft's existing tracing algorithm. Parameter effects follow its
|
||
implementation; they do not claim pixel-identical results with another application.
|
||
The terminology and general control behavior are described in the
|
||
[public Image Trace panel documentation](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/image-trace-panel-options.html).
|
||
|
||
Regression coverage: `crates/ui-egui/src/panels/image_trace.rs` tests opening the panel,
|
||
a quick trace leaving it as it was, repeated opening, floating ownership, slider commits, visible threshold
|
||
changes, undo, and the Properties entry point. Tracer tests live in `crates/trace/src/tests.rs`.
|