共计 595 个字符,预计需要花费 2 分钟才能阅读完成。
1. 高斯卷积核可视化
#设置卷积核大小 K_size, 像素长度 l
K_size = 3
l = 50
pad = K_size // 2
img = np.zeros([K_size * 50, K_size * 50, 3], dtype=np.uint8)
for i in range(K_size):
for j in range(K_size):
#绘制卷积两头地位
if i == pad and j == pad:
x = i * l
y = j * l
img[x: x + 47, y: y + 47] = (0, 0, 100)
cv2.putText(img, str(0.16), (j * l + 5, (i + 1) * l - 25), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (200, 200, 0), 2)
#绘制最靠近核心的地位
elif i + j == 3 or i + j == 1:
x = i * l
y = j * l
img[x: x + 47, y: y + 47] = (50, 0, 0)
cv2.putText(img, str(0.12), (j * l + 5, (i + 1) * l - 25), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (200, 200, 0), 2)
#绘制角落
else:
x = i * l
y = j * l
img[x: x + 47, y: y + 47] = (100, 0, 0)
cv2.putText(img, str(0.09), (j * l + 5, (i + 1) * l - 25), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (200, 200, 0), 2)
失去图像
正文完