-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhelpers.py
36 lines (26 loc) · 837 Bytes
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import matplotlib.cm as cm
import numpy as np
'''
The following functions are modified from KittiSeg repository
'''
def make_overlay(image, gt_prob):
mycm = cm.get_cmap('bwr')
overimage = mycm(gt_prob, bytes=True)
output = 0.4*overimage[:,:,0:3] + 0.6*image
return output
def overlayImageWithConfidence(in_image, conf, vis_channel = 1, threshold = 0.5):
'''
:param in_image:
:param conf:
:param vis_channel:
:param threshold:
'''
if in_image.dtype == 'uint8':
visImage = in_image.copy().astype('f4')/255
else:
visImage = in_image.copy()
channelPart = visImage[:, :, vis_channel] * (conf > threshold) - conf
channelPart[channelPart < 0] = 0
visImage[:, :, vis_channel] = 0.5*visImage[:, :, vis_channel] + 255*conf
return visImage