/[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 948 - (show annotations)
Thu Feb 1 07:23:34 2007 UTC (13 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 1306 byte(s)
fixed some bugs in pyvisi and added more epydocs.
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
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 Set the image file name to be read.
47
48 @type file_name: String
49 @param file_name: Image file name from which data is to be read
50 """
51
52 self.__vtk_image_reader.SetFileName(file_name)
53
54 def _getOutput(self):
55 """
56 Return the output of hte image reader.
57
58 @rtype: vtkImageData
59 @return: Image Data
60 """
61
62 return self.__vtk_image_reader.GetOutput()
63

  ViewVC Help
Powered by ViewVC 1.1.26