Commit 4cf108365d726e33b9364b65221fd04759221398

Authored by Paulo Henrique Junqueira Amorim
1 parent 7f23d9ef

ADD: Reduced Matrix slice by slice

Showing 1 changed file with 11 additions and 16 deletions   Show diff stats
invesalius/reader/dicom_reader.py
... ... @@ -84,14 +84,13 @@ def LoadImages(dir_):
84 84 array = vtk.vtkStringArray()
85 85  
86 86 #Case Reduce Matrix of the Image
87   - flag = 0
88   - reduce_factor = 3
  87 + reduce_matrix = 1
89 88  
90 89 img_app = vtk.vtkImageAppend()
91 90 img_app.SetAppendAxis(2) #Define Stack in Z
92 91  
93 92 for x in xrange(len(files)):
94   - if not(flag):
  93 + if not(reduce_matrix):
95 94 array.InsertValue(x,files[x])
96 95 else:
97 96 #SIf the resolution of the
... ... @@ -100,24 +99,20 @@ def LoadImages(dir_):
100 99 read.SetFileName(files[x])
101 100 read.Update()
102 101  
  102 + #Resample image in x,y dimension
  103 + img = ResampleMatrix(read.GetOutput(), 256)
  104 +
103 105 #Stack images in Z axes
104   - img = ResampleMatrix(read.GetOutput(), reduce_factor)
105 106 img_app.AddInput(img)
106   -
  107 +
  108 + img_app.Update()
107 109 img_axial = vtk.vtkImageData()
108 110  
109   - if (flag):
110   - img_app.Update()
  111 + if (reduce_matrix):
111 112 img_axial.DeepCopy(img_app.GetOutput())
112   -
113   - #TODO: Code challenge (imagedata_utils.ResampleMatrix),
114   - #it is necessary to know the new spacing.
115   - #spacing = read.GetOutput().GetSpacing()
116   - extent = read.GetOutput().GetExtent()
117   - size = read.GetOutput().GetDimensions()
118   - height = float(size[1]/reduce_factor)
119   - resolution = (height/(extent[1]-extent[0])+1)*spacing
120   - img_axial.SetSpacing(spacing, spacing, spacing_z * resolution)
  113 + img_axial.SetSpacing(img_axial.GetSpacing()[0],\
  114 + img_axial.GetSpacing()[1],\
  115 + spacing_z)
121 116 else:
122 117 read = vtkgdcm.vtkGDCMImageReader()
123 118 read.SetFileNames(array)
... ...