A modern, modular pixel sorting application with a clean web interface built using Gradio. This is a complete refactor of the original pixel sorting concept, providing an intuitive way to create stunning glitch art effects.
Pixel sorting is a digital art technique that creates glitch-like effects by sorting pixels in an image based on various criteria such as brightness, color, or intensity. The results can range from subtle artistic enhancements to dramatic abstract transformations.
Have a look at this post or /r/pixelsorting for inspiration.
All credit goes to the original repo for the foundational algorithms. This version provides a modern, user-friendly interface and modular architecture.
- Python 3.8+
- uv for package management
# Clone the repository
git clone https://github.com/wolfembers/Pixelsorting.git
cd Pixelsorting
# Install dependencies using uv
uv pip install -r requirements.txt
# Alternative: Install the package directly
uv pip install -e .
For development with all testing dependencies:
uv pip install -r requirements.txt
uv pip install pytest mypy black
Launch the Gradio web interface for the easiest experience:
python -m pixelsort.main
Or directly:
python pixelsort/main.py
This will start a local web server (usually at http://127.0.0.1:7860
) where you can:
- Upload images or provide image URLs
- Adjust sorting and interval parameters in real-time
- Preview results instantly
- Download processed images
- Experiment with different presets
- Image Input: Upload local files or provide image URLs
- Real-time Preview: See results as you adjust parameters
- Parameter Controls:
- Interval Function: How to divide the image for sorting (
random
,threshold
,edges
,waves
,none
) - Sorting Function: How to order pixels (
lightness
,intensity
,hue
,saturation
,red
,green
,blue
) - Thresholds: Control sorting boundaries (0.0 - 1.0)
- Randomness: Percentage of intervals to leave unsorted (0-100%)
- Angle: Rotation angle for sorting direction (0-360°)
- Characteristic Length: Controls interval sizes for certain functions
- Interval Function: How to divide the image for sorting (
- Preset System: Quick access to popular configurations
- Download: Save results in PNG format
Function | Description |
---|---|
random |
Randomly generate intervals with configurable lengths |
threshold |
Sort only pixels within lightness thresholds |
edges |
Use edge detection to define sorting boundaries |
waves |
Create wave-like intervals of uniform width |
none |
Sort entire rows without breaks |
Function | Description |
---|---|
lightness |
Sort by HSV lightness value |
intensity |
Sort by sum of RGB values |
hue |
Sort by HSV hue component |
saturation |
Sort by HSV saturation |
red |
Sort by red channel value |
green |
Sort by green channel value |
blue |
Sort by blue channel value |
Parameter | Range | Description |
---|---|---|
Bottom Threshold | 0.0 - 1.0 | Lower boundary for threshold-based sorting |
Upper Threshold | 0.0 - 1.0 | Upper boundary for threshold-based sorting |
Randomness | 0 - 100% | Percentage of intervals to skip sorting |
Angle | 0 - 360° | Rotation angle for sorting direction |
Characteristic Length | 1+ | Average interval size for random intervals |
All examples created using the web interface with different preset configurations.
- Interval Function:
threshold
- Sorting Function:
lightness
- Result: Creates the classic Kim Asendorf-style pixel sorting effect
- Interval Function:
waves
- Sorting Function:
hue
- Result: Flowing, wave-like color transitions
- Interval Function:
random
- Sorting Function:
intensity
- Randomness: 50%
- Result: Balanced chaos with preserved image areas
- Classic Effect: Use
threshold
interval function withlightness
sorting for the original pixel sorting look - Preserve Details: Increase randomness to 30-70% to maintain recognizable image features
- Color Focus: Use hue or saturation sorting with edge-based intervals for artistic color effects
- Experiment: The web interface makes it easy to try different combinations in real-time
pixelsort/
├── core/ # Main processing engine
├── effects/ # Sorting and interval functions
├── ui/ # Gradio web interface
├── utils/ # Utilities and configuration
├── config/ # Configuration and presets
└── main.py # Application entry point
# Run all tests
python -m pytest tests/
# Run with coverage
python -m pytest tests/ --cov=pixelsort
# Format code
black pixelsort/ tests/
# Type checking
mypy pixelsort/
The application uses modern Python packages:
- PIL (Pillow): Image processing
- Gradio: Web interface
- NumPy: Numerical operations
- tqdm: Progress bars
- requests: HTTP requests for remote images
See requirements.txt
for complete dependency list with versions.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project builds upon the original pixel sorting work and is shared under the same spirit of open collaboration. See LICENSE for details.
- Original pixel sorting algorithm by Kim Asendorf
- Python implementation inspiration from satyarth
- Modern refactor and web interface by the community