如何分离真阳性和真阴性?

编程入门 行业动态 更新时间:2024-10-09 08:27:57
本文介绍了如何分离真阳性和真阴性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

基本上我有一个二进制图像,它表示地面真相,我有一个二进制图像,从一个算法的结果 - 现在的任务是找到重叠区域来评估算法的性能,即找到真正阳性(TP),真阴性(TN),假阳性(FP)和假阴性(FN)。

我已经正确找到FP和FN的值,然而,我不能得到我的头如何我将分离TNs和TPs。

我计算重叠的方式是通过首先计算出的地面真实图像和该算法的图像:

%Gdilate =基准真实图像,img =算法的结果 ImageComparison =(Gdilate> 0 ) - (img> 0);

然后简单地由于减法,我可以将0s,1s和-1s的所有像素获取TP_TNs,FNs和FPs。

TP_TN = sum(sum(ImageComparison == 0))/ rows / columns; FN = sum(sum(ImageComparison == - 1))/ rows / columns; FP = sum(sum(imageComparison == 1))/ rows / columns;

以下是 imagesc()的结果 ImageComparison 变量:

现在我只需要找到一种方法将TP与TN分开,因为它们都显示为0 ImageComparison 矩阵。

解决方案

区分真阳性和真阴性,因为( 0 - 0 和 1 - 1 em>等于零。相反,如果您有两个二进制结果( ground_truth 和 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);

真阳性

/ p>

true_positives = ground_truth& test_data; true_positive_rate = sum(true_positives(:))/ numel(true_positives);

True Negatives

/ p>

true_negatives =〜ground_truth& 〜test_data; true_negative_rate = sum(true_negatives(:))/ numel(true_negatives);

Essentially I have a binary image which represents the ground truth and I have a binary image which is taken from the results of an algorithm - now the task was to find the overlapping regions to evaluate the performance of the algorithm, i.e. find the true positives (TPs), true negatives (TNs), false positives (FPs) and false negatives (FNs).

I have correctly found the values for FPs and FNs, however I cannot get my head around how I would separate the TNs and TPs.

The way I calculated the overlaps was by firstly working out the difference between the ground truth image and the algorithm's image:

% Gdilate=ground truth image, img=result of algorithm ImageComparison = (Gdilate>0)-(img>0);

Then simply due to the subtraction I can sum up all the pixels that 0s, 1s and -1s to obtain the TP_TNs, FNs and FPs.

TP_TN = sum(sum(ImageComparison==0))/rows/columns; FN = sum(sum(ImageComparison==-1))/rows/columns; FP = sum(sum(ImageComparison==1))/rows/columns;

Here are the results of imagesc() on the ImageComparison variable:

Now I just need to find a way to separate the TPs from the TNs, because they both appear as 0 in the ImageComparison matrix.

解决方案

The way that you are doing it cannot differentiate between true positives and true negatives because (0 - 0 and 1 - 1) are both equal to zero. Instead, if you have two binary results (ground_truth and test_data), you don't need to subtract the two, you can compute everything you need using just logical comparisons.

ground_truth = Gdilate > 0; test_data = img > 0;

False Positives

Negative in ground truth but positive in your test.

false_positives = ~ground_truth & test_data; false_positive_rate = sum(false_positives(:)) / numel(false_positives);

False Negatives

Positive in ground truth data but negative in your test

false_negatives = ground_truth & ~test_data; false_negative_rate = sum(false_negatives(:)) / numel(false_negatives);

True Positives

Positive in both

true_positives = ground_truth & test_data; true_positive_rate = sum(true_positives(:)) / numel(true_positives);

True Negatives

Negative in both

true_negatives = ~ground_truth & ~test_data; true_negative_rate = sum(true_negatives(:)) / numel(true_negatives);

更多推荐

如何分离真阳性和真阴性?

本文发布于:2023-11-29 10:53:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646187.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴性   阳性

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!