(
image: Float[Tensor, "channel height width"],
border: int = 8,
color: Color = 1,
)
| 200 | |
| 201 | |
| 202 | def add_border( |
| 203 | image: Float[Tensor, "channel height width"], |
| 204 | border: int = 8, |
| 205 | color: Color = 1, |
| 206 | ) -> Float[Tensor, "channel new_height new_width"]: |
| 207 | color = _sanitize_color(color).to(image) |
| 208 | c, h, w = image.shape |
| 209 | result = torch.empty( |
| 210 | (c, h + 2 * border, w + 2 * border), dtype=torch.float32, device=image.device |
| 211 | ) |
| 212 | result[:] = color[:, None, None] |
| 213 | result[:, border : h + border, border : w + border] = image |
| 214 | return result |
| 215 | |
| 216 | |
| 217 | def resize( |
no test coverage detected