What is Pixel Sorting?
Pixel sorting is a digital art technique that rearranges pixels in an image or video frame based on a sorting criterion — typically brightness, hue, or saturation. The result is a striking glitch-art effect where portions of the image appear to melt, streak, or dissolve into ordered color gradients while other regions remain intact. It sits at the intersection of generative art and controlled chaos.
How Pixel Sorting Works
- Row/Column Selection — The algorithm processes the image row by row (horizontal sorting) or column by column (vertical sorting)
- Threshold Masking — Pixels within a brightness or hue range are selected for sorting; pixels outside the range remain untouched
- Sorting — Selected pixel spans are sorted by their brightness, hue, saturation, or raw channel values
- Recombination — Sorted spans are written back to their original positions, creating the characteristic streaking effect
Controlling the Effect
The visual character of pixel sorting depends on several parameters: sort direction (horizontal, vertical, or both), sort key (brightness, hue, saturation, or individual channels), threshold range (which pixels get sorted), and span length (maximum contiguous run of sorted pixels). Lower thresholds sort shadows, higher thresholds sort highlights, and the threshold range determines how much of the image is affected.
Pixel Sorting in Video
Applying pixel sorting to video introduces temporal dimension. Frame-by-frame sorting can create a waterfall or rain-like effect as sorted regions shift with the content. For temporal consistency, the threshold parameters should remain stable across frames, with changes driven by intentional animation rather than frame-to-frame noise.
Tools and Implementation
Pixel sorting can be implemented in any language with image manipulation capabilities. Python with PIL/Pillow is common for static images. For real-time video, GLSL shaders can approximate the effect using GPU-accelerated sorting within small pixel neighborhoods, though true per-row sorting requires compute shaders or CPU-side processing.
Pixel Sorting in BeatSync PRO
BeatSync PRO uses pixel sorting as a beat-reactive effect where the sort intensity and threshold range pulse with the music. On strong beats, the sorting threshold expands to affect more of the frame, creating dramatic streaking effects that decay between beats. Combined with chromatic aberration and RGB glitch shaders, it produces the characteristic electronic music video aesthetic.
Try BeatSync PRO