How to use Dithering using pillow library?

1.6k views Asked by At

I want to use Dithering from pillow, (https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Dither.FLOYDSTEINBERG)

My question is how to import dither from pillow,

Following is my code,

import os

from PIL import Image



ORIGIN_PATH = "/home/prajakta/Tasks/Evaluate detection model on scanned customer documents/scanned_docs/"
#DESTIN_PATH = "/home/prajakta/Tasks/Evaluate detection model on scanned customer documents/scanned_docs_grayscale/"


for filename in os.listdir(ORIGIN_PATH):
    img = Image.open(ORIGIN_PATH + filename).convert("L", dither=Image.Dither)
    img.show()

Thank you in advance.

0

There are 0 answers