Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edges of image are upscaled incorrectly with Point mode #30

Open
xmakro opened this issue Feb 9, 2021 · 1 comment
Open

Edges of image are upscaled incorrectly with Point mode #30

xmakro opened this issue Feb 9, 2021 · 1 comment

Comments

@xmakro
Copy link

xmakro commented Feb 9, 2021

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.

@xmakro xmakro changed the title First and last row of image are upscaled incorrectly with Point mode Edges of image are upscaled incorrectly with Point mode Feb 9, 2021
@swfsql
Copy link

swfsql commented Mar 21, 2023

I observed that on a 3x3 image, the center is also scaled incorrectly. But the distortion increases at the edge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants