Skip to content

Commit 7fdae4e

Browse files
committed
Using sw.Image.toArray() instead of python itk
1 parent 0a8ab76 commit 7fdae4e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Examples/Python/GroomUtils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def FindReferenceImage(inDataList):
121121
"""
122122
x = y = z = 0
123123
for i in range(len(inDataList)):
124-
dim = itk.GetArrayFromImage(itk.imread(inDataList[i])).shape
124+
img = Image(inDataList[i])
125+
tmp = img.toArray()
126+
dim = tmp.shape
125127
if dim[0] > x:
126128
x = dim[0]
127129
if dim[1] > y:
@@ -131,15 +133,17 @@ def FindReferenceImage(inDataList):
131133

132134
COM = np.zeros((x, y, z))
133135
for i in range(len(inDataList)):
134-
tmp = itk.GetArrayFromImage(itk.imread(inDataList[i]))
136+
img = Image(inDataList[i])
137+
tmp = img.toArray()
135138
COM += np.pad(tmp, (((x - tmp.shape[0]) // 2, (x - tmp.shape[0]) - (x - tmp.shape[0]) // 2),
136139
((y - tmp.shape[1]) // 2, (y - tmp.shape[1]) - (y - tmp.shape[1]) // 2),
137140
((z - tmp.shape[2]) // 2, (z - tmp.shape[2]) - (z - tmp.shape[2]) // 2)))
138141
COM /= len(inDataList)
139142
dist = np.inf
140143
idx = 0
141144
for i in range(len(inDataList)):
142-
tmp = itk.GetArrayFromImage(itk.imread(inDataList[i]))
145+
img = Image(inDataList[i])
146+
tmp = img.toArray()
143147
tmp_dist = np.linalg.norm(
144148
COM - np.pad(tmp, (((x - tmp.shape[0]) // 2, (x - tmp.shape[0]) - (x - tmp.shape[0]) // 2),
145149
((y - tmp.shape[1]) // 2, (y - tmp.shape[1]) - (y - tmp.shape[1]) // 2),

0 commit comments

Comments
 (0)