What did you do?
I down-sample an image with BOX filter.
Here is the image:
table-51.png (width="2755" height="1837")
What did you expect to happen?
All pixels are counted while down-sampling.
The result should look like this (688x459, 459x306):
box-js-v3-table-51.png-688x459-49c214b-pil-like.png
---
box-js-v3-table-51.png-459x306-20d1f1f-pil-like.png
What actually happened?
Some edge-case pixels were skipped.
---
Downscaled 4 times to 688x459:
box-pil-table-51.png-688x459-49c7ade.png
missed a central vertical line.
---
Downscaled 6 times to 459x306:
box-pil-table-51.png-459x306-20d5e62.png
missed a central horizontal line.
What are your OS, Python and Pillow versions?
- OS: Win 10
- Python: 3.12
- Pillow: 12.3.0
file_path = "./table-51.png"
scale = 4 # scale(-down)
image = Image.open(file_path)
image_gray = image.convert("L")
wh = (int(image.width / scale), int(image.height / scale))
image = image_gray.resize(wh, Image.Resampling.BOX)
Search words: off-by-one error, range rounding.
What did you do?
I down-sample an image with BOX filter.
Here is the image:
table-51.png (width="2755" height="1837")
What did you expect to happen?
All pixels are counted while down-sampling.
The result should look like this (688x459, 459x306):
box-js-v3-table-51.png-688x459-49c214b-pil-like.png
---
box-js-v3-table-51.png-459x306-20d1f1f-pil-like.png
What actually happened?
Some edge-case pixels were skipped.
---
Downscaled
4times to 688x459:box-pil-table-51.png-688x459-49c7ade.png
missed a central vertical line.
---
Downscaled
6times to 459x306:box-pil-table-51.png-459x306-20d5e62.png
missed a central horizontal line.
What are your OS, Python and Pillow versions?
Search words: off-by-one error, range rounding.