/[escript]/trunk/pyvisi/py_src/imagereader.py
ViewVC logotype

Annotation of /trunk/pyvisi/py_src/imagereader.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (13 years, 3 months ago) by trankine
File MIME type: text/x-python
File size: 2050 byte(s)
And get the *(&(*&(* name right
1 ksteube 1147 """
2 jongui 1197 @var __author__: name of author
3     @var __copyright__: copyrights
4     @var __license__: licence agreement
5     @var __url__: url entry point on documentation
6     @var __version__: version
7     @var __date__: date of the version
8 ksteube 1147 """
9    
10 jongui 1197 __author__="John Ngui, john.ngui@uq.edu.au"
11     __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
12     http://www.access.edu.au
13     Primary Business: Queensland, Australia"""
14     __license__="""Licensed under the Open Software License version 3.0
15     http://www.opensource.org/licenses/osl-3.0.php"""
16     __url__="http://www.iservo.edu.au/esys"
17     __version__="$Revision$"
18     __date__="$Date$"
19    
20    
21 ksteube 1147 import vtk
22     from constant import ImageFormat
23    
24     class ImageReader:
25     """
26     Class that defines an image reader. An image reader is used to read
27     data from an image in a variety of formats.
28     """
29    
30     def __init__(self, format):
31     """
32     Initialise the image reader.
33    
34     @type format: L{ImageFormat <constant.ImageFormat>} constant
35     @param format: Format of the image
36     """
37    
38     self.__format = format
39     self.__vtk_image_reader = self.__getImageReader()
40    
41     def __getImageReader(self):
42     """
43     Return the corresponding image reader based on the supplied image
44     format.
45    
46     @rtype: vtkImageReader2 (i.e. vtkJPEGReader, etc)
47     @return: Image reader
48     """
49    
50     if(self.__format == ImageFormat.JPG):
51     return vtk.vtkJPEGReader()
52     elif(self.__format == ImageFormat.BMP):
53     return vtk.vtkBMPReader()
54     elif(self.__format == ImageFormat.PNM):
55     return vtk.vtkPNMReader()
56     elif(self.__format == ImageFormat.PNG):
57     return vtk.vtkPNGReader()
58     elif(self.__format == ImageFormat.TIF):
59     return vtk.vtkTIFFReader()
60    
61     def setImageName(self, image_name):
62     """
63     Set the image file name to be read.
64    
65     @type image_name: String
66 jongui 1199 @param image_name: Image name from which image data is to be read
67 ksteube 1147 """
68    
69     self.__vtk_image_reader.SetFileName(image_name)
70    
71 jongui 1148 def _getImageReaderOutput(self):
72 ksteube 1147 """
73     Return the output of the image reader.
74    
75     @rtype: vtkImageData
76     @return: Image data
77     """
78    
79     return self.__vtk_image_reader.GetOutput()
80    

  ViewVC Help
Powered by ViewVC 1.1.26