Orthogonal ratio of image processing (IoU)

Source: Internet
Author: User

This article fixed link: https://www.lao-wang.com/?p=114 reprint: Searky July 31, 2017 in Lao Wang's website published

Orthogonal ratio (INTERSECTION-OVER-UNION,IOU), a concept used in target detection, is the rate of overlap between the resulting candidate frame (candidate bound) and the original marker box (ground truth bound), i.e. the ratio of their intersection to the set. Ideally, the total overlap, which is the ratio of 1.


Calculation formula:

Python implementation code:

def Calculateiou (Candidatebound, Groundtruthbound):
    cx1 = candidatebound[0]
    cy1 = candidatebound[1]
    cx2 = CANDIDATEBOUND[2]
    cy2 = candidatebound[3]

    gx1 = groundtruthbound[0]
    gy1 = groundtruthbound[1]
    gx2 = GROUNDTRUTHBOUND[2]
    gy2 = groundtruthbound[3]

    Carea = (cx2-cx1) * (cy2-cy1) #C的面积
    Garea = (gx2-gx1) * (g Y2-GY1) #G的面积

    x1 = max (cx1, gx1)
    y1 = max (Cy1, gy1)
    x2 = min (cx2, gx2)
    y2 = min (cy2, gy2)
    w = m Ax (0, x2-x1)
    h = max (0, y2-y1)
    area = w * H #C ∩g

    IOU = areas/(Carea + garea-area) return

    IOU


def Calculateiou (Candidatebound, groundtruthbound): cx1 = candidatebound[0] Cy1 = candidatebound[1] cx2 = candidatebound[ 2] cy2 = candidatebound[3] gx1 = groundtruthbound[0] gy1 = groundtruthbound[1] gx2 = groundtruthbound[2] Gy2 = Groundtruth BOUND[3] Carea = (cx2-cx1) * (cy2-cy1) #C的面积 Garea = (gx2-gx1) * (gy2-gy1) #G的面积 x1 = max (cx1, gx1) y1 = max (Cy1, gy1) x2 = min (cx2, gx2) y2 = min (cy2, gy2) w = max (0, x2-x1) H = max (0, y2-y1) area = w * H #C ∩g size IOU = areas/(Care A + Garea-area) return IOU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.