使用opencv-python实现MATLAB的fspecial('Gaussian', [r, c], sigma)
reference_opencv实现高斯核
reference_MATLAB_fspecial函数说明
# MATLAB
H = fspecial('Gaussian', [r, c], sigma);
# opencv-python
# cv2.getGaussianKernel(r, sigma)返回一个shape为(r, 1)的np.ndarray, fspecial里核的size的参数是先行后列, 因此:
H = np.multiply(cv2.getGaussianKernel(r, sigma), (cv2.getGaussianKernel(c, sigma)).T) # H.shape == (r, c)