Skip to content

Commit

Permalink
ITK installed by pip3 on my system does not know 'itk.image_from_arra…
Browse files Browse the repository at this point in the history
…y' and 'itk.array_from_image'
  • Loading branch information
David Boersma committed Nov 22, 2019
1 parent 34a0500 commit e9203a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gatetools/image_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_convert(self):
y = np.arange(-12, 15, 1)
z = np.arange(-13, 10, 1)
xx, yy, zz = np.meshgrid(x, y, z)
image = itk.image_from_array(np.float32(xx))
image = itk.GetImageFromArray(np.float32(xx))
convertedImage = image_convert(image, "unsigned char")
itk.imwrite(convertedImage, "testConvert.mha")
with open("testConvert.mha","rb") as fnew:
Expand Down
10 changes: 5 additions & 5 deletions gatetools/image_crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ def test_auto_crop(self):
image.SetRegions(region)
image.Allocate()
image.FillBuffer(0)
npView = itk.array_from_image(image)
npView = itk.GetArrayFromImage(image)
npView[10:52, 42:192, 124:147] =1
image = itk.image_from_array(npView)
image = itk.GetImageFromArray(npView)
autoCrop = image_auto_crop(image)
autoCropSize = autoCrop.GetLargestPossibleRegion().GetSize()
self.assertTrue(np.allclose(autoCropSize[0], 23))
self.assertTrue(np.allclose(autoCropSize[1], 150))
self.assertTrue(np.allclose(autoCropSize[2], 42))
self.assertTrue(np.allclose(itk.array_from_image(autoCrop)[0, 0, 0], 1))
self.assertTrue(np.allclose(itk.GetArrayFromImage(autoCrop)[0, 0, 0], 1))
def test_crop(self):
x = np.arange(-10, 10, 0.1)
y = np.arange(-12, 15, 0.1)
z = np.arange(-13, 10, 0.1)
xx, yy, zz = np.meshgrid(x, y, z)
image = itk.image_from_array(np.float32(xx))
image = itk.GetImageFromArray(np.float32(xx))
croppedImage = image_crop_with_bb(image, gt.bounding_box(xyz=[10.0, 12.0, 0.0, 7.0, 6.0, 15.0]))
croppedImageSize = croppedImage.GetLargestPossibleRegion().GetSize()
self.assertTrue(np.allclose(croppedImageSize[0], 3))
self.assertTrue(np.allclose(croppedImageSize[1], 8))
self.assertTrue(np.allclose(croppedImageSize[2], 10))
self.assertTrue(np.allclose(itk.array_from_image(croppedImage)[0, 0, 0], -10))
self.assertTrue(np.allclose(itk.GetArrayFromImage(croppedImage)[0, 0, 0], -10))

0 comments on commit e9203a4

Please sign in to comment.