/ changedetection / utils / fusion_maria.py
fusion_maria.py
 1  #!/usr/bin/env python3
 2  # -*- coding: utf-8 -*-
 3  """
 4  Created on Wed Apr  6 21:27:17 2022
 5  
 6  @author: Maria Pegia
 7  """
 8  
 9  import numpy as np
10  
11  
12  
13  def fusion(triangle_cm, otsu_cm, conv_cm, param):
14      triangle_cm = triangle_cm.astype(int)
15      otsu_cm = otsu_cm.astype(int)
16      conv_cm = conv_cm.astype(int)
17      
18      cm = np.zeros(conv_cm.shape)
19  
20      sim = np.bitwise_and(triangle_cm, otsu_cm)  # Keep similarities
21  
22      rows = sim.shape[0]
23      for i in range(rows):
24          x = conv_cm[i, :]
25          y = sim[i, :]
26          dist = np.linalg.norm(x - y)
27  
28          cm[i, :] = x if dist > param else y
29  
30      return cm