Fix SAVI formula: (1+L) was in denominator instead of numerator (#1094)#1095
Merged
brendancol merged 2 commits intomasterfrom Mar 30, 2026
Merged
Fix SAVI formula: (1+L) was in denominator instead of numerator (#1094)#1095brendancol merged 2 commits intomasterfrom
brendancol merged 2 commits intomasterfrom
Conversation
SAVI: The (1+L) factor was in the denominator instead of the numerator. The standard formula (Huete 1988) is ((NIR-Red)/(NIR+Red+L))*(1+L). The code computed (NIR-Red)/((NIR+Red+L)*(1+L)), making all results too small by (1+L)^2 = 2.25 with default L=0.5. EBBI GPU: Changed nb.int64(10) to 10.0 to match CPU path's type behavior.
SAVI had (1+L) in the denominator instead of the numerator. The Huete (1988) formula is ((NIR-Red)/(NIR+Red+L))*(1+L). The code computed (NIR-Red)/((NIR+Red+L)*(1+L)), making results too small by (1+L)^2. Updated the qgis_savi fixture and uint dtype fixture with correct reference values. Added test_savi_formula_1094 which checks all 4 backends against the formula directly. Also fixed EBBI GPU: nb.int64(10) -> 10.0 for type consistency.
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.
Summary
Fixes #1094. The SAVI formula (Huete 1988) had
(1+L)on the wrong side of the division.Correct:
((NIR - Red) / (NIR + Red + L)) * (1 + L)Was:
(NIR - Red) / ((NIR + Red + L) * (1 + L))With the default
L=0.5, every SAVI result was too small by a factor of(1+L)^2 = 2.25. Both_savi_cpuand_savi_gpuhad the same error.Also fixed a minor type inconsistency in the EBBI GPU kernel (
nb.int64(10)->10.0).Test plan
qgis_savifixture with correct reference values (4x larger with L=1)data_uint_dtype_savifixture with correct valuestest_savi_formula_1094: spot-checks the formula on all 4 backends with hand-computed values (NIR=0.8, Red=0.2, L=0.5 should give 0.6)test_multispectral.pysuite: 147 passed