Closed damondpham closed 4 years ago
You've linked to the v3.1 docs from 2016. This:
If dither is NONE, all non-zero values are set to 255 (white).
has since been changed (in https://github.com/python-pillow/Pillow/pull/3397) to:
If dither is NONE, all values larger than 128 are set to 255 (white), all other values to 0 (black).
https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.convert
It also says "If dither is NONE, all non-zero values are set to 255 (white)." This should be "If dither is False, ...", right?
Checking the source, if dither is None
(not NONE
which equals NEAREST
and 0), dither is set to FLOYDSTEINBERG
.
And NONE
and FLOYDSTEINBERG
give different results:
The default method of converting a greyscale (“L”) or “RGB” image into a bilevel (mode “1”) image uses Floyd-Steinberg dither to approximate the original image luminosity levels. If dither is NONE, all values larger than 128 are set to 255 (white), all other values to 0 (black).
ah, perfect. thanks so much for your help!
You're welcome!
The Docs state binary conversion makes all non-zero values white, and all zero values black: https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#PIL.Image.Image.convert
But, if I read in an image, it looks like it uses a halfway point instead:
Image.open('my_image.jpg').convert(mode='1', dither=False)
Here is the image file I tried: https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fchildrensdentistryofcharlottesville.com%2Fwp-content%2Fuploads%2F2017%2F01%2Fblack-white-spectrum.jpg&f=1&nofb=1
It also says "If dither is NONE, all non-zero values are set to 255 (white)." This should be "If dither is False, ...", right?