Use correct bands for two band histograms #9054
Open
+12
−5
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.
Resolves #9050
For an
image32
image without a mask, histogram values are generated withPillow/src/libImaging/Histo.c
Lines 136 to 139 in 37cd041
However, this doesn't consider that some images (PA, LA and La) only have two bands
Pillow/src/libImaging/Storage.c
Lines 78 to 80 in 37cd041
Pillow/src/_imaging.c
Lines 1360 to 1361 in 37cd041
meaning that two band histograms only have 512 values, rather than 1024. So this PR skips the middle two bands when assigning values.