hbldh / hitherdither

Dithering algorithms for arbitrary palettes in PIL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect output

missionfloyd opened this issue · comments

I've noticed that images produced with hitherdither are slightly different than those produced with other programs using the same algorithms.

I tested this using Floyd-Steinberg on a solid 50% gray image, which should produce a uniform checkerboard pattern.

Input Output Expected (from PIL)
808080 out mock_output

I've found that by rounding when distributing the quantization error, the above image renders correctly, while others are closer but still different.
ni[yn, xn] += np.round(quantization_error * diffusion_coefficient)
Maybe that's as good as it's gonna get.

Interesting. How did you create the PIL image? If PIL works better, then I would suggest using that.

from PIL import Image

img = Image.open('808080.png') # solid grey image
img_dithered = img.convert('1') # uses floyd-steinberg dithering by default
img_dithered.save('dithered.png')

PIL only supports Floyd-Steinberg, however.