
In mode 1, or brightness mode, the script will begin sorting when it finds a pixel which is bright in the column or row, and will stop sorting when it finds a dark pixel. You can adjust this threshold by changing the blackValue variable which is by default set to -16000000. The script identifies black pixels by comparing the pixel’s color value to a threshold, if it’s lower than the black threshold the pixel is deemed to not be black, if it’s higher it’s deemed to be black. In mode 0, or black mode, the script will begin sorting when it finds a pixel which is not black in the column or row, and will stop sorting when it finds a black pixel.

Different modes will work better depending on the image itself. The mode can be changed by adjusting the mode variable, by default it is set to 1, but can be changed to either 0 or 2 as well. In order to decide which pixel to start sorting on and which to stop sorting on this script can operate in three different modes. Instead for each column and row it looks for a pixel to start sorting on and then it looks for a pixel to stop sorting on - this makes the algorithm somewhat intelligent resulting in identifiable elements of the image being left untouched. This particular script loops through both the columns and the rows of the image, but it doesn’t pixel sort the entire column or row, if it did, the result would look more like a blank gradient than anything interesting. Once you’ve updated the script with the name of your file simply press the Run button at the top left of the Processing window (it looks like a play button) and in a few seconds you should see a window with the results, a new image should also be saved to the sketch directory.

#PIXEL SORTER 2 UPDATE#
Place your PNG in the same directory as the ASDFPixelSort.pde (which Processing may have placed in a new sub directory) and update the script with the filename. In the script, which are referred to as sketches in Processing, you’ll need to change the following lines to point the script at the image you want to pixel sort: // image path is relative to sketch directoryįor this tutorial we’ll use a PNG, though Processing supports GIF, JPG and TGA as well.
#PIXEL SORTER 2 ZIP#
Once you’ve downloaded the ZIP you can extract the sorting script and open it in Processing by selecting:Īnd navigating to the ASDFPixelSort.pde script file. If you’re familiar with GitHub you can do this a number of other ways. Next select a pixel sorting script to start from, my own pixel sorting scripts are not written for Processing so for the purposes of this tutorial we’ll use a popular script made available by glitch artist Kim Asendorf, the ASDF Pixel Sort.ĭownload the ASDFPixelSort.pde from Kim’s GitHub repository by clicking the green button labelled Clone or download and select Download ZIP.
#PIXEL SORTER 2 INSTALL#
To get started download and install the latest version of Processing, version 3.1.1 at the time of writing this. One popular programming language for pixel sorting is Processing.
