File size: 638 Bytes
e5a19d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()