本文整理匯總了Python中pylinac.core.image.Image.ground方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.ground方法的具體用法?Python Image.ground怎麽用?Python Image.ground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylinac.core.image.Image
的用法示例。
在下文中一共展示了Image.ground方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Test_Image_Methods
# 需要導入模塊: from pylinac.core.image import Image [as 別名]
# 或者: from pylinac.core.image.Image import ground [as 別名]
class Test_Image_Methods(unittest.TestCase):
def setUp(self):
self.img = Image(img_path)
self.dcm = Image(dcm_path)
small_array = np.arange(42).reshape(6,7)
self.sm_arr = Image.from_array(small_array)
def test_remove_edges(self):
"""Remove the edges from a pixel array."""
crop = 15
orig_shape = self.img.shape
orig_dpi = self.img.dpi
self.img.remove_edges(crop)
new_shape = self.img.shape
new_dpi = self.img.dpi
self.assertEqual(new_shape[0]+crop*2, orig_shape[0])
# ensure original metadata is still the same
self.assertEqual(new_dpi, orig_dpi)
def test_median_filter(self):
filter_size = 3
self.sm_arr.median_filter(filter_size)
self.assertEqual(self.sm_arr.array[0, 0], 1)
filter_size = 0.03
self.sm_arr.median_filter(filter_size)
self.assertRaises(ValueError, self.img.median_filter, 1.1)
def test_ground(self):
old_min_val = copy.copy(self.dcm.array.min())
ground_val = self.dcm.ground()
self.assertEqual(old_min_val, ground_val)
# test that array was also changed
self.assertAlmostEqual(self.dcm.array.min(), 0)
def test_resize(self):
new_size = (200, 300)
self.img.resize(new_size)
self.assertEqual(self.img.shape, new_size)
def test_invert(self):
self.img.invert()
def test_dist2edge_min(self):
dist = self.sm_arr.dist2edge_min(Point(1,3))
self.assertEqual(dist, 1)
dist = self.sm_arr.dist2edge_min((1,3))
self.assertEqual(dist, 1)
def test_center(self):
self.assertIsInstance(self.img.center, Point)
img_known_center = Point(512, 1702)
dcm_known_center = Point(512, 384)
self.assertEqual(self.img.center.x, img_known_center.x)
self.assertEqual(self.dcm.center.y, dcm_known_center.y)
def test_SID(self):
self.assertEqual(self.dcm.SID, 1050)
self.assertRaises(TypeError, setattr, self.dcm, 'SID', '105')
def test_combine_multiples(self):
bad_img_path = [dcm_path, img_path]
self.assertRaises(AttributeError, Image.from_multiples, bad_img_path)
good_img_path = [img_path, img_path]
combined_img = Image.from_multiples(good_img_path)
self.assertIsInstance(combined_img, Image)
def test_plot(self):
self.img.plot() # shouldn't raise