本文整理匯總了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)