Plot custom bounding boxes¶
This notebook covers how to use the image verification engines to plot custom bounding boxes. This can be helpful when you want to verify a provided set of bounding boxes against an image.
Prerequisites¶
Before getting started, make sure presidio and the latest version of Tesseract OCR are installed. For detailed documentation, see the installation docs.
In [ ]:
Copied!
!pip install presidio_analyzer presidio_anonymizer presidio_image_redactor
!python -m spacy download en_core_web_lg
!pip install presidio_analyzer presidio_anonymizer presidio_image_redactor
!python -m spacy download en_core_web_lg
0. Imports and initializations¶
In [1]:
Copied!
from PIL import Image
import pydicom
from presidio_image_redactor import ImageAnalyzerEngine, ImagePiiVerifyEngine, DicomImagePiiVerifyEngine
import matplotlib.pyplot as plt
from PIL import Image
import pydicom
from presidio_image_redactor import ImageAnalyzerEngine, ImagePiiVerifyEngine, DicomImagePiiVerifyEngine
import matplotlib.pyplot as plt
Initialize engines used for image redaction
In [2]:
Copied!
# Image analyzer engine
image_analyzer_engine = ImageAnalyzerEngine()
# Verification engines
verify_engine = ImagePiiVerifyEngine() # standard images
dicom_verify_engine = DicomImagePiiVerifyEngine() # DICOM images
padding_width = 3
# Image analyzer engine
image_analyzer_engine = ImageAnalyzerEngine()
# Verification engines
verify_engine = ImagePiiVerifyEngine() # standard images
dicom_verify_engine = DicomImagePiiVerifyEngine() # DICOM images
padding_width = 3
1. Example images¶
In this notebook, we will use the following examples images.
1.1 Standard example image¶
In [3]:
Copied!
image = Image.open("../../image-redactor/ocr_text.png")
display(image)
image = Image.open("../../image-redactor/ocr_text.png")
display(image)
And this is what the image looks like with the standard, default behavior of the verification engine.
In [4]:
Copied!
verify_image = verify_engine.verify(image, display_image=True)
verify_image = verify_engine.verify(image, display_image=True)