1 |
""" |
2 |
@author: John NGUI |
3 |
""" |
4 |
|
5 |
import vtk |
6 |
|
7 |
class ImageReslice: |
8 |
""" |
9 |
Class that defines an image reslice used to resize static |
10 |
(no interaction capability) images. |
11 |
""" |
12 |
|
13 |
def __init__(self): |
14 |
""" |
15 |
Initialise the image reslice. |
16 |
""" |
17 |
|
18 |
self.__vtk_image_reslice = vtk.vtkImageReslice() |
19 |
|
20 |
def _setupImageReslice(self, object): |
21 |
""" |
22 |
Setup the image reslice. |
23 |
|
24 |
@type object: vtkImageData |
25 |
@param object: Image Data |
26 |
""" |
27 |
|
28 |
self.__object = object |
29 |
self.__setInput() |
30 |
|
31 |
def __setInput(self): |
32 |
""" |
33 |
Set the input for the image reslice. |
34 |
""" |
35 |
|
36 |
self.__vtk_image_reslice.SetInput(self.__object) |
37 |
|
38 |
def setSize(self, size): |
39 |
""" |
40 |
Set the size of the image, between 0 and 2. Size 1 (one) displays the |
41 |
image in its original size (which is the default). |
42 |
|
43 |
@type size: Number |
44 |
@param size: Size of the static image |
45 |
""" |
46 |
|
47 |
# By default, with image reslice, the larger the output spacing, the |
48 |
# smaller the image. Similarly, the smaller the output spacing, the |
49 |
# larger the image. This behaviour is reversed so that the larger the |
50 |
# size the image. Similarly, the smaller the size, the smaller the |
51 |
# image. |
52 |
if(size > 1): |
53 |
size = 1 - (size - 1) |
54 |
self.__vtk_image_reslice.SetOutputSpacing(size, size, size) |
55 |
elif(size < 1): |
56 |
size = (1 - size) + 1 |
57 |
self.__vtk_image_reslice.SetOutputSpacing(size, size, size) |
58 |
|
59 |
def _getImageResliceOutput(self): |
60 |
""" |
61 |
Return the output of the image reslice. |
62 |
|
63 |
@rtype: vtkImageData |
64 |
@return: Image data |
65 |
""" |
66 |
|
67 |
return self.__vtk_image_reslice.GetOutput() |