/[escript]/temp_trunk_copy/pyvisi/py_src/lookuptable.py
ViewVC logotype

Annotation of /temp_trunk_copy/pyvisi/py_src/lookuptable.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1197 - (hide annotations)
Mon Jun 18 02:08:34 2007 UTC (13 years, 10 months ago) by jongui
Original Path: trunk/pyvisi/py_src/lookuptable.py
File MIME type: text/x-python
File size: 3396 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 ksteube 1147 """
2 jongui 1197 @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 ksteube 1147 """
9    
10 jongui 1197 __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 ksteube 1147 import vtk
22    
23     class LookupTable:
24     """
25     Class that defines a lookup table for mapping scalar values into colors.
26     """
27    
28     def __init__(self):
29     """
30     Initialise the lookup table.
31     """
32    
33     self.__vtk_lookup_table = vtk.vtkLookupTable()
34     self.__vtk_inverse_lookup_table = vtk.vtkLookupTable()
35     self.__build()
36    
37     def __build(self):
38     """
39     Generates the lookup table.
40     """
41    
42     # NOTE: Build have to be executed prior to using SetTableValue (if any).
43     self.__vtk_lookup_table.Build()
44     self.__vtk_inverse_lookup_table.Build()
45    
46     def _setTableValue(self):
47     """
48     Setup the lookup table with colors.
49     """
50    
51     # NOTE: The color values are inversed because VTK's default lookup
52     # table is inversed by itself. SetTableValue have to be executed after
53     # the Build.
54     for i in range(256):
55     self.__vtk_lookup_table.SetTableValue(
56     i, self.__vtk_inverse_lookup_table.GetTableValue(255 - i))
57    
58     def _setLookupTableToGreyScale(self):
59     """
60     Setup the lookup table with grey scale.
61     """
62    
63     self.__setHueRange(0,0)
64     self.__setSaturationRange(0,0)
65     self.__setValueRange(1,0)
66     self.__setNumberOfTableValues(256)
67     self.__setRampToSQRT()
68    
69     def __setValueRange(self, lower_range, upper_range):
70     """
71     Set the value range (brightness) for the lookup table (between 0 and 1).
72    
73     @type lower_range: Number
74     @param lower_range:Lower value range
75     @type upper_range: Number
76     @param upper_range: Upper value range
77     """
78    
79     self.__vtk_lookup_table.SetValueRange(lower_range, upper_range)
80    
81     def __setHueRange(self, lower_range, upper_range):
82     """
83     Set the hue (color) range for the lookup table (between 0 and 1).
84    
85     @type lower_range: Number
86     @param lower_range:Lower hue range
87     @type upper_range: Number
88     @param upper_range: Upper hue range
89     """
90    
91     self.__vtk_lookup_table.SetHueRange(lower_range, upper_range)
92    
93     def __setSaturationRange(self, lower_range, upper_range):
94     """
95     Set the saturation (vibrancy) range for the lookup table \
96     (between 0 and 1).
97    
98     @type lower_range: Number
99     @param lower_range:Lower saturantion range
100     @type upper_range: Number
101     @param upper_range: Upper saturation range
102     """
103    
104     self.__vtk_lookup_table.SetSaturationRange(lower_range, upper_range)
105    
106     def __setRampToSQRT(self):
107     """
108     Set the table ramp to SQRT. The default ramp is S-curve.
109     """
110    
111     self.__vtk_lookup_table.SetRampToSQRT()
112    
113     def __setNumberOfTableValues(self, table_values):
114     """
115     Set the number of values (i.e. colors) in the lookup table.
116    
117     @type table_values: Number
118     @param table_values: Number of colors in the lookup table.
119     """
120    
121     self.__vtk_lookup_table.SetNumberOfTableValues(table_values)
122    
123     def _getLookupTable(self):
124     """
125 jongui 1148 Return the lookup table.
126    
127 ksteube 1147 @rtype: vtkLookupTable
128     @return: Lookup table
129     """
130    
131     return self.__vtk_lookup_table
132 jongui 1189
133 ksteube 1147
134    

  ViewVC Help
Powered by ViewVC 1.1.26