[405042]: / cardiac_motion / utils / image_utils.py

Download this file

13 lines (8 with data), 385 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import torch
import torch.nn.functional as F
import numpy as np
# -- image normalisation to 0 - 255
def normalise_numpy(x, norm_min=0.0, norm_max=255.0):
return float(norm_max - norm_min) * (x - np.min(x)) / (np.max(x) - np.min(x))
def normalise_torch(x, norm_min=0.0, norm_max=255.0):
return float(norm_max - norm_min) * (x - torch.min(x)) / (torch.max(x) - torch.min(x))