Generate a bivariate isotropic or anisotropic Gaussian kernel. In the isotropic mode, only `sig_x` is used. `sig_y` and `theta` is ignored. Args: kernel_size (int): sig_x (float): sig_y (float): theta (float): Radian measurement. grid (ndarray, optiona
(kernel_size, sig_x, sig_y, theta, grid=None, isotropic=True)
| 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. |
| 199 | In the isotropic mode, only `sig_x` is used. `sig_y` and `theta` is ignored. |
| 200 | Args: |
| 201 | kernel_size (int): |
| 202 | sig_x (float): |
| 203 | sig_y (float): |
| 204 | theta (float): Radian measurement. |
| 205 | grid (ndarray, optional): generated by :func:`mesh_grid`, |
| 206 | with the shape (K, K, 2), K is the kernel size. Default: None |
| 207 | isotropic (bool): |
| 208 | Returns: |
| 209 | kernel (ndarray): normalized kernel. |
| 210 | """ |
| 211 | if grid is None: |
| 212 | grid, _, _ = mesh_grid(kernel_size) |
| 213 | if isotropic: |
| 214 | sigma_matrix = np.array([[sig_x**2, 0], [0, sig_x**2]]) |
| 215 | else: |
| 216 | sigma_matrix = sigma_matrix2(sig_x, sig_y, theta) |
| 217 | kernel = pdf2(sigma_matrix, grid) |
| 218 | kernel = kernel / np.sum(kernel) |
| 219 | return kernel |
no test coverage detected