Skip to content

Commit

Permalink
Merge pull request #1180 from SCIInstitute/fix_1179
Browse files Browse the repository at this point in the history
Fix for #1179
  • Loading branch information
akenmorris committed Mar 30, 2021
2 parents 4dd0ecc + 7fdae4e commit e839d2d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Examples/Python/GroomUtils.py
Expand Up @@ -121,7 +121,9 @@ def FindReferenceImage(inDataList):
"""
x = y = z = 0
for i in range(len(inDataList)):
dim = itk.GetArrayFromImage(itk.imread(inDataList[i])).shape
img = Image(inDataList[i])
tmp = img.toArray()
dim = tmp.shape
if dim[0] > x:
x = dim[0]
if dim[1] > y:
Expand All @@ -131,15 +133,17 @@ def FindReferenceImage(inDataList):

COM = np.zeros((x, y, z))
for i in range(len(inDataList)):
tmp = itk.GetArrayFromImage(itk.imread(inDataList[i]))
img = Image(inDataList[i])
tmp = img.toArray()
COM += np.pad(tmp, (((x - tmp.shape[0]) // 2, (x - tmp.shape[0]) - (x - tmp.shape[0]) // 2),
((y - tmp.shape[1]) // 2, (y - tmp.shape[1]) - (y - tmp.shape[1]) // 2),
((z - tmp.shape[2]) // 2, (z - tmp.shape[2]) - (z - tmp.shape[2]) // 2)))
COM /= len(inDataList)
dist = np.inf
idx = 0
for i in range(len(inDataList)):
tmp = itk.GetArrayFromImage(itk.imread(inDataList[i]))
img = Image(inDataList[i])
tmp = img.toArray()
tmp_dist = np.linalg.norm(
COM - np.pad(tmp, (((x - tmp.shape[0]) // 2, (x - tmp.shape[0]) - (x - tmp.shape[0]) // 2),
((y - tmp.shape[1]) // 2, (y - tmp.shape[1]) - (y - tmp.shape[1]) // 2),
Expand Down

0 comments on commit e839d2d

Please sign in to comment.