Package omero :: Package util :: Module pixelstypetopython
[hide private]
[frames] | no frames]

Source Code for Module omero.util.pixelstypetopython

  1  #!/usr/bin/python 
  2  # 
  3  #------------------------------------------------------------------------------ 
  4  #  Copyright (C) 2006-2008 University of Dundee. All rights reserved. 
  5  # 
  6  # 
  7  #       This program is free software; you can redistribute it and/or modify 
  8  #  it under the terms of the GNU General Public License as published by 
  9  #  the Free Software Foundation; either version 2 of the License, or 
 10  #  (at your option) any later version. 
 11  #  This program is distributed in the hope that it will be useful, 
 12  #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  #  GNU General Public License for more details. 
 15  #   
 16  #  You should have received a copy of the GNU General Public License along 
 17  #  with this program; if not, write to the Free Software Foundation, Inc., 
 18  #  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 19  # 
 20  #------------------------------------------------------------------------------ 
 21  # 
 22  # The Pixels object in omero, has a member pixelsType, this can be  
 23  #       INT_8 = "int8"; 
 24  #       UINT_8 = "uint8"; 
 25  #       INT_16 = "int16"; 
 26  #       UINT_16 = "uint16"; 
 27  #       INT_32 = "int32"; 
 28  #       UINT_32 = "uint32"; 
 29  #       FLOAT = "float"; 
 30  #       DOUBLE = "double"; 
 31  # we can convert these to the appropriate types in python.       
 32  import omero 
 33   
34 -def toPython(pixelType):
35 INT_8 = "int8" 36 UINT_8 = "uint8" 37 INT_16 = "int16" 38 UINT_16 = "uint16" 39 INT_32 = "int32" 40 UINT_32 = "uint32" 41 FLOAT = "float" 42 DOUBLE = "double" 43 if(pixelType==INT_8): 44 return 'b' 45 if(pixelType==UINT_8): 46 return 'c' 47 if(pixelType==INT_16): 48 return 'h' 49 if(pixelType==UINT_16): 50 return 'H' 51 if(pixelType==INT_32): 52 return 'i' 53 if(pixelType==UINT_32): 54 return 'I' 55 if(pixelType==FLOAT): 56 return 'f' 57 if(pixelType==DOUBLE): 58 return 'd'
59
60 -def toArray(pixelType):
61 INT_8 = "int8" 62 UINT_8 = "uint8" 63 INT_16 = "int16" 64 UINT_16 = "uint16" 65 INT_32 = "int32" 66 UINT_32 = "uint32" 67 FLOAT = "float" 68 DOUBLE = "double" 69 if(pixelType==INT_8): 70 return 'b' 71 if(pixelType==UINT_8): 72 return 'B' 73 if(pixelType==INT_16): 74 return 'i2' 75 if(pixelType==UINT_16): 76 return 'H2' 77 if(pixelType==INT_32): 78 return 'i4' 79 if(pixelType==UINT_32): 80 return 'I4' 81 if(pixelType==FLOAT): 82 return 'f' 83 if(pixelType==DOUBLE): 84 return 'd'
85
86 -def toPIL(pixelType):
87 INT_8 = "int8" 88 UINT_8 = "uint8" 89 INT_16 = "int16" 90 UINT_16 = "uint16" 91 INT_32 = "int32" 92 UINT_32 = "uint32" 93 FLOAT = "float" 94 DOUBLE = "double" 95 if(pixelType==INT_8): 96 return 'L' 97 if(pixelType==UINT_8): 98 return 'L' 99 if(pixelType==INT_16): 100 return 'I;16' 101 if(pixelType==UINT_16): 102 return 'I;16' 103 if(pixelType==INT_32): 104 return 'I' 105 if(pixelType==UINT_32): 106 return 'I' 107 if(pixelType==FLOAT): 108 return 'F' 109 if(pixelType==DOUBLE): 110 return 'F'
111