IoU算法可用与评估两个多维度数据的相似度,举一个实际应用,做CV,目标检测,我们需要评估模型的识别准确率,不同于二元类问题,普通的评估算法不合适,于是用到了这个算法,这个算法简单易懂,评估效果也不错。

  这里主要讨论如何计算并评估两个矩形相交程度。有空再训练一个目标检测器,来试试水。。

  第一种对于数据形状是这样的 $ (x_{top-left}, y_{top-left}, w, h) $,意思是:给出了起始坐标,矩形沿着 $ w, h $ 扩展开。

  算法实现:

  1. double IoU(int*a, int*b)
  2. {
  3. int overlap_w = min(a[0] + a[2], b[0] + b[2]) - max(a[0], b[0]);
  4. int overlap_h = min(a[1] + a[3], b[1] + b[3]) - max(a[1], b[1]);
  5. int overlap_s = overlap_w*overlap_h;
  6. return overlap_s / double(a[2]*a[3] + b[2]*b[3] - overlap_s);
  7. }

  第二种数据形状是这样的 $ (x_{top-left}, y_{top-left}, x_{right-down}, y_{right-down}) $,意思是:给出了起始坐标和终点坐标,如图:

  

  算法实现:

  1. double IoU_2(int*a, int*b)
  2. {
  3. int overlap_w = min(a[2], b[2]) - max(a[0], b[0]);
  4. int overlap_h = min(a[3], b[3]) - max(a[1], b[1]);
  5. int overlap_s = overlap_w*overlap_h;
  6. return overlap_s / double((a[2] - a[0])*(a[3] - a[1]) + (b[2] - b[0])*(b[3] - b[1]) - overlap_s);
  7. }

  用这几组数据测试一下:

  1. 1: [39, 63, 203, 112], [54, 66, 198, 114]
  2. 2: [49, 75, 203, 125], [42, 78, 186, 126]
  3. 3: [31, 69, 201, 125], [18, 63, 235, 135]
  4. 4: [50, 72, 197, 121], [54, 72, 198, 120]
  5. 5: [35, 51, 196, 110], [36, 60, 180, 108]

  output:

  1. 0.825758
  2. 0.795771
  3. =====================
  4. 0.809624
  5. 0.787838
  6. =====================
  7. 0.791962
  8. 0.609319
  9. =====================
  10. 0.947743
  11. 0.946628
  12. =====================
  13. 0.79667
  14. 0.727656
  15. =====================

  参考:

    1.https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/

    2.https://en.wikipedia.org/wiki/Jaccard_index

Intersection over Union(IoU) algorithms的更多相关文章

  1. 论文阅读笔记四十七:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression(CVPR2019)

    论文原址:https://arxiv.org/pdf/1902.09630.pdf github:https://github.com/generalized-iou 摘要 在目标检测的评测体系中,I ...

  2. 目标识别(object detection)中的 IoU(Intersection over Union)

    首先直观上来看 IoU 的计算公式: 由上述图示可知,IoU 的计算综合考虑了交集和并集,如何使得 IoU 最大,需要满足,更大的重叠区域,更小的不重叠的区域. 两个矩形窗格分别表示: 左上点.右下点 ...

  3. 『计算机视觉』Generalized Intersection over Union: A Metric and A Loss for Bounding BoxRegression

    论文地址:Generalized Intersection over Union 一.相关工作 目标检测精度标准 度量检测优劣基本基于 IOU,mAP 是典型的基于 IOU 的标准,但是 mAP 仅有 ...

  4. Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression

    Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression 2019-05-20 19:3 ...

  5. Dice Similarity Coefficent vs. IoU Dice系数和IoU

    Dice Similarity Coefficent vs. IoU Several readers emailed regarding the segmentation performance of ...

  6. 评价目标检测(object detection)模型的参数:IOU,AP,mAP

    首先我们为什么要使用这些呢? 举个简单的例子,假设我们图像里面只有1个目标,但是定位出来10个框,1个正确的,9个错误的,那么你要按(识别出来的正确的目标/总的正确目标)来算,正确率100%,但是其实 ...

  7. Analyzing The Papers Behind Facebook's Computer Vision Approach

    Analyzing The Papers Behind Facebook's Computer Vision Approach Introduction You know that company c ...

  8. 大规模视觉识别挑战赛ILSVRC2015各团队结果和方法 Large Scale Visual Recognition Challenge 2015

    Large Scale Visual Recognition Challenge 2015 (ILSVRC2015) Legend: Yellow background = winner in thi ...

  9. YOLO: You Only Look Once论文阅读摘要

    论文链接: https://arxiv.org/pdf/1506.02640.pdf 代码下载: https://github.com/gliese581gg/YOLO_tensorflow Abst ...

随机推荐

  1. python面试的100题(13)

    29.Given an array of integers 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数.你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用.示例:给定nums ...

  2. 2019-08-07 纪中NOIP模拟B组

    T1 [JZOJ1385] 直角三角形 题目描述 二维平面坐标系中有N个位置不同的点. 从N个点选择3个点,问有多少选法使得这3个点形成直角三角形. 数据范围 $3 \leq N \leq 1500$ ...

  3. Atom 基础使用

    当你安装好了 Atom 之后,让我们来认识一下它吧. 当你第一次打开 Atom 的时候,你会看到这样的一个窗口:   这是 Atom 的欢迎屏幕(welcome screen),它展示了一些不错的建议 ...

  4. day28 rsync服务端配置和客户端

    2. rsync守护进程部署方式 客户端---服务端 上厕所 4 rsync守护进程服务端配置: 第一个历程: 下载安装软件 rpm -qa|grep rsync yum install -y rsy ...

  5. g++运行c++程序提示main()找不到

    /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20) ...

  6. LED Holiday Light - Color Creation Of LED Christmas Lights

    In the long and interesting history of Christmas lights, nothing is brighter than light-emitting dio ...

  7. ORA-01935: missing user or role name

    问题描述 ORA-01935: missing user or role name ORA-01935:缺少用户或角色名

  8. mediasoup-demo解析-客户端

    1.gulp任务管理 app官方文档 npm start启动app,执行脚本: "start": "gulp live" 该命令用启动gulp顺序任务组合liv ...

  9. IntelliJ IDEA 2017.3尚硅谷-----模板

    https://www.jetbrains.com/help/idea/using-live-templates.html  

  10. VS2015+EF+MySql问题

    1.出现框架不兼容问题: 解决方法:a.在web.config或者app.config中加入所示代码: b.引用mysqlConnector.net中的所有dll,一般路径在D:\Program Fi ...