本文整理汇总了Python中pylinac.core.image.Image.from_array方法的典型用法代码示例。如果您正苦于以下问题:Python Image.from_array方法的具体用法?Python Image.from_array怎么用?Python Image.from_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylinac.core.image.Image
的用法示例。
在下文中一共展示了Image.from_array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _find_HU_slice
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import from_array [as 别名]
def _find_HU_slice(self):
"""Using a brute force search of the images, find the median HU linearity slice.
This method walks through all the images and takes a collapsed circle profile where the HU
linearity ROIs are. If the profile contains both low (<800) and high (>800) HU values and most values are the same
(i.e. its not an artifact, then
it can be assumed it is an HU linearity slice. The median of all applicable slices is the
center of the HU slice.
Returns
-------
int
The middle slice of the HU linearity module.
"""
hu_slices = []
for image_number in range(self.num_images):
image = self.images[:, :, image_number]
slice = Slice(self, Image.from_array(image))
try:
slice.find_phan_center()
except ValueError: # a slice without the phantom in view
continue
else:
circle_prof = CollapsedCircleProfile(slice.phan_center, radius=120/self.fov_ratio)
circle_prof.get_profile(image, width_ratio=0.05, num_profiles=5)
prof = circle_prof.y_values
# determine if the profile contains both low and high values and that most values are the same
if (np.percentile(prof, 2) < 800) and (np.percentile(prof, 98) > 800) and (np.percentile(prof, 80) - np.percentile(prof, 30) < 40):
hu_slices.append(image_number)
center_hu_slice = int(np.median(hu_slices))
return center_hu_slice
示例2: __init__
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import from_array [as 别名]
def __init__(self, settings):
super().__init__(settings)
self.scale_by_FOV()
self.image = Image.from_array(combine_surrounding_slices(self.settings.images, self.settings.SR_slice_num, mode='max'))
self.LP_MTF = OrderedDict() # holds lp:mtf data
for idx, radius in enumerate(self.radius2profs):
c = SR_Circle_ROI(idx, self.image.array, radius=radius)
self.add_ROI(c)
super().find_phan_center()
示例3: test_open
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import from_array [as 别名]
def test_open(self):
"""Test the open class method."""
# load a tif file
img = Image(img_path)
self.assertEqual(img.im_type, IMAGE)
# load a dicom file
img2 = Image(dcm_path)
self.assertEqual(img2.im_type, DICOM)
# try loading a bad file
bad_file = osp.abspath(__file__)
self.assertRaises(TypeError, Image, bad_file)
# not a valid parameter
bad_input = 3.5
self.assertRaises(TypeError, Image, bad_input)
# load an array
dcm = dicom.read_file(dcm_path)
img = Image.from_array(dcm.pixel_array)
self.assertEqual(img.im_type, ARRAY)
示例4: setUp
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import from_array [as 别名]
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)