Help us understand the problem. What is going on with this article?

# IoUの0.1～0.9を図にしてみた

More than 1 year has passed since last update.

# コード

plot_iou.py
```import matplotlib
import matplotlib.pyplot as plt

import numpy as np

for i, iou in enumerate(np.linspace(1, 0, 11)):
# 　 ↓t
# □□□
# □□□
# □□■□□
# 　　□□□
# 　　□□□

# inter = (1 - t) ** 2
# union = 2 - inter
# iou = inter / union
# https://www.wolframalpha.com/input/?dataset=&i=Solve%5Bu+%3D%3D+(1+-+t)%5E2+%2F+(2+-+(1+-+t)%5E2)+%26%26+0+<%3D+t+%26%26+t+<%3D+1+%26%26+0+<%3D+u+%26%26+u+<%3D+1,+t%5D
# → t = 1 - sqrt(2) sqrt(u/(1 + u))
t = 1 - np.sqrt(2 * iou / (1 + iou))
print(f'#{i} iou={iou:.2f}, offset={t:.2f}')

fig = plt.figure()
ax = plt.axes()
ax.add_patch(matplotlib.patches.Rectangle(xy=(0 / 2, 0.5 + 0 / 2), width=0.5, height=0.5, color='#9999ff77'))
ax.add_patch(matplotlib.patches.Rectangle(xy=(t / 2, 0.5 - t / 2), width=0.5, height=0.5, color='#99ff9977'))
ax.set_aspect('equal')
plt.savefig(f'#{i} iou={iou:.2f}, offset={t:.2f}.png')
plt.close()
```
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away