头图

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)

得到图像
高斯卷积核


罗岩
1 声望0 粉丝