Skip to content
Snippets Groups Projects
Commit f9676c4d authored by Tamino Huxohl's avatar Tamino Huxohl
Browse files

update join image function to automatically generate separator images

parent bb53e417
No related branches found
No related tags found
No related merge requests found
from typing import List
from typing import List, Optional
import numpy as np
from mu_map.dataset.util import align_images
from mu_map.file.dicom import load_dcm_img
from mu_map.file.interfile import load_interfile_img
from mu_map.file.util import load_img
def join_images(
images: List[np.ndarray], separator: np.ndarray, vertical: bool = False
) -> List[np.ndarray]:
images: List[np.ndarray],
separator: Optional[np.ndarray] = None,
vertical: bool = False,
) -> np.ndarray:
"""
Create a new image by joining all input images along a separator image.
If joining horizontally, their shape must be equal along their first axis.
If joining vertically, their shape must be equal along their second axis.
:param images: a list of images to join
:param separator: a separator image inserted between all images
:param vertical: join images vertically instead of horizontally
:return: a new image joined as described above
Parameters
----------
images: list of np.ndarray
a list of images to join
separator: np.ndarray, optional
a separator image inserted between all images - if None a default separator
with a width of 10 pixels is created
vertical: bool
join images vertically instead of horizontally
Returns
-------
np.ndarray
a new image joined as described above
"""
if separator is None:
shape = (
(10, *images[0].shape[1:])
if vertical
else (images[0].shape[0], 10, *images[0].shape[2:])
)
separator = np.full(shape, 239, np.uint8)
res = []
for image in images:
res += [image, separator]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment