Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 86 lines (64 sloc) 2.812 kB
94a4f96 Added possibility of segmenting with levelsets at different resolutio…
lucantiga authored
1 #!/usr/bin/env python
2
3 ## Program: VMTK
4 ## Module: $RCSfile: vmtkimagecompose.py,v $
5 ## Language: Python
6 ## Date: $Date: 2006/07/17 09:53:14 $
7 ## Version: $Revision: 1.8 $
8
9 ## Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 ## See LICENCE file for details.
11
12 ## This software is distributed WITHOUT ANY WARRANTY; without even
13 ## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 ## PURPOSE. See the above copyright notices for more information.
15
16
17 import vtk
18 import sys
19
20 import pypes
21
22 vmtkimagecompose = 'vmtkImageCompose'
23
24 class vmtkImageCompose(pypes.pypeScript):
25
26 def __init__(self):
27
28 pypes.pypeScript.__init__(self)
29
30 self.Image = None
31 self.Image2 = None
32 self.Operation = 'min'
7c9a6a9 Added feature image correction. Factored initialization out of levelsets
lucantiga authored
33 self.NegateImage2 = False
94a4f96 Added possibility of segmenting with levelsets at different resolutio…
lucantiga authored
34
35 self.SetScriptName('vmtkimagecompose')
36 self.SetScriptDoc('compose an image based on user-specified parameters or on a reference image')
37 self.SetInputMembers([
cbda38c Several improvements to PypeS for better Slicer3 integration and vmtk…
lucantiga authored
38 ['Image','i','vtkImageData',1,'','the input image','vmtkimagereader'],
39 ['Image2','i2','vtkImageData',1,'','the second input image','vmtkimagereader'],
63443cc Improved vessel enhancing diffusion. Added network analysis.
lucantiga authored
40 ['Operation','operation','str',1,'["min","max","multiply","subtract"]','the operation used to compose images'],
7c9a6a9 Added feature image correction. Factored initialization out of levelsets
lucantiga authored
41 ['NegateImage2','negatei2','bool',1,'','negate the second input before composing']
94a4f96 Added possibility of segmenting with levelsets at different resolutio…
lucantiga authored
42 ])
43 self.SetOutputMembers([
cbda38c Several improvements to PypeS for better Slicer3 integration and vmtk…
lucantiga authored
44 ['Image','o','vtkImageData',1,'','the output image','vmtkimagewriter']
94a4f96 Added possibility of segmenting with levelsets at different resolutio…
lucantiga authored
45 ])
46
47 def Execute(self):
48
49 if self.Image == None:
50 self.PrintError('Error: No input image.')
51
52 if self.Image2 == None:
53 self.PrintError('Error: No input image2.')
54
7c9a6a9 Added feature image correction. Factored initialization out of levelsets
lucantiga authored
55 if self.NegateImage2:
56 negateFilter = vtk.vtkImageMathematics()
57 negateFilter.SetInput(self.Image2)
58 negateFilter.SetOperationToMultiplyByK()
dd4ee4a Added meshing with boundary layer. Fixed bug in vmtkimagecompose
lucantiga authored
59 negateFilter.SetConstantK(-1.0)
7c9a6a9 Added feature image correction. Factored initialization out of levelsets
lucantiga authored
60 negateFilter.Update()
61 self.Image2 = negateFilter.GetOutput()
62
94a4f96 Added possibility of segmenting with levelsets at different resolutio…
lucantiga authored
63 composeFilter = vtk.vtkImageMathematics()
64 composeFilter.SetInput1(self.Image)
65 composeFilter.SetInput2(self.Image2)
66 if self.Operation == 'min':
67 composeFilter.SetOperationToMin()
68 elif self.Operation == 'max':
69 composeFilter.SetOperationToMax()
bf25b92 Added image multiplication in compose
lucantiga authored
70 elif self.Operation == 'multiply':
71 composeFilter.SetOperationToMultiply()
63443cc Improved vessel enhancing diffusion. Added network analysis.
lucantiga authored
72 elif self.Operation == 'subtract':
73 composeFilter.SetOperationToSubtract()
94a4f96 Added possibility of segmenting with levelsets at different resolutio…
lucantiga authored
74 else:
75 self.PrintError('Error: Unsupported operation')
76 composeFilter.Update()
77
78 self.Image = composeFilter.GetOutput()
79
80
81 if __name__=='__main__':
82
83 main = pypes.pypeMain()
84 main.Arguments = sys.argv
85 main.Execute()
Something went wrong with that request. Please try again.