dcnum.segm.segm_torch.torch_preproc =================================== .. py:module:: dcnum.segm.segm_torch.torch_preproc Functions --------- .. autoapisummary:: dcnum.segm.segm_torch.torch_preproc.preprocess_images Module Contents --------------- .. py:function:: preprocess_images(images: numpy.ndarray, norm_mean: float | None, norm_std: float | None, image_shape: tuple[int, int] | None = None) Transform image data to something torch models expect The transformation includes: - normalization (division by 255, subtraction of mean, division by std) - cropping and padding of the input images to `image_shape`. For padding, the median of each *individual* image is used. - casting the input images to four dimensions (batch_size, 1, height, width) where the second axis is "channels" :param images: Input image array (batch_size, height_in, width_in). If this is a 2D image, it will be reshaped to a 3D image with a batch_size of 1. :param norm_mean: Mean value used for standard score data normalization, i.e. `normalized = `(images / 255 - norm_mean) / norm_std`; Set to None to disable normalization. :param norm_std: Standard deviation used for standard score data normalization; Set to None to disable normalization (see above). :param image_shape: Image shape for which the model was created (height, width). If the image shape does not match the input image shape, then the input images are padded/cropped to fit the image shape of the model. :returns: 3D array with preprocessed image data of shape (batch_size, 1, height, width) :rtype: image_proc