File size: 1,097 Bytes
911c613
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# ------------------------------------------------------------ #
#
# file : preprocessing/normalisation.py
# author : CM
#
# ------------------------------------------------------------ #
import numpy as np

# Rescaling (min-max normalization)
def linear_intensity_normalization(loaded_dataset):
    loaded_dataset = (loaded_dataset / loaded_dataset.max())
    return loaded_dataset

# Preprocess dataset with intensity normalisation
# (zero mean and unit variance)
def standardization_intensity_normalization(dataset, dtype):
    mean = dataset.mean()
    std  = dataset.std()
    return ((dataset - mean) / std).astype(dtype)

# Intensities normalized to the range [0, 1]
def intensityNormalisationFeatureScaling(dataset, dtype):
    max = dataset.max()
    min = dataset.min()

    return ((dataset - min) / (max - min)).astype(dtype)

# Intensity max clipping with c "max value"
def intensityMaxClipping(dataset, c, dtype):
    return np.clip(a=dataset, a_min=0, a_max=c).astype(dtype)

# Intensity projection
def intensityProjection(dataset, p, dtype):
    return (dataset ** p).astype(dtype)