Commit b400736e0a4c282c55546fb75251c56bc7274e1a
1 parent
ede7fa7c
Exists in
master
and in
68 other branches
ADD: Function to cropping vtkImageData
Showing
1 changed file
with
41 additions
and
0 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -54,6 +54,47 @@ class Controller(): |
54 | 54 | if output: |
55 | 55 | #acquisition_modality, tilt_value, orientation,window, level |
56 | 56 | imagedata, dicom = output |
57 | + | |
58 | + import vtk | |
59 | + | |
60 | + fow = vtk.vtkFileOutputWindow () | |
61 | + fow.SetFileName ( 'C:\\vtk_output.txt') | |
62 | + | |
63 | + ow = vtk.vtkOutputWindow () | |
64 | + ow.SetInstance (fow) | |
65 | + | |
66 | + b = imagedata.GetExtent() | |
67 | + | |
68 | + flip = vtk.vtkImageFlip() | |
69 | + flip.SetInput(imagedata) | |
70 | + flip.SetFilteredAxis(1) | |
71 | + flip.FlipAboutOriginOn() | |
72 | + | |
73 | + print b | |
74 | + print "______________" | |
75 | + a = vtk.vtkExtractVOI() | |
76 | + a.SetVOI(b[1]/2,180,135,b[3],b[4],b[5]) #Cond 3 | |
77 | + #a.SetVOI(100,135,b[2],135,b[4],b[5]) Cond 9 | |
78 | + a.SetInput(flip.GetOutput()) | |
79 | + a.Update() | |
80 | + | |
81 | + from data import imagedata_utils | |
82 | + | |
83 | + imagedata_utils.Export(a.GetOutput(), "c:\\cond3") | |
84 | + | |
85 | + c = vtk.vtkContourFilter() | |
86 | + c.SetValue(0,226) | |
87 | + c.SetValue(1,3071) | |
88 | + c.SetInput(a.GetOutput()) | |
89 | + c.Update() | |
90 | + | |
91 | + writer = vtk.vtkSTLWriter() | |
92 | + writer.SetInput(c.GetOutput()) | |
93 | + writer.SetFileTypeToBinary() | |
94 | + writer.SetFileName("c:\\teste.stl") | |
95 | + writer.Write() | |
96 | + | |
97 | + | |
57 | 98 | orientation = dicom.image.orientation_label |
58 | 99 | if (orientation == "CORONAL"): |
59 | 100 | orientation = const.CORONAL | ... | ... |