diff --git a/mu_map/vis/slices.py b/mu_map/vis/slices.py index a4fc04c3c0ccccdf4a25502d5513e84bf44572d4..fb7fe0e488feae4706351f3c23b9535db7d16ed0 100644 --- a/mu_map/vis/slices.py +++ b/mu_map/vis/slices.py @@ -1,26 +1,44 @@ -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]