code: def test_remove_background(resources, outdir):
      # Ensure the input image does not contain pure white/black
      with Image.open(resources / "baiona_color.jpg") as im:
          assert im.getextrema() != ((0, 255), (0, 255), (0, 255))
  
      output_pdf = check_ocrmypdf(
          resources / "baiona_color.jpg",
          outdir / "test_remove_bg.pdf",
          "--remove-background",
          "--image-dpi",
          "150",
          "--plugin",
          "tests/plugins/tesseract_noop.py",
      )
  
      output_png = outdir / "remove_bg.png"
  
      ghostscript.rasterize_pdf(
          output_pdf,
          output_png,
          raster_device="png16m",
          raster_dpi=Resolution(100, 100),
          pageno=1,
      )
  
      # The output image should contain pure white and black
      with Image.open(output_png) as im:
          assert im.getextrema() == ((0, 255), (0, 255), (0, 255))
  
file_path: OCRmyPDF/tests/test_preprocessing.py
imports: from __future__ import annotations
  from math import isclose
  import pytest
  from PIL import Image
  from ocrmypdf._exec import ghostscript, tesseract
  from ocrmypdf.helpers import Resolution
  from ocrmypdf.pdfinfo import PdfInfo
  from .conftest import check_ocrmypdf, have_unpaper
label_desc: Use image node_id 3 for calling a global function with example usage: test_remove_background(resources, outdir) without return types