本质上,我有一个代表真实情况的二值图像,并且有一个取自算法结果的二值图像 - 现在的任务是找到重叠区域来评估算法的性能,即找到真正的阳性( TP)、真阴性(TN)、假阳性(FP)和假阴性(FN)。
我已经正确找到了 FP 和 FN 的值,但是我无法理解如何分离 TN 和 TP。
我计算重叠的方法是首先计算出地面真实图像和算法图像之间的差异:
% Gdilate=ground truth image, img=result of algorithm
ImageComparison = (Gdilate>0)-(img>0);
然后,通过减法,我可以将所有 0、1 和 -1 的像素相加,以获得 TP_TN、FN 和 FP。
TP_TN = sum(sum(ImageComparison==0))/rows/columns;
FN = sum(sum(ImageComparison==-1))/rows/columns;
FP = sum(sum(ImageComparison==1))/rows/columns;
以下是结果imagesc()
on the ImageComparison
多变的:
现在我只需要找到一种方法将 TP 与 TN 分开,因为它们在ImageComparison
matrix.
您这样做的方式无法区分真正的积极因素和真正的消极因素,因为(0 - 0
and 1 - 1
) are both等于零。相反,如果您有两个二进制结果(ground_truth
and test_data
),您不需要将两者相减,您可以仅使用逻辑比较来计算您需要的一切。
ground_truth = Gdilate > 0;
test_data = img > 0;
误报
基本事实为阴性,但测试为阳性。
false_positives = ~ground_truth & test_data;
false_positive_rate = sum(false_positives(:)) / numel(false_positives);
假阴性
真实数据为阳性,但测试为阴性
false_negatives = ground_truth & ~test_data;
false_negative_rate = sum(false_negatives(:)) / numel(false_negatives);
真正的积极因素
两者都积极
true_positives = ground_truth & test_data;
true_positive_rate = sum(true_positives(:)) / numel(true_positives);
真阴性
两者均为负数
true_negatives = ~ground_truth & ~test_data;
true_negative_rate = sum(true_negatives(:)) / numel(true_negatives);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)