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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (show annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 2050 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 """
2 @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 """
9
10 __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 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 @param image_name: Image name from which image data is to be read
67 """
68
69 self.__vtk_image_reader.SetFileName(image_name)
70
71 def _getImageReaderOutput(self):
72 """
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