/[escript]/tags/trunk_2172_checkpoint/pyvisi/py_src/imagereader.py
ViewVC logotype

Contents of /tags/trunk_2172_checkpoint/pyvisi/py_src/imagereader.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2175 - (show annotations)
Wed Dec 17 09:22:40 2008 UTC (12 years, 2 months ago) by phornby
File MIME type: text/x-python
File size: 2443 byte(s)
Try again at conforming to naming convention.
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="http://www.uq.edu.au/esscc/escript-finley"
21
22 """
23 @var __author__: name of author
24 @var __copyright__: copyrights
25 @var __license__: licence agreement
26 @var __url__: url entry point on documentation
27 @var __version__: version
28 @var __date__: date of the version
29 """
30
31 __author__="John Ngui, john.ngui@uq.edu.au"
32
33 import vtk
34 from constant import ImageFormat
35
36 class ImageReader:
37 """
38 Class that defines an image reader. An image reader is used to read
39 data from an image in a variety of formats.
40 """
41
42 def __init__(self, format):
43 """
44 Initialise the image reader.
45
46 @type format: L{ImageFormat <constant.ImageFormat>} constant
47 @param format: Format of the image
48 """
49
50 self.__format = format
51 self.__vtk_image_reader = self.__getImageReader()
52
53 def __getImageReader(self):
54 """
55 Return the corresponding image reader based on the supplied image
56 format.
57
58 @rtype: vtkImageReader2 (i.e. vtkJPEGReader, etc)
59 @return: Image reader
60 """
61
62 if(self.__format == ImageFormat.JPG):
63 return vtk.vtkJPEGReader()
64 elif(self.__format == ImageFormat.BMP):
65 return vtk.vtkBMPReader()
66 elif(self.__format == ImageFormat.PNM):
67 return vtk.vtkPNMReader()
68 elif(self.__format == ImageFormat.PNG):
69 return vtk.vtkPNGReader()
70 elif(self.__format == ImageFormat.TIF):
71 return vtk.vtkTIFFReader()
72
73 def setImageName(self, image_name):
74 """
75 Set the image file name to be read.
76
77 @type image_name: String
78 @param image_name: Image name from which image data is to be read
79 """
80
81 self.__vtk_image_reader.SetFileName(image_name)
82
83 def _getImageReaderOutput(self):
84 """
85 Return the output of the image reader.
86
87 @rtype: vtkImageData
88 @return: Image data
89 """
90
91 return self.__vtk_image_reader.GetOutput()
92

  ViewVC Help
Powered by ViewVC 1.1.26