To get the 5x5 Gaussian kernel first we can form a 7x7 Numpy array with only one 1 in the middle.
img=np.zeros((7,7))
img[3,3]=1
img
The result of the code is
array([[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 1., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.]])
Then apply gaussian blur:
img1 = cv2.GaussianBlur(img, (5, 5), 0)
img1
The result is:
array([[0. , 0. , 0. , 0. , 0. ,0. , 0. ],
[0. , 0.00390625, 0.015625 , 0.0234375 , 0.015625 ,0.00390625, 0. ],
[0. , 0.015625 , 0.0625 , 0.09375 , 0.0625 ,0.015625 , 0. ],
[0. , 0.0234375 , 0.09375 , 0.140625 , 0.09375 ,0.0234375 , 0. ],
[0. , 0.015625 , 0.0625 , 0.09375 , 0.0625 ,0.015625 , 0. ],
[0. , 0.00390625, 0.015625 , 0.0234375 , 0.015625 ,0.00390625, 0. ],
[0. , 0. , 0. , 0. , 0. ,0. , 0. ]])
The nonzero numbers are the Gaussian kernel. We can confirm that the sum of the numbers are 1:
np.sum(img1)
1.0