LDM-SyntheticChestX-Ray / overlay_image.py
lfolle's picture
small fix to video
44a5c17
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import os
def overlay_file(im_path, heat_map_path):
im = np.array(Image.open(im_path))
heat_map = np.array(Image.open(heat_map_path))
overlay_numpy(im, heat_map, im_path)
def overlay_numpy(im, heat_map, path):
fig = plt.figure()
plt.imshow(im, 'gray', interpolation='none')
plt.imshow(heat_map, 'jet', interpolation='none', alpha=0.35),
plt.axis('off')
#plt.show()
file_name = os.path.splitext(path)[0] + '_overlay.png'
fig.savefig(file_name, bbox_inches='tight', pad_inches=0, transparent=True, dpi=1200)
plt.close()