# 说点 Cornernet/Centernet 代码里面 GT heatmap 里面如何应用高斯散射核

###### 来源：本文授权转自知乎作者Monstarrrr，https://zhuanlan.zhihu.com/p/96856635。未经作者许可，不得二次转载。

For each corner, there is one ground-truth positive location, and all other locations are negative. During training, instead of equally penalizing negative locations, we reduce the penalty given to negative locations within a radius of the positive location. This is because a pair of false corner detections, if they are close to their respective ground truth locations, can still produce a box that suciently overlaps the ground-truth box (Fig. 5). We determine the radius by the size of an
object by ensuring that a pair of points within the radius would generate a bounding box with at least t IoU with the ground-truth annotation (we set t to 0:3 in allexperiments).

$$overlap=\frac{h*w}{(h+2r)(w+2r)}$$

$$4overlapr^{2} + 2overlap(h+w)r+(overlap-1)(h*w) = 0$$

$$r = \frac{-b+\sqrt{b^{2}-4ac}}{2a}$$

$$overlap=\frac{(h-2r)(w-2r)}{hw}$$

$$4r^{2} - 2(h+w)r+(1-overlap)(hw) = 0$$

$$r = \frac{-b+\sqrt{b^{2}-4ac}}{2a}$$

$$overlap=\frac{(h-r)(w-r)}{2hw -(h-r)(w-r)}$$

$$r^{2} - (h+w)r+\frac{(1-overlap)*wh}{1+overlap}$$

$$r = \frac{-b+\sqrt{b^{2}-4ac}}{2a}$$

def gaussian_radius(det_size, min_overlap):
height, width = det_size
# 情况三
a1  = 1
b1  = (height + width)
c1  = width * height * (1 - min_overlap) / (1 + min_overlap)
sq1 = np.sqrt(b1 ** 2 - 4 * a1 * c1)
r1  = (b1 + sq1) / 2

# 情况二
a2  = 4
b2  = 2 * (height + width)
c2  = (1 - min_overlap) * width * height
sq2 = np.sqrt(b2 ** 2 - 4 * a2 * c2)
r2  = (b2 + sq2) / 2

# 情况一
a3  = 4 * min_overlap
b3  = -2 * min_overlap * (height + width)
c3  = (min_overlap - 1) * width * height
sq3 = np.sqrt(b3 ** 2 - 4 * a3 * c3)
r3  = (b3 + sq3) / 2
return min(r1, r2, r3)

—题外话—