Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Sort pixels of an image to generate a pixel sorting glitch effect
ResourceFunction["PixelSort"][img] applies a pixel sorting effect to img. | |
ResourceFunction["PixelSort"][img,assoc] applies a pixel sorting effect using the parameters specified in the association assoc. |
| "Direction" | "Row" | direction in which the sorting is applied ("Row" or "Column") |
| "Property" | "Luminance" | computed pixel property to sort (mode) |
| "Level" | 0.2 | filter level (real 0 through 1) |
| "LevelTest" | "Min" | whether the specified filter level is a maximum or a minimum |
| "Reversed" | False | True to sort the pixels into reverse canonical order |
| "OriginalImage" | True | False to return the image computed using the specified property (e.g. "Luminance") with its pixels sorted |
| "Luminance" | computes the pixels' RGB luminance by using the formula {r*0.2126,g*0.7152,b*0.0722} |
| "Brightness" | computes the pixels' RGB brightness by taking the mean of the values of the pixels |
| "Min" | use the specified level as a minimum when filtering pixels |
| "Max" | use the specified level as a maximum when filtering pixels |
Get a sample image:
| In[1]:= |
| Out[1]= | ![]() |
Sort the image pixels using the default values:
| In[2]:= |
| Out[2]= | ![]() |
Sort the image pixels using custom values:
| In[3]:= |
| Out[3]= | ![]() |
Get some sample images:
| In[4]:= |
| Out[4]= | ![]() |
| In[5]:= |
| Out[5]= | ![]() |
| In[6]:= |
| Out[6]= | ![]() |
Sort rows of pixels of an image:
| In[7]:= |
| Out[7]= | ![]() |
Sort columns of pixels of an image:
| In[8]:= |
| Out[8]= | ![]() |
Sort the pixels of an image based on their luminance:
| In[9]:= |
| Out[9]= | ![]() |
Sort the pixels based on their brightness:
| In[10]:= |
| Out[10]= | ![]() |
Use a custom filter level:
| In[11]:= |
| Out[11]= | ![]() |
Sort all pixels with a minimum luminance value of 0.7:
| In[12]:= |
| Out[12]= | ![]() |
Sort all pixels with a maximum brightness value of 0.7:
| In[13]:= |
| Out[13]= | ![]() |
Sort the pixels into reverse order:
| In[14]:= |
| Out[14]= | ![]() |
Apply the filter on the image generated by computing the default luminance property:
| In[15]:= |
| Out[15]= | ![]() |
Apply the filter on the image generated by computing the brightness of its pixels:
| In[16]:= |
| Out[16]= | ![]() |
There are subtle differences between using the "Luminance" and "Brightness" properties:
| In[17]:= |
| In[18]:= | ![]() |
| Out[18]= | ![]() |
An invalid property will return an error:
| In[19]:= |
| In[20]:= |
| Out[20]= |
An invalid level test will return an error:
| In[21]:= |
| Out[21]= |
Get a test image:
| In[22]:= |
| Out[22]= | ![]() |
Create a pixel sorting animation:
| In[23]:= | ![]() |
| Out[23]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License