Create a binary kernel to extract the patches. The window size HxWxD will create a (H*W*D)xHxWxD kernel.
(window_size: Sequence[int], dtype=torch.float, device=None)
| 428 | |
| 429 | |
| 430 | def get_binary_kernel(window_size: Sequence[int], dtype=torch.float, device=None) -> torch.Tensor: |
| 431 | """ |
| 432 | Create a binary kernel to extract the patches. |
| 433 | The window size HxWxD will create a (H*W*D)xHxWxD kernel. |
| 434 | """ |
| 435 | win_size = convert_to_tensor(window_size, int, wrap_sequence=True) |
| 436 | prod = torch.prod(win_size) |
| 437 | s = [prod, 1, *win_size] |
| 438 | return torch.diag(torch.ones(prod, dtype=dtype, device=device)).view(s) # type: ignore |
| 439 | |
| 440 | |
| 441 | def median_filter( |
no test coverage detected
searching dependent graphs…