coord2region.utils.image_utils#
Utility functions for generating simple brain images.
This module currently exposes generate_mni152_image(), which creates a
static visualization of a spherical region overlaid on the MNI152 template
using Nilearn’s plotting utilities. The resulting image is returned as PNG
bytes so it can be saved or embedded by callers without touching the
filesystem.
Functions#
|
Return a PNG image of a sphere drawn on the MNI152 template. |
|
Overlay a semi-transparent watermark onto image bytes. |
|
Return a labelled side-by-side comparison panel. |
Module Contents#
- coord2region.utils.image_utils.generate_mni152_image(coord: Sequence[float], radius: int = 6, cmap: str = 'autumn') bytes[source]#
Return a PNG image of a sphere drawn on the MNI152 template.
- Parameters:
- Returns:
PNG-encoded image bytes representing the sphere on the MNI152 template.
- Return type:
- coord2region.utils.image_utils.add_watermark(image_bytes: bytes, text: str = 'AI approximation for illustrative purposes') bytes[source]#
Overlay a semi-transparent watermark onto image bytes.
- coord2region.utils.image_utils.build_side_by_side_panel(left_image: bytes, right_image: bytes, *, left_title: str = 'AI-generated approximation', right_title: str = 'Nilearn reference', background_color: tuple[int, int, int] = (20, 20, 24), padding: int = 36) bytes[source]#
Return a labelled side-by-side comparison panel.
- Parameters:
left_image (bytes) – PNG-encoded images for the left and right panels respectively.
right_image (bytes) – PNG-encoded images for the left and right panels respectively.
left_title (str, optional) – Captions rendered above the corresponding image.
right_title (str, optional) – Captions rendered above the corresponding image.
background_color (tuple[int, int, int], optional) – RGB colour applied to the canvas background. Defaults to a dark grey.
padding (int, optional) – Padding (in pixels) surrounding the images and text.