Skip to content

fix: anti-aliasing needs the darkest or brightest sibling to repeat in both images - #188

Open
jayhemnani9910 wants to merge 1 commit into
dmtrKovalenko:mainfrom
jayhemnani9910:fix-aa-siblings-in-both-images
Open

jayhemnani9910 wants to merge 1 commit into
dmtrKovalenko:mainfrom
jayhemnani9910:fix-aa-siblings-in-both-images

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 22, 2026 •

Copy link
Copy Markdown

With --antialiasing, detect returns

(min_has_siblings_base or max_has_siblings_base) and
    (min_has_siblings_comp or max_has_siblings_comp)

but the comment above it, and the detector it follows (pixelmatch does the same), say the pixel is anti-aliased when either the darkest or the brightest sibling has 3+ equal neighbours in both images:

(min_has_siblings_base and min_has_siblings_comp) or
    (max_has_siblings_base and max_has_siblings_comp)

The current expression also accepts the darkest sibling repeating only in the base image and the brightest only in the compared one, so real changes get dropped as anti-aliasing. In this 5x5 pair, pixel (4, 2) goes from black to red and odiff --aa reports 4 different pixels instead of 5 (pixelmatch: 5):

base        comp
K G R K G   K G W K G
W K G G G   G K G G G
W K R G K   W K R K R    <- (4, 2): K -> R
K G R W K   K G R W K
R W W W K   R W W W W

On images/www.cypress.io.png vs www.cypress.io-1.png with --aa, main counts 924818 different pixels, this branch 927138, pixelmatch 5.3.0 (includeAA: false) 927205. donkey and tiger change by 0 and 4 pixels.

The two images above are added under test/aa/, and the new test "antialiasing: a sibling needs equal neighbours in both images" fails without the change (expected 5, found 4). zig build test-integration: 46 of 47 passed, 1 skipped, as on main plus the new test; the existing anti-aliasing tests keep their counts. On 300 random PNG pairs at five thresholds, with and without --aa, odiff and pixelmatch agree on 599 of 600 counts both before and after; the remaining one is a pixel whose neighbour has the same brightness but a different color (pixelmatch counts equal brightness, odiff equal color).

Summary by CodeRabbit

  • Bug Fixes
    • Improved antialiasing detection so sibling support must match for the same brightness extreme in both images, preventing some real image changes from being overlooked.
  • Tests
    • Added a regression test confirming mismatched sibling-neighbor evidence is counted as a real change.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c21a87f-ffe4-43ac-b4e4-51c4fd611257
📥 Commits

Reviewing files that changed from the base of the PR and between 6dd1e96 and e6e428f.

⛔ Files ignored due to path filters: 2
  • test/aa/siblings-base.png is excluded by !**/*.png
  • test/aa/siblings-comp.png is excluded by !**/*.png
📒 Files selected for processing: 2
  • src/antialiasing.zig
  • src/test_core.zig

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

📝 Walkthrough

detect now requires matching-sibling support for the same brightness extreme in both images. A regression test checks the diff count when the images have mismatched sibling evidence.

Changes: Antialiasing check

Layer / File(s) Summary
Detection condition and regression test
src/antialiasing.zig, src/test_core.zig
detect now checks the same brightness extreme in both images. The regression test expects 5 differing pixels when sibling evidence differs.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: dmtrkovalenko

Merge Risk: ⚪ Minimal · up to e6e42

The change addresses the reported anti-aliasing misclassification, and the regression test distinguishes the old behavior. No issue remains that should delay merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and accurately summarizes the main anti-aliasing fix. It identifies the darkest or brightest sibling requirement and its repetition in both images.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

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