Skip to main content
Participant
July 9, 2021
Question

Pixel art edges become jagged when rotated with nearest-neighbor interpolation

  • July 9, 2021
  • 3 replies
  • 2968 views

While trying to rotate an image with Nearest-Neighbor interpolation at a 45 degree angle, the edges become overly jagged and not in a straight line.

 

When rotating the image, the preview shows the way I want the image to be, however, when I apply the changes, the edges become overly jagged and distorted. 

 

Is there any fix to this?

 

Examples are shown below.

 

Before rotation

Preview (Ideal)

After applying

 

This topic has been closed for replies.

3 replies

kayr23628964
Known Participant
May 26, 2023

Can someone from adobe explain why this is happening? Gimp is able to do this transforation as expected.

Trevor.Dennis
Community Expert
Community Expert
July 9, 2021

I'm assuming that you have a reason to use Nearest Neighbour. Maybe you are producing pixel art for your project?

So my idea was to rotate the rectangle with Bicubic Automatic which will use anti aliasing to soften the edge, and then use levels or Threshold to remove the aa and see if that produces a less ugly edge.  However, things got a bit weired on me.

 

AFAICT your rectangle is 60 pixels long and full white.  Rotating the white rectangle -45° looks like this.  I have turned off the pixel grid, and the zoom ration is 1200%.  There is obvious aa so I should be able to harden up the edge.

 

The same thing against a black background shows the aa as looking darker, so I'm guessing those pixels are still at, or close to, 255,255,255 but with reduced opacity.  This gave me a problem.

 

Threshold set all the way up to 255 had no effect on the white rectangle, because the aa pixels must already have been at 255,255,255 but with the afore mentioned reduced opacity.  Bummer!

 

Giving a Levels adjustment layer the entire canvas to work on did kill the aa

But if you clipped it to the white rectangle, you are back where you started from

 

So no help to you, but I enjoyed tracking down what was initially a bit of a mystery to me. I wonder if we can be of more help if you tell us why you needed to Nearest Neighbour?  Is it some sort of pixel art?  We do still get questions about pixel art so it must still be a thing.

Participant
July 9, 2021

Interesting, yeah its for a largescale pixel art project. The pixel art I am creating must fit into a specific color pallete for it to work in the way I want it to. This is one of the reasons I don't want to use other antialiasing methods (along with thinking nearest neighbor looks better while working with pixel art in general)

gener7
Community Expert
Community Expert
July 9, 2021

Go into Preferences > General and try Bicubic Automatic:

Participant
July 9, 2021

I want sharp edges, similar to nearest neighbor interpolation, just without the overly jagged edges shown. Bicubic Automatic tends to not have sharp edges and have miscolored pixels, as shown below.