This project implements an algorithm for stylizing images that clusters pixels by color, then maps each cluster to another color. Optionally, the image can be downsampled or have noise added prior to mapping colors, which produces a pixelated or grainy effect when reupscaled.
| Before | After |
|---|---|
![]() |
![]() |
Photograph taken by Daniel Mennerich (Flickr).
| Before |
|---|
![]() |
| After |
|---|
![]() |
Photograph taken by Macaolards (Wikipedia).
It is recommended to use a virtual environment to manage dependencies.
python -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txtUsing the GUI application allows tuning the pipeline parameters and previewing the effects in real-time.
python gui.py
The CLI application has the same features as the GUI application. Run using the following arguments:
python cli.py <filename> <palette> <pixelsize> <space> <noisesize>
| argument | description | default value |
|---|---|---|
filename |
str: The filename of the image to run the algorithm on. |
None (required) |
palette |
int | str: Either the number of colors to use for an auto-generated palette, or the name of a builtin palette (see palettes). |
16 |
pixelsize |
int | None: If int, the size of each pixel after reupsampling. If None, no downsampling is performed. |
None |
space |
str: The color space to run the pipeline in. One of rgb, linear, or oklab. |
rgb |
noisesize |
number: The amount of noize to add to the image, measured in standard deviations. Effect varies depending on space. |
0.0 |
| palette | description |
|---|---|
latte |
Catppuccin Latte |
macchiato |
Catppuccin Macchiato |




