This Python script applies a Bayer matrix dithering to images, gifs or videos. It offers a variety of customizable options such as matrix size, filters, sharpness, contrast, and downscaling. It also supports multi-threading for faster processing.
- Dithering for images and videos: Applies Bayer matrix dithering to PNG, JPG, GIF, and MP4 files.
- Customizable filters: Configurable through the filters.toml file.
- Multi-threading Support: Process large files faster with parallel processing.
- Support for downscaling and sharpening: Image manipulation options before dithering.
- Clone the repository:
git clone https://github.com/madmattp/Bayer-Dithering.git
- Install dependencies:
pip install -r requirements.txt
-i, --input
: Specifies the input file (image or video) to apply dithering to.-m, --matrix
: Selects the Bayer matrix size. Options: 2x2, 4x4, 8x8 (default: 4x4).-o, --output
: Specifies the output file path. A default name will be used if not provided.-f, --filter
: Applies a color filter to the output image.-s, --sharpness
: Adjusts the sharpness (default: 1).-c, --contrast
: Adjusts the contrast (default: 1).-d, --downscale
: Downscales the image by a factor before dithering (default: 1).-t, --threads
: Specifies the number of threads for processing (default: 1).
For more visually pleasing results before applying dithering, it is recommended to use the following settings:
- Contrast: 1.5
- Sharpness: 1.6
- Downscaling: >2
- Dithering an Image with Recommended Settings:
python dither.py -i input_image.png -o output_image.png -m 4x4 -c 1.5 -s 1.6 -d 2
- Dithering a Video with Multiple Threads:
python dither.py -i input_video.mp4 -o output_video.mp4 -m 4x4 -t 4 -c 1.5 -s 1.6 -d 2
cat_huh.mp4
dithered_video.mp4
Fine-tune the dithering effect by adjusting matrix size, sharpness, contrast, and downscaling factors. Use multi-threading for faster video processing.
Feel free to open issues or contribute via pull requests. Contributions are welcome!