Calculate PDF of the bivariate Gaussian distribution. Args: sigma_matrix (ndarray): with the shape (2, 2) grid (ndarray): generated by :func:`mesh_grid`, with the shape (K, K, 2), K is the kernel size. Returns: kernel (ndarrray): un-normalized kernel.
(sigma_matrix, grid)
| 182 | |
| 183 | |
| 184 | def pdf2(sigma_matrix, grid): |
| 185 | """Calculate PDF of the bivariate Gaussian distribution. |
| 186 | Args: |
| 187 | sigma_matrix (ndarray): with the shape (2, 2) |
| 188 | grid (ndarray): generated by :func:`mesh_grid`, |
| 189 | with the shape (K, K, 2), K is the kernel size. |
| 190 | Returns: |
| 191 | kernel (ndarrray): un-normalized kernel. |
| 192 | """ |
| 193 | inverse_sigma = np.linalg.inv(sigma_matrix) |
| 194 | kernel = np.exp(-0.5 * np.sum(np.dot(grid, inverse_sigma) * grid, 2)) |
| 195 | return kernel |
| 196 | |
| 197 | def bivariate_Gaussian(kernel_size, sig_x, sig_y, theta, grid=None, isotropic=True): |
| 198 | """Generate a bivariate isotropic or anisotropic Gaussian kernel. |
no outgoing calls
no test coverage detected