MCPcopy Create free account
hub / github.com/dcharatan/flowmap / add_border

Function add_border

flowmap/visualization/layout.py:202–214  ·  view source on GitHub ↗
(
    image: Float[Tensor, "channel height width"],
    border: int = 8,
    color: Color = 1,
)

Source from the content-addressed store, hash-verified

200
201
202def 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
217def resize(

Callers 2

visualizeMethod · 0.85
visualizeMethod · 0.85

Calls 2

_sanitize_colorFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected