resize
resize copied to clipboard
Edges of image are upscaled incorrectly with Point mode
A 2x2 grayscale image:
[1, 0,
0, 2]
Is incorrectly upscaled to the following 4x4 image:
[1, 0, 0, 0,
0, 2, 2, 2,
0, 2, 2, 2,
0, 2, 2, 2]
This can be reproduced with:
fn main() {
let mut resizer = resize::new(2, 2, 4, 4, resize::Pixel::Gray8, resize::Type::Point).unwrap();
let src = vec![1u8, 0u8, 0u8, 2u8];
let mut dst = vec![0u8; 4 * 4];
resizer.resize(&src, &mut dst).unwrap();
println!("{:?}", dst);
// prints: [1, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2]
}
I only observe this behavior for the edges of the image, the center part of the image is upscaled correctly.
I observed that on a 3x3 image, the center is also scaled incorrectly. But the distortion increases at the edge.