This page stores some self-made toolbox files written by multiple languages and all the files are classified into detailed different categories.
Normal: normalize data
1 2 3 4 5 6 7 8 9 10
| def Normal(_data): ''' This function return the normalization of image data
input : image: _data
output: normalized_image: data ''' data = _data.copy() data = (data-np.min(data)) / (np.max(data) - np.min(data)) return data
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| def img2uint8(img): ''' This function convert image data from double to uint8
input: image: img
output: image_uin8: img_uint8 ''' try: _datatype = img.dtype except AttributeError: print 'input should be of ndarray type.'
if img.dtype == 'uint8': print 'the input is already of uint8 type.' return img
img = Normal(img) img_uint8 = (img * 255).astype('uint8') return img_uint8
|