(img, pred_color, blend_factor=0.4)
| 18 | |
| 19 | |
| 20 | def overlay(img, pred_color, blend_factor=0.4): |
| 21 | import cv2 |
| 22 | edges = cv2.Canny(pred_color, 20, 40) |
| 23 | edges = cv2.dilate(edges, np.ones((5,5),np.uint8), iterations=1) |
| 24 | out = (1-blend_factor)*img + blend_factor * pred_color |
| 25 | edge_pixels = (edges==255) |
| 26 | new_color = [0,0,255] |
| 27 | for i in range(0,3): |
| 28 | timg = out[:,:,i] |
| 29 | timg[edge_pixels]=new_color[i] |
| 30 | out[:,:,i] = timg |
| 31 | return out |
| 32 | |
| 33 | |
| 34 | def visualize_result(label_map): |