Skip to content

Instantly share code, notes, and snippets.

View smrht's full-sized avatar
💭
I may be slow to respond.

smrht

💭
I may be slow to respond.
View GitHub Profile
@bzamecnik
bzamecnik / floyd_steinberg_dithering.py
Created August 6, 2019 16:05
Floyd-Steinberg dithering in Python (quite fast via Numba JIT)
# https://en.wikipedia.org/wiki/Floyd–Steinberg_dithering
from numba import jit
import numpy as np
@jit(nopython=True)
def floyd_steinberg(image):
# image: np.array of shape (height, width), dtype=float, 0.0-1.0
# works in-place!
h, w = image.shape
for y in range(h):