A NaN or infinite sample (32-bit documents can hold them) reached the
region means unchanged, so a region's colour, the edge offsets built from
it and the fill could turn non-finite or leave pixels uncovered. trace now
replaces non-finite channels with 0 before banding (copying the image only
when one is present).
Test: NaN and ±inf samples give finite region colours, outlines and pixels
with full coverage; it fails without the fix. (CodeRabbit review on #10328.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reference application's Liquify has Twirl Clockwise only; holding
Alt (Option on macOS) while using it twirls counterclockwise. PhotoCraft
had an extra Twirl Counterclockwise tool on the strip, and #9598 had just
given it a mirrored icon.
Twirl Counterclockwise leaves the tool strip (LiquifyTool::ALL, 11 to
10 tools) and the rotate-ccw icon #9598 added goes with it (asset,
icon_data entry, ATTRIBUTION count back to 113). Alt already reversed
Twirl Clockwise at stroke-down; that stays. The TwirlCcw variant stays as
a stroke's direction: Alt-strokes record `twirlCcw`, and filter.liquify
strokes and older saved strokes naming it still replay as Twirl
Clockwise reversed (the command doc says so). Selecting it as the tool
(control channel `tool: "twirlCcw"`, or a preference saved by an older
version) is refused with an error that says to choose twirlCw and hold
Alt; the rest of the settings still apply and the dialog opens.
Tests: the_tool_strip_has_no_twirl_counterclockwise (no such tool, label
or missing icon on the strip, C is Twirl Clockwise, `twirlCcw` as the
tool is an Err and leaves the tool, an old saved preference naming it
opens); alt_with_twirl_clockwise_twirls_counterclockwise (the field
displacement a dab leaves right of the centre points up without Alt and
down, mirrored, with Alt). twirl_counterclockwise_has_its_own_mirrored_icon
and the twirlCcw row of alt_reverses_twirl_and_swaps_pucker_and_bloat
are removed. The i18n labels for Twirl Counterclockwise stay (the
variant's label).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#8191, #8192, #8193 and #7903 made Cutout trace the image with its own
pipeline: an Oklab bilateral smooth, a median-cut/k-means palette,
lightness stretched towards black and white, colour that drifts inside a
shape, and Catmull-Rom curves. The result looks good but not like the
reference application. Measured there on a portrait, grey ramps, a hue
sweep and squares of known size:
- Tone bands are the plain mean of R, G and B in Number of Levels equal
steps (4 levels on a 0-255 ramp: steps at 64, 128 and 192). Colours of
different hue but the same mean share a band, so a saturated blue
headscarf and the grey around it come out as one averaged colour.
- Each connected region is filled flat with the mean colour of its own
pixels (ramp bands read 96, 160, 224 = their means). No stretch, no
drift: about 1,100 distinct colours on the portrait, edges included,
against 13,000 before.
- Edge Simplicity removes regions by size alone, the same on a 256 px
and a 600 px canvas: 6 px squares survive at 0-2 and 4 px go; 12 px
survive at 4; 48 px at 6; 96 px at 7; none at 8. Merged pixels count
towards the neighbour's mean.
- Outlines are straight-sided polygons that coarsen with Simplicity.
- Edge Fidelity nudges outlines only: 1.9% of the portrait's pixels
change from 1 to 2, 1.2% from 2 to 3 (PhotoCraft now 2.7% / 1.1%).
So the palette stage becomes the channel-mean band, regions keep their
flat mean colour, outlines stay straight (the Douglas-Peucker vertices,
no curves), and the minimum area follows the measured table. The
smoothing, palette, paper-colour and curve code that no longer runs is
removed, and quantize's median_cut/kmeans are private again.
Against the reference renders (mean absolute difference per channel,
0-255): the portrait at the defaults 4/4/2 went from 27.7 to 3.1, at
8/4/2 from 23.3 to 3.4; grey ramps from 17-47 to 1.7-3.4; the hue sweep
from 39.7 to 2.2; the noisy two-colour image from 57.5 to 1.2. Over 36
cases the summed error went from 676 to 229. The rest is mostly at Edge
Simplicity 7-10, where the reference keeps some mid-sized strips that
are merged here.
Tests: the ramp's band steps and tones; which square sizes survive at
Simplicity 0, 2, 4 and 10; every slider changes a radial gradient; the
region merge picks the neighbour with the longest shared border and
uses the measured area; Edge Fidelity changes 0.2-6% of the pixels;
islands keep their tone at low fidelity; tiling and seam tests as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#5176 made ±100% move the edge by max(radius, feather, 2σ smooth), at
least 1 px. Measured in the reference application (a 100 px square,
Radius/Feather/Smooth each varied, Shift Edge -100/-50/+100):
- A hard selection does not move at all, at any Shift Edge.
- On a feathered edge the result is a fixed per-pixel curve, the same at
2, 5 and 10 px feather: the pixel's odds a/(1-a) are multiplied by
49^(shift/100). At -100% a 50% pixel becomes 2%, at -50% 1/8, at
+100% 98%. The fit holds within ±0.05 in log-odds on every sample.
So Shift Edge is now that curve, applied last as before. It needs no
neighbours, so the morphology callback and the halo/spread it added are
gone, with the ignored benchmark that timed it (matting::morph itself
stays for Select › Modify and the mask view).
Tests: a hard edge is unchanged at ±50/±100%; seven measured
before→after coverage pairs; a feathered edge is pulled in; the engine
refine tests now check the hard edge stays and a feathered one moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's noop_step now takes the step's params (an Arrange that cannot move the layer is a no-op too); it is public for the CLI's run and batch, which pass them.
* perf(algo): row-parallel local_sharpen with fast-path protect_detail (#5426)
Refs #5426. Follow-up to #5499.
Cause:
While #5499 parallelized local_blur and the per-dab mix in DabTool::Focus,
local_sharpen in crates/algo/src/retouch.rs remained single-threaded.
In addition, protect_detail redundantly evaluated coordinate clamping
and strided memory lookups across 8 neighbors inside the per-channel
inner loop for every pixel in the dab. On large brush sizes (e.g. 1000–2500 px),
strokes took seconds and stalled the application.
Change:
- Process local_sharpen window rows in parallel with Rayon across threads,
with wasm32 serial fallback matching local_blur.
- Hoist protect_detail 3x3 neighborhood offset calculations outside the
channel loop.
- Fast-path interior pixels (x > 0 && x + 1 < w && y > 0 && y + 1 < h)
with direct stride offsets, skipping boundary clamping entirely for >99.9%
of pixels in large brush dabs.
- Add retouch_sharpen_exact integration test verifying bit-for-bit parity
against the frozen scalar implementation across layouts, edges, and channels.
* bench(engine): add bench_sharpen_tool example
* perf(algo): reuse Reduce Noise guide statistics
* fix(algo): use fixed-size chunks for guide statistics
* Reduce Noise: test that the caller routes the cleaned luma guide and both chroma planes
Review follow-up: compares reduce_noise's output (Lab, so planes pass through) with the
independent guided filters run in order.
* test(algo): assert bit-identical output in Reduce Noise routing test
Port behavior and regression coverage into current modules; preserve current upstream behavior.
Ported mappings and smart Save into current modules, preserving bounded authorized playback; migrated legacy PAT by committing validated per-pattern assets before atomic authoritative index; preserved same-ID replacements and builtin edits; added temporary-store interruption, corruption, duplicate ID/name and restart regression coverage. Current all-target compilation passed before final ownership guard refinement; focused tests pending.
Main now carries #9031 (Halftone) and #8923; this branch keeps only what it adds on top: the guard for a setting beside a Gallery stack's effect list, its test, and the PSD open warning for patterns that paint nothing.
GrabCut's colour-model grids have few terminal links and short paths, where
BK beats the push/relabel solver the default dispatch picks for graphs of
4096+ nodes. Quick Selection keeps push/relabel.
24 MP synthetic, release, median of 3: Select Subject 480 -> 207 ms,
Object Selection 337 -> 140 ms, Quick Selection unchanged. IoU unchanged.
The mesh warp's least squares was solved by CGLS, which ran its whole iteration
budget on an ill-conditioned system. The static shape and anchor terms are now
assembled once per solve and factored with a banded Cholesky, and each round adds
the constraint lines as an exact low-rank update (conjugate gradients remain as the
fallback). Csr and BandChol move from puppet.rs to photo_util.rs so both share them.
Main reorganised the source tree (command modules under engine/src/cmd, tools and dialogs under ui-egui/src, large files split into modules, inline test modules moved to their own files). This branch's changes to the moved and split files are ported to their new locations.
The feather's ⌈3σ⌉ truncation radius was written out in the blur and again in two engine callers: the windowed marquee and lasso feather (#9794) and the canvas-edge padding of Select › Modify › Feather. selection::feather_reach returns it from the blur's own σ rules, and both callers use it, so a change to the blur's reach can't leave them behind. Output is unchanged; a test pins that the feather leaves everything past its reach at zero.
Resolves the move of crates/engine/src/selection_cmds.rs to cmd/selection_cmds.rs: the two hunks apply at the new path, and modify_window.rs with its tests moves under cmd/selection_cmds/.