Skip to content

Image Trace: a gray photo with little noise counts as continuous tone - #7633

Open
dotCooCoo wants to merge 2 commits into
storytold:mainfrom
dotCooCoo:fix/trace-clean-gray-photo-tone
Open

dotCooCoo wants to merge 2 commits into
storytold:mainfrom
dotCooCoo:fix/trace-clean-gray-photo-tone

Conversation

@dotCooCoo

@dotCooCoo dotCooCoo commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Color and Grayscale smooth a picture before tracing it when quantize::continuous_tone (crates/trace/src/quantize/cut_edge.rs) classes it as continuous tone. A neutral or one-curve picture is exempt when sixteen colors leave at most a fifth of the error of eight colors. The exemption is for flat art of up to sixteen clean levels, where sixteen colors leave no error. A gray photo with little noise also falls under that cutoff, so it was classed as flat art and traced without smoothing, while its color original and the same photo with more noise were smoothed.

  • The cutoff is now a tenth instead of a fifth (VectorCraft's own values), in both places continuous_tone applies it. The doc comment states the new value.
  • docs/target-app-parity.md has one line for it. Its three neighboring Image Trace lines (gray photos, tinted photos, flat art of 10 to 16 levels) now give the cutoff as a tenth.

Measured on main with the synthetic photo the trace tests use (photo_scene), as the ratio of the sixteen-color error to the eight-color error:

Picture Ratio main This branch
Gray photo, noise 0, 1, 2 0.190, 0.192, 0.195 flat art continuous tone
Gray photo, noise 3 to 16 0.211 to 0.349 continuous tone continuous tone
Sepia, single-hue and duotone photos, noise 0 to 16 0.273 to 0.544 continuous tone continuous tone
Clean gray bands of 10, 12, 14 and 16 levels 0.000 flat art flat art

Every existing flat-art test that reaches the exemption measures 0.000, and no existing test changed.

This changes existing behavior: a neutral or one-curve picture whose ratio is between a tenth and a fifth now counts as continuous tone and is smoothed before tracing.

How it was tested

New test in crates/trace/src/tests.rs, failing without the change:

  • a_clean_gray_photo_is_continuous_tone_as_its_color_original_is: the synthetic photo with 0, 1, 2 and 3 levels of noise is continuous tone in color and in gray. On main it fails at "gray, noise 0".

Focused checks on 3de44da. The branch is two commits on main at 676f052, which was the latest main when this was opened. The second commit, 04df80f, changes only docs/target-app-parity.md.

  • cargo test -p vectorcraft-trace --lib: 340 passed, 1 ignored.
  • cargo clippy -p vectorcraft-trace --all-targets -- -D warnings: passed.
  • cargo check --workspace --tests: passed.
  • cargo fmt --all -- --check: passed.
  • cargo xtask ci runs in this pull request's CI.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md.

The continuous-tone check exempts a neutral or single-curve picture when
sixteen colors leave at most a fifth of the error of eight. The
exemption is for flat art of up to sixteen clean levels, where sixteen
colors leave no error. A gray photo with 0 to 2 levels of noise measures
0.19, under the cutoff, so it was classed as flat art and traced without
smoothing, while its color original and the same photo with more noise
were smoothed.

The cutoff is now a tenth (VectorCraft's own value). Clean gray, sepia,
single-hue and duotone art of up to sixteen levels stays flat art.

Docs: docs/target-app-parity.md.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 676f052 and 04df80f.

Files selected for processing: 3

  • crates/trace/src/quantize/cut_edge.rs
  • crates/trace/src/tests.rs
  • docs/target-app-parity.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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