Last active
August 19, 2021 13:36
-
-
Save Borda/0c4afc86db7d273da257914ff8a03d41 to your computer and use it in GitHub Desktop.
blog: show COVID detection bbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pydicom | |
from pydicom.pixel_data_handlers import apply_voi_lut | |
# load the DICOM file | |
dicom = pydicom.dcmread(dicom_path) | |
# extract the image bitmap | |
img = apply_voi_lut(dicom.pixel_array, dicom) | |
import matplotlib.pyplot as plt | |
from matplotlib import patches | |
fig, ax = plt.subplots() | |
ax_im = ax.imshow(img, cmap="gray") | |
bbox_property = dict(linewidth=1, edgecolor='r', facecolor='none') | |
for bbox in train_images["boxes"][idx_]: | |
xy_wh = (bbox['x'], bbox['y']), bbox['width'], bbox['height'] | |
# Create a Rectangle patch | |
rect = patches.Rectangle(*xy_wh, **bbox_property) | |
# Add the patch to the Axes | |
ax.add_patch(rect) | |
plt.colorbar(ax_im) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment