mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 08:12:33 +03:00
Use correct bands for 2 band histograms
This commit is contained in:
parent
44a553a0a2
commit
dc7d646db0
|
@ -10,9 +10,12 @@ def test_histogram() -> None:
|
|||
|
||||
assert histogram("1") == (256, 0, 10994)
|
||||
assert histogram("L") == (256, 0, 662)
|
||||
assert histogram("LA") == (512, 0, 16384)
|
||||
assert histogram("La") == (512, 0, 16384)
|
||||
assert histogram("I") == (256, 0, 662)
|
||||
assert histogram("F") == (256, 0, 662)
|
||||
assert histogram("P") == (256, 0, 1551)
|
||||
assert histogram("PA") == (512, 0, 16384)
|
||||
assert histogram("RGB") == (768, 4, 675)
|
||||
assert histogram("RGBA") == (1024, 0, 16384)
|
||||
assert histogram("CMYK") == (1024, 0, 16384)
|
||||
|
|
|
@ -132,11 +132,15 @@ ImagingGetHistogram(Imaging im, Imaging imMask, void *minmax) {
|
|||
ImagingSectionEnter(&cookie);
|
||||
for (y = 0; y < im->ysize; y++) {
|
||||
UINT8 *in = (UINT8 *)im->image[y];
|
||||
for (x = 0; x < im->xsize; x++) {
|
||||
h->histogram[(*in++)]++;
|
||||
h->histogram[(*in++) + 256]++;
|
||||
h->histogram[(*in++) + 512]++;
|
||||
h->histogram[(*in++) + 768]++;
|
||||
for (x = 0; x < im->xsize; x++, in += 4) {
|
||||
h->histogram[*in]++;
|
||||
if (im->bands == 2) {
|
||||
h->histogram[*(in + 3) + 256]++;
|
||||
} else {
|
||||
h->histogram[*(in + 1) + 256]++;
|
||||
h->histogram[*(in + 2) + 512]++;
|
||||
h->histogram[*(in + 3) + 768]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImagingSectionLeave(&cookie);
|
||||
|
|
Loading…
Reference in New Issue
Block a user