/[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 1197 - (show annotations)
Mon Jun 18 02:08:34 2007 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 2044 byte(s)
Update the way movies are generated. Please refer to the examples. 

The user can now either specify the image range(first and last images inclusive):
mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
        first_image = IMAGE_NAME + "000938.jpg",
		last_image = IMAGE_NAME + "000948.jpg")
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))

or the user can specify a list of images:

lst = ['image1.jpg', 'image5.jpg', 'image7.jpg]
mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))


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 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