Commit Graph
458 Commits
Author SHA1 Message Date
David MannandClaude Opus 5.5 4aa7984eb0 Cutout: non-finite samples count as 0 before tracing
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>
2026-10-30 16:56:58 +01:00
David MannandClaude Opus 5.5 d9cb0edd8d Liquify: no Twirl Counterclockwise tool, Alt with Twirl Clockwise does it
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>
2026-10-30 16:34:03 +01:00
David MannandClaude Opus 5.5 d91195ba29 Filter Gallery › Cutout: tone bands of the channel mean, flat region colours
#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>
2026-10-30 16:34:03 +01:00
David MannandClaude Opus 5.5 bf80e2d2fa Select and Mask: Shift Edge is a curve on coverage, so hard edges stay put
#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>
2026-10-30 14:58:18 +01:00
FredApps 722a9bd5cf Merge current main and remove app-local integration workflow additions 2026-10-30 12:22:42 +01:00
FredApps 0f120bbda1 Merge current main, reconcile streamed PNG profiles and workflow inputs 2026-10-30 06:52:05 +01:00
FredApps a4ab4873e8 Merge current main, retain full-sweep and new benchmark inputs 2026-10-30 03:05:00 +01:00
FredApps 47eaae523f Apply rustfmt layout to subpixel blur regression 2026-10-29 23:54:51 +01:00
FredApps c93c0bb36d Merge main into trimmed integration; reconcile blur, pattern and Liquify behavior 2026-10-29 23:47:53 +01:00
FredApps 29bf828ec2 Merge upstream main into reviewed performance integration
Preserve both UI parity status entries; retain all reviewed performance changes.
2026-10-29 23:35:19 +01:00
FredApps 4f6ebb1b6e test: partition long parity matrices without dropping cases 2026-10-29 23:23:32 +01:00
FredApps 63637c4d80 Merge current main into trimmed integration, preserving exclusions and interpolation behavior 2026-10-29 21:31:18 +01:00
Federico Olivares 796ef557cc Merge main into the integration batch
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.
2026-10-29 14:19:54 -03:00
Khawar Zamman Wani 539f5bd58f perf(algo): row-parallel local_sharpen with fast-path protect_detail (#5426) (#9651)
* 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
2026-10-29 12:11:22 -04:00
Khawar Zamman Wani 6c6cfc243a perf(stack): cache bounded entropy terms across pixels (#9622)
* perf(stack): cache bounded entropy terms across pixels

* test(stack): iterate entropy terms directly for Clippy

* ci: rerun checks
2026-10-29 12:10:12 -04:00
Khawar Zamman Wani 66ac154d68 perf(algo): select median stack samples without full sorting (#9628) 2026-10-29 11:36:34 -04:00
Khawar Zamman Wani 6b2ad6b620 Reduce Noise: reuse guide statistics with bit-identical output (#9639)
* 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
2026-10-29 11:35:24 -04:00
FredApps 53dbfe280c Integrate 16 reviewed performance and usability PRs
Includes #8472 #8488 #9461 #9793 #9809 #9813 #9814 #9822 #9826 #9847 #9850 #9852 #9921 #9924 #9961 #10080 at reviewed heads.

Preserves each PR head as a parent. Reconciles CI workflow inputs and benchmark jobs without dropping checks. Excludes #8536 #9825 #9969 #10129. Combined CI pending; no manual validation claimed.
2026-10-29 14:31:15 +01:00
Khawar Zamman Wani 706186384a test(segment): make the long-run cancellation test fail when periodic polling is removed 2026-10-29 16:44:22 +05:30
FredApps d98e419542 Merge approved PhotoCraft PR #5176: Play CopyCat, AJ and Line and Color action sets; keep patterns across restarts; Shift Edge scale
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.
2026-10-29 05:15:28 +01:00
Khawar Zamman Wani 6d449fc8cb test(segment): pin a BK-sized GrabCut mask and use a genuine min-cut tie
Address CodeRabbit on #9961: the 32x24 pinned mask stayed under the 4096-node
BK threshold, and the tie fixture had a unique minimum cut.
2026-10-29 09:30:05 +05:30
Khawar Zamman Wani 5177daef70 test(segment): pin BK cut labelling on ties and a stored GrabCut mask 2026-10-29 08:08:16 +05:30
FredApps 6ad071b77a Merge approved PhotoCraft PR #9651: perf(algo): row-parallel local_sharpen with fast-path protect_detail (#5426) 2026-10-29 03:30:04 +01:00
FredApps ce77d3def1 Merge approved PhotoCraft PR #8931: feat(algo): describe the Gaussian blur as data for other devices 2026-10-29 03:29:42 +01:00
FredApps 07ec24727a Merge approved PhotoCraft PR #7903: Filter Gallery › Cutout 4/4: trace the image into flat paper shapes 2026-10-29 03:29:36 +01:00
FredApps ef6467c751 Merge approved PhotoCraft PR #8193: Filter Gallery › Cutout 3/4: edges and curves stage 2026-10-29 03:29:35 +01:00
FredApps ec6f486b04 Merge approved PhotoCraft PR #8192: Filter Gallery › Cutout 2/4: regions stage 2026-10-29 03:29:35 +01:00
FredApps de85ba7b07 Merge approved PhotoCraft PR #8191: Filter Gallery › Cutout 1/4: colour and palette stage 2026-10-29 03:29:34 +01:00
Khawar Zamman Wani 830cb65d48 fix(segment): place cancellation tests after items 2026-10-28 19:53:59 +05:30
Federico Olivares 5a6270921c Merge main into the integration batch
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.
2026-10-28 11:17:59 -03:00
Khawar Zamman Wani 5a86877b68 fix(segment): honor cancellation on short BK cuts 2026-10-28 19:35:31 +05:30
Khawar Zamman Wani a79057f6e4 perf(segment): solve GrabCut and the band re-cut with Boykov-Kolmogorov
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.
2026-10-28 17:01:21 +05:30
Khawar Zamman Wani aae87d353a perf(algo): solve Adaptive Wide Angle's mesh with a factor-once direct solve
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.
2026-10-28 07:52:44 +05:30
Dylan M. Taylor 8bc939cf3b Refactor algo for strict Clippy checks 2026-10-27 23:47:06 +00:00
Finn NewickandClaude Opus 5.5 d42dd4c630 Merge origin/main into feat/operator-separable
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 22:51:51 +00:00
Federico Olivares e173a9be17 Merge main into the integration batch
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.
2026-10-27 10:44:16 -03:00
Khawar Zamman Wani 9722d16909 perf(selection): retain direct Replace path and tighten validation 2026-10-27 13:19:08 +05:30
Khawar Zamman Wani 34af1d8e66 fix(engine): convert Bitmap images in bands 2026-10-27 13:18:39 +05:30
Khawar Zamman Wani 8324e278a1 perf(selection): combine GRAY8 masks directly in tiles 2026-10-27 12:42:18 +05:30
aiongg 7ac7b8b106 refactor(selection): take the feather reach from the blur (#9802)
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.
2026-10-27 01:07:05 -04:00
aiongg a27436adcb Merge main into perf/selection-morphology
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/.
2026-10-27 04:27:45 +00:00
Khawar Zamman Wani 55b8df82fc perf(selection): window marquee and lasso feather masks (#9794)
* perf: window marquee and lasso feather masks to drawn bounds

* perf: benchmark small feathered tool selections on a 24 MP canvas
2026-10-27 00:12:47 -04:00
Khawar Zamman Wani d843f4c34b perf: invert selections using sparse shared tiles 2026-10-27 08:25:37 +05:30
aiongg 4d07ccded0 refactor(algo): split panorama.rs into panorama/ 2026-10-26 22:54:56 +00:00
aiongg ff2a29a364 refactor(algo): split inpaint.rs into inpaint/ 2026-10-26 22:54:56 +00:00
aiongg 2be8a2e5a8 refactor(algo): move tests_selection_mix.rs to tests/selection_mix.rs 2026-10-26 22:30:15 +00:00
aiongg dd784da5cc refactor(algo): move tests_mosaic.rs to tests/mosaic.rs 2026-10-26 22:30:15 +00:00
aiongg 1559d287d6 refactor(algo): move tests_ext.rs to tests/ext.rs 2026-10-26 22:30:15 +00:00
aiongg fe82c57039 refactor(algo): move tests_tilt_shift.rs to gallery/tilt_shift_tests.rs 2026-10-26 22:30:14 +00:00
aiongg 6275857616 refactor(algo): move tests_iris.rs to gallery/tests.rs 2026-10-26 22:30:14 +00:00