/[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 1078 - (hide annotations)
Thu Apr 5 06:18:47 2007 UTC (13 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 1428 byte(s)
Added and updated some epydocs.
1 jongui 1037 """
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. An image reader is used to read
11     data from an image in a variety of formats.
12     """
13    
14     def __init__(self, format):
15     """
16     Initialise the image reader.
17    
18 jongui 1078 @type format: L{ImageFormat <constant.ImageFormat>} constant
19 jongui 1037 @param format: Format of the image
20     """
21    
22     self.__format = format
23 jongui 1074 self.__vtk_image_reader = self.__getImageReader()
24 jongui 1037
25 jongui 1074 def __getImageReader(self):
26 jongui 1037 """
27     Return the corresponding image reader based on the supplied image
28     format.
29    
30     @rtype: vtkImageReader2 (i.e. vtkJPEGReader, etc)
31     @return: Image reader
32     """
33    
34     if(self.__format == ImageFormat.JPG):
35     return vtk.vtkJPEGReader()
36     elif(self.__format == ImageFormat.BMP):
37     return vtk.vtkBMPReader()
38     elif(self.__format == ImageFormat.PNM):
39     return vtk.vtkPNMReader()
40     elif(self.__format == ImageFormat.PNG):
41     return vtk.vtkPNGReader()
42     elif(self.__format == ImageFormat.TIF):
43     return vtk.vtkTIFFReader()
44    
45     def setImageName(self, image_name):
46     """
47     Set the image file name to be read.
48    
49     @type image_name: String
50     @param image_name: Image name from which data is to be read
51     """
52    
53     self.__vtk_image_reader.SetFileName(image_name)
54    
55     def _getOutput(self):
56     """
57     Return the output of the image reader.
58    
59     @rtype: vtkImageData
60     @return: Image Data
61     """
62    
63     return self.__vtk_image_reader.GetOutput()
64    

  ViewVC Help
Powered by ViewVC 1.1.26