Skip to content

Fix filter_rgb32_range() with several filters, and make the ImageFilter tests real tests - #1682

Merged
Mysticial merged 3 commits into
mainfrom
test-image-filters
Oct 23, 2026
Merged

Mysticial merged 3 commits into
mainfrom
test-image-filters

Conversation

@Gin890

@Gin890 Gin890 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fix a bug in filter_rgb32_range() with several filters, and make the ImageFilter kernel tests real tests.

Split from #1669, as Mysticial asked. The other part is #1681 (PackedBinaryMatrix::submatrix()).

The bug: the overload that runs several range filters in one call passed a field that is not set yet as the replace flag, so the result was undefined. It now passes each filter's own flag. The PokemonLA MountDetector uses this overload. This broke in 5bb2f45.

The tests now check each range filter and filter_by_mask() implementation that the CPU supports against a scalar reference, on real images. A new test checks filter_rgb32_range() and to_blackwhite_rgb32_range() with several filters in one call. Before, the tests were debug code. They were not registered, so CI did not run them. They tested only the implementation that the dispatch picks, and had 3-second timing loops.

Other changes:

The images are from the CommandLineTests repo. No width or height is a multiple of 8, so the tests also check the leftover pixels after the SIMD loops and the edge tiles of the mask. #1554 also changes this test file, so it will need a small merge fix.

0 test files added, 1 test file changed:

  • SerialPrograms/Source/Kernels/ImageFilters/Kernels_ImageFilter_Tests.cpp

Test results: added when the CI of this PR finishes.

🤖 Generated with Claude Code

Gin and others added 3 commits October 22, 2026 21:08
…mages

The old ImageFilter tests were debug code: they were not registered, ran
3-second timing loops, and only ran the implementation the CPU dispatch picks.
Now each range filter and filter_by_mask() implementation that the build has
and the CPU supports gets a test on 4 CommandLineTests images, checked against
a scalar reference.
The two Euclidean tests are removed. Kernels::RGB32Euclidean covers them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The overload that runs several range filters in one call passed the filter's
pixels_in_range, which is not set yet, as replace_color_within_range. It
should pass the filter's own flag, invert. This broke in 5bb2f45. The
PokemonLA MountDetector uses this overload.
Also set pixels_in_range to 0 in both multi-filter structs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a test that runs filter_rgb32_range() and to_blackwhite_rgb32_range()
with 8 filters in one call, and checks each output against the scalar
reference. It fails without the fix in the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mysticial
Mysticial merged commit b97ca16 into main Oct 23, 2026
7 checks passed
@Mysticial
Mysticial deleted the test-image-filters branch October 23, 2026 06:12
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.

2 participants