def get_score(self, algo_result, gt, scene, with_visualization=False): m_fattening = self.get_fattening(algo_result, gt, scene.get_fg_extrapolation()) mask = self.get_evaluation_mask(scene) * misc.get_mask_valid(m_fattening) score = misc.percentage(np.sum(mask), np.sum(m_fattening * mask)) if not with_visualization: return score vis = np.ma.masked_array(plotting.adjust_binary_vis(m_fattening), mask=~mask) return score, vis
def get_score(self, algo_result, gt, scene, with_visualization=False): m_bad_pix = self.get_bad_pix(algo_result - gt) mask = self.get_evaluation_mask(scene) * misc.get_mask_valid(m_bad_pix) n_bad = np.sum(m_bad_pix[mask]) score = misc.percentage(np.sum(mask), n_bad) if not with_visualization: return score m_bad_pix = plotting.adjust_binary_vis(m_bad_pix) vis = np.ma.masked_array(m_bad_pix, mask=~mask) return score, vis
def get_score(self, algo_result, gt, scene, with_visualization=False): grid = scene.get_boxes() dots_by_size = scene.get_dots_by_size() bad_pix = BadPix(thresh=self.thresh) vis = np.zeros(np.shape(algo_result), dtype=np.bool) diffs = np.abs(gt - algo_result) box_ids = sorted(list(np.unique(grid))) box_ids.remove(0) n_boxes = np.size(box_ids) dot_labels = list(np.unique(dots_by_size)) # use only the nine biggest dots per box dot_labels = [dl for dl in dot_labels if 0 < dl < 9] n_dots = len(dot_labels) total_dots = n_dots * n_boxes detected_dots = 0 for box_id in box_ids: m_box = (grid == box_id) for idx_d in range(n_dots): dot_mask = (dots_by_size == idx_d+1) * m_box bad_pix_on_dot = bad_pix.get_score_from_diffs(diffs[dot_mask]) if bad_pix_on_dot < self.missed_dot_bad_pix: detected_dots += 1 else: vis[dot_mask] = 1 missed_dots = total_dots - detected_dots score = misc.percentage(total_dots, missed_dots) if not with_visualization: return score vis = plotting.adjust_binary_vis(vis) return score, vis