How to add noise (dithering) at background only?

I am trying to train a model with some noisy images having dithering.

What I have :

  1. clean pdfs with white background
  2. coloured pdfs(RGB) and grayscale pdfs (with 3 channels, RGB)

What I want:

  1. convert only white background (not text) into gray background, if possible only half page should be converted

  2. Add dithering to the gray background without loosing the text

what I tried:

import os

from PIL import Image
from numpy import asarray

ORIGIN_PATH = "/home/dithering/temp/"
DESTIN_PATH = "/home/dithering/temp_try/"
"""for filename in os.listdir(ORIGIN_PATH):
    img = + filename).convert("L")
    rbg_grayscale_img = img.convert("RGB") + filename)"""

for filename in os.listdir(ORIGIN_PATH):

    img = + filename).convert("L", dither=Image.Dither.FLOYDSTEINBERG)

    # convert image to nparray
    numpydata = asarray(img)
    numpydata[numpydata > 250] = 128

    # data

    # convert array to image
    final_image = Image.fromarray(numpydata)

    # img show

    # img save + filename)

I expect something like this, enter image description here

Any help would be appreciated, thanks in advance! @ptrblck