Exemplo n.º 1
0
    def get_score(self, algo_result, gt, scene, with_visualization=False):
        mask = self.get_evaluation_mask(scene) * \
               misc.get_mask_valid(algo_result) * \
               misc.get_mask_valid(gt)
        score = self.get_masked_score(algo_result, gt, mask)

        if not with_visualization:
            return score

        vis = np.ma.masked_array(gt - algo_result, mask=~mask)
        return score, vis
Exemplo n.º 2
0
    def get_score(self, algo_result, gt, scene, with_visualization=False):
        diffs = np.abs(algo_result - gt) * self.factor
        mask = self.get_evaluation_mask(scene) * misc.get_mask_valid(diffs) * misc.get_mask_valid(algo_result)
        sorted_diffs = np.sort(diffs[mask])
        idx = np.size(sorted_diffs) * self.percentage / 100.
        score = sorted_diffs[int(idx)]

        if not with_visualization:
            return score

        with np.errstate(invalid="ignore"):
            m_bad_pix = np.abs(diffs) > score
        vis = np.abs(diffs)
        vis[m_bad_pix] = -1
        vis = np.ma.masked_array(vis, mask=~mask)
        return score, vis
Exemplo n.º 3
0
    def get_score_from_mask(self,
                            algo_result,
                            gt,
                            scene,
                            mask,
                            with_visualization=False):
        angular_error = self.get_angular_error(algo_result, gt, scene)
        mask = mask * misc.get_mask_valid(algo_result) * misc.get_mask_valid(
            angular_error)
        score = np.median(angular_error[mask])

        if not with_visualization:
            return score

        vis = np.ma.masked_array(angular_error, mask=~mask)
        return score, vis
    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
Exemplo n.º 5
0
    def get_score(self, algo_result, gt, scene, with_visualization=False):
        bumpiness = self.get_bumpiness(gt, algo_result)
        mask = self.get_evaluation_mask(scene) * misc.get_mask_valid(bumpiness)
        score = self.factor * np.sum(bumpiness[mask]) / float(np.sum(mask))

        if not with_visualization:
            return score

        vis = np.ma.masked_array(bumpiness * self.factor, mask=~mask)
        return score, vis
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
def compute_scores(algorithms,
                   scenes,
                   thresholds=THRESHOLDS,
                   penalize_missing_pixels=True):
    percentages_algo_thresh = np.full((len(algorithms), len(thresholds)),
                                      fill_value=np.nan)
    bad_pix_metric = BadPix()
    max_diff = np.max(thresholds)

    for idx_a, algorithm in enumerate(algorithms):
        combined_diffs = np.full(0, fill_value=np.nan)
        log.info('Computing BadPix scores for: %s' %
                 algorithm.get_display_name())

        for scene in scenes:
            gt = scene.get_gt()
            algo_result = misc.get_algo_result(algorithm, scene)
            diffs = np.abs(algo_result - gt)

            mask_valid = misc.get_mask_valid(
                algo_result) * misc.get_mask_valid(diffs)
            mask_eval = bad_pix_metric.get_evaluation_mask(scene)

            if penalize_missing_pixels:
                # penalize all invalid algorithm pixels with maximum error
                diffs[~mask_valid] = max_diff + 100
                diffs = diffs[mask_eval]
            else:
                diffs = diffs[mask_eval * mask_valid]

            combined_diffs = np.concatenate((combined_diffs, diffs))

        # compute BadPix score for each threshold
        for idx_t, t in enumerate(thresholds):
            bad_pix_metric.thresh = t
            bad_pix_score = bad_pix_metric.get_score_from_diffs(combined_diffs)
            percentages_algo_thresh[idx_a, idx_t] = 100 - bad_pix_score

    return percentages_algo_thresh