Pixel sorting on an angle

Is there anyone who can help me understand how to change the angle of sorted pixels? Instead of sorting in horizontal lines, how would I implement something like this 45 degree angle?

1 Like

Usually, pixel sorting compares (and possibly swaps) pixels[i] with either pixels[i+width] (for vertical only shifts) or pixels[i+1] (for row sorting).

You might consider comparing pixels[i] to pixels[i+width+1], which would sort them diagonally.

Draw a diagram of the i’th pixel and its surrounding 8 pixels. Work out what the indexes are for those other 8 pixels. That’ll help get you started.

1 Like

Hello,

There are resources here:
https://processing.org/

This tutorial may be of interest:
https://processing.org/tutorials/pixels

And examples that come with the Processing IDE:

Click to open

Search through the topics to glean some insight.

I did this in one of the topics here in the forum:

8001d4e5fb6f6d0a8b4462af184689d8b1a01b14_2_357x375

:)

1 Like

Hi
i think rotating image to change the sort direction only works when the image is quadrate and angle value is particular such as 45 degree and so on
but how can i change the sort direction to some ordinary angle value such as 30/45 degree in any ordinary image?