Function iamaxleveltype

Synopse

Returns the maximum value associated to an image datatype

  • max = iamaxleveltype(TYPE='uint8')
    • max: Double
    • TYPE: String One of the strings 'uint8', 'uint16', 'int32' or 'float64', specifying the image type
01. from numpy import *
02. 
03. def iamaxleveltype(TYPE='uint8'):
04. 
05.     max = 0
06.     if   TYPE == 'uint8'  : max=255
07.     elif TYPE == 'binary' : max=1
08.     elif TYPE == 'uint16' : max=65535
09.     elif TYPE == 'int32'  : max=2147483647
10.     elif TYPE == 'float64'  : max=inf
11.     else:
12.         assert 0, 'does not support this data type:'+TYPE
13. 
14.     return max
1. from iamaxleveltype import iamaxleveltype
2. 
3. print iamaxleveltype('uint8')
4. print iamaxleveltype('binary')
5. print iamaxleveltype('uint16')
6. print iamaxleveltype('int32')
7. print iamaxleveltype('float64')
255
1
65535
2147483647
inf