Skip to content

madmattp/Bayer-Dithering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dithered Image

Bayer Dithering

Python

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.

Features

  • 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.

Installation

  1. Clone the repository:
git clone https://github.com/madmattp/Bayer-Dithering.git
  1. Install dependencies:
pip install -r requirements.txt

Usage:

Command Line Options:

  • -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).

Recommended Settings

For more visually pleasing results before applying dithering, it is recommended to use the following settings:

  • Contrast: 1.5
  • Sharpness: 1.6
  • Downscaling: >2

Examples:

  1. 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

Silly Cat Dithered Image

  1. 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

Configuration

Fine-tune the dithering effect by adjusting matrix size, sharpness, contrast, and downscaling factors. Use multi-threading for faster video processing.

Contributions

Feel free to open issues or contribute via pull requests. Contributions are welcome!