/[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 943 - (show annotations)
Mon Jan 29 07:22:43 2007 UTC (14 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 1257 byte(s)
new pyvisi files
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6 from constant import ImageFormat
7
8 class ImageReader:
9 """
10 Class that defines an image reader.
11 """
12
13 def __init__(self, format):
14 """
15 Initialise the image reader.
16
17 @type format: String
18 @param format: Format of the image
19 """
20 print "Imgae Reader"
21 self.__format = format
22 self.__vtk_image_reader = self.getImageReader()
23
24 def getImageReader(self):
25 """
26 Return the corresponding image reader based on the supplied image
27 format.
28
29 @rtype: vtkImageReader2 (i.e. vtkJPEGReader, etc)
30 @return: Image reader
31 """
32
33 if(self.__format == ImageFormat.JPG):
34 return vtk.vtkJPEGReader()
35 elif(self.__format == ImageFormat.BMP):
36 return vtk.vtkBMPReader()
37 elif(self.__format == ImageFormat.PNM):
38 return vtk.vtkPNMReader()
39 elif(self.__format == ImageFormat.PNG):
40 return vtk.vtkPNGReader()
41 elif(self.__format == ImageFormat.TIF):
42 return vtk.vtkTIFFReader()
43
44 def setFileName(self, file_name):
45 """
46 @type file_name: String
47 @param file_name: Image file name from which data is to be read
48 """
49 print "image reader set file name"
50 self.__vtk_image_reader.SetFileName(file_name)
51
52 def _getOutput(self):
53 print "return image reader..."
54 return self.__vtk_image_reader.GetOutput()
55

  ViewVC Help
Powered by ViewVC 1.1.26