File size: 442 Bytes
6c0075d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19


import numpy as np

def float2Uint(Image_float):
    """

    Transfer float image to np.uint8 type

    :param Image_float:

    :return:LnGray

    """

    MaxLn = np.max(Image_float)
    MinLn = np.min(Image_float)
    # LnGray = 255*(Image_float - MinLn)//(MaxLn - MinLn + 1e-6)
    LnGray = 255 * ((Image_float - MinLn) / float((MaxLn - MinLn + 1e-6)))
    LnGray = np.array(LnGray, dtype = np.uint8)

    return LnGray