Repository navigation
Fix RASE dividing the target mean by window_size**2 twice - #3677
Open
harshil-sri wants to merge 2 commits into
Open
harshil-sri wants to merge 2 commits into
harshil-sri wants to merge 2 commits into
Conversation
_uniform_filter already returns the local mean, but _rase_update divided it by window_size**2 again, so RASE came out window_size**2 times too large (64x with the default window). The test reference copied the same line, so it could not catch this. Compare single images against sewar.rase directly and add a constant-offset check.
harshil-sri
requested review from
SkafteNicki,
ethanwharris,
justusperillieux and
tchaton
as code owners
November 28, 2026 04:04
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Compared relative_average_spectral_error with sewar.full_ref.rase on random 3x24x24 images. Here it matches sewar for window sizes 3 and 8 (7.731, 7.926); master gave 69.58 and 507.235, off by about window_size**2.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #3676
_rase_updatedivided the output of_uniform_filterbywindow_size**2, but_uniform_filteralready returns the local mean (its kernel is normalised in_uniform_weight_bias_conv2d). The mean radiance in the RASE formula was thereforewindow_size**2too small, andrelative_average_spectral_error/RelativeAverageSpectralErrorcame outwindow_size**2times too large.For a random 32x32 image the old value was 16x
sewar.rasewithwindow_size=4and 64x withwindow_size=8. After the change they agree to float precision.Changes:
/ (window_size**2)in_rase_update_reference_sewar_rasein the tests, which had copied it (that is why CI never caught this)test_rase_single_image_matches_sewar, which compares single images againstsewar.rasedirectly for window sizes 3, 4 and 8, for both the functional and the classtest_rase_constant_offsetwith the constant image case aboveTested with
pytest tests/unittests/image/test_rase.py tests/unittests/image/test_rmse_sw.py(24 passed) and the doctests of both rase modules. With the source change reverted, all 12 tests in test_rase.py fail. Ruff check and format pass on the changed files.This changes the values users get from RASE, so anyone comparing against old numbers will see them drop by
window_size**2. The ranking of models at a fixed window size does not change. #3568 and #3613 touch the same files but different lines, so either order of merging should be a trivial rebase.I used Claude Code to help find and fix this.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Yes.