Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inconsistencies using nearest neighbour for rotation #2913

Open
@sfcgeorge

Description

@sfcgeorge

Bug report

Describe the bug

When rotating images using Vips with nearest neighbour interpolation the result has inconsistencies.

This is especially obvious when rotating symmetrical pixel art.

To Reproduce
Steps to reproduce the behavior:

  1. Use Image of ladder at bottom
  2. Use Configuration interpolate: nearest and rotate 45 degrees
  3. See error

Or with the Ruby binding:

ladder = Vips::Image.new_from_file "./ladder.png"
rotated = ladder.rotate 45, interpolate: Vips::Interpolate.new(:nearest)
rotated.write_to_file "./rotated.png"

Expected behavior

Of course nearest neighbour produces artefacts, but I expect them to be symmetrical when the image being rotated is symmetrical.

Actual behavior

There are various discrepancies throughout.

Screenshots

magick_vs_vips_45

Environment

  • OS: macOS 12.4 (21F79)
  • vips-8.12.2-Tue Jan 25 09:34:32 UTC 2022

Additional context

ImageMagick produces symmetrical results when using nearest neighbour. However when using "integer" it produces results more like Vips:

magick_integer

Original ladder image:

ladder

Or if theres a different way to rotate 1 bit pixel art I'd love to know :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions