本文整理汇总了Python中pylinac.core.image.Image.check_inversion方法的典型用法代码示例。如果您正苦于以下问题:Python Image.check_inversion方法的具体用法?Python Image.check_inversion怎么用?Python Image.check_inversion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylinac.core.image.Image
的用法示例。
在下文中一共展示了Image.check_inversion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PicketFence
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import check_inversion [as 别名]
#.........这里部分代码省略.........
self.load_image(path)
def run_demo(self, tolerance=0.5):
"""Run the Picket Fence demo using the demo image. See analyze() for parameter info."""
self.load_demo_image()
self.analyze(tolerance)
print(self.return_results())
self.plot_analyzed_image()
def analyze(self, tolerance=0.5, action_tolerance=None, hdmlc=False):
"""Analyze the picket fence image.
Parameters
----------
tolerance : int, float
The tolerance of difference in mm between an MLC pair position and the
picket fit line.
action_tolerance : int, float, None
If None (default), no action tolerance is set or compared to.
If an int or float, the MLC pair measurement is also compared to this
tolerance. Must be lower than tolerance. This value is usually meant
to indicate an "action" is necessary on the part of the physicist to
resolve the issue.
hdmlc : bool
If False (default), a standard (5/10mm leaves) Millennium MLC model is assumed.
If True, an HD (2.5/5mm leaves) Millennium is assumed.
"""
if action_tolerance is not None and tolerance < action_tolerance:
raise ValueError("Tolerance cannot be lower than the action tolerance")
"""Pre-analysis"""
self._clear_attrs()
self._action_lvl = action_tolerance
self.image.check_inversion()
self._threshold()
self._find_orientation()
"""Analysis"""
self._construct_pickets(tolerance, action_tolerance)
leaf_centers = self._find_leaf_centers(hdmlc)
self._calc_mlc_positions(leaf_centers)
self._calc_mlc_error()
def _construct_pickets(self, tolerance, action_tolerance):
"""Construct the Picket instances."""
if self.orientation == orientations['UD']:
leaf_prof = np.median(self._analysis_array, 0)
else:
leaf_prof = np.median(self._analysis_array, 1)
leaf_prof = Profile(leaf_prof)
_, peak_idxs = leaf_prof.find_peaks(min_peak_distance=0.01, min_peak_height=0.5)
for peak in range(len(peak_idxs)):
self.pickets.append(Picket(self.image, tolerance, self.orientation, action_tolerance))
def _find_leaf_centers(self, hdmlc):
"""Return the leaf centers perpendicular to the leaf motion."""
# generate some settings
sm_lf_wdth = 5 * self.image.dpmm
bg_lf_wdth = sm_lf_wdth * 2
if hdmlc:
sm_lf_wdth /= 2
bg_lf_wdth /= 2
self._sm_lf_meas_wdth = slmw = int(round(sm_lf_wdth*3/4))
self._bg_lf_meas_wdth = blmw = int(round(bg_lf_wdth*3/4))
bl_ex = int(bg_lf_wdth/4)
sm_ex = int(sm_lf_wdth/4)
示例2: PicketFence
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import check_inversion [as 别名]
#.........这里部分代码省略.........
"""Return the number of pickets determined."""
return len(self.pickets)
@classmethod
def from_demo_image(cls, filter=None):
"""Construct a PicketFence instance using the demo image.
.. versionadded:: 0.6
"""
obj = cls()
obj.load_demo_image(filter=filter)
return obj
def load_demo_image(self, filter=None):
"""Load the demo image that is included with pylinac."""
im_open_path = osp.join(osp.dirname(__file__), 'demo_files', 'picket_fence', 'EPID-PF-LR.dcm')
self.load_image(im_open_path, filter=filter)
def load_image(self, file_path, filter=None):
"""Load the image
Parameters
----------
file_path : str
Path to the image file.
filter : int, None
If None (default), no filtering will be done to the image.
If an int, will perform median filtering over image of size *filter*.
"""
self.image = Image(file_path)
if isinstance(filter, int):
self.image.median_filter(size=filter)
self._check_for_noise()
self.image.check_inversion()
@classmethod
def from_image_UI(cls, filter=None):
"""Construct a PicketFence instance and load an image using a dialog box.
.. versionadded:: 0.6
"""
obj = cls()
obj.load_image_UI(filter=filter)
return obj
def load_image_UI(self, filter=None):
"""Load the image using a UI dialog box."""
path = get_filepath_UI()
self.load_image(path, filter=filter)
def _check_for_noise(self):
"""Check if the image has extreme noise (dead pixel, etc) by comparing
min/max to 1/99 percentiles and smoothing if need be."""
while self._has_noise():
self.image.median_filter()
def _has_noise(self):
"""Helper method to determine if there is spurious signal in the image."""
min = self.image.array.min()
max = self.image.array.max()
near_min, near_max = np.percentile(self.image.array, [0.5, 99.5])
max_is_extreme = max > near_max * 2
min_is_extreme = (min < near_min) and (abs(near_min - min) > 0.2 * near_max)
return max_is_extreme or min_is_extreme
def _adjust_for_sag(self, sag):
示例3: PicketFence
# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import check_inversion [as 别名]
#.........这里部分代码省略.........
"""Return the number of pickets determined."""
return len(self.pickets)
@classmethod
def from_demo_image(cls, filter=None):
"""Construct a PicketFence instance using the demo image.
.. versionadded:: 0.6
"""
obj = cls()
obj.load_demo_image(filter=filter)
return obj
def load_demo_image(self, filter=None):
"""Load the demo image that is included with pylinac."""
im_open_path = osp.join(osp.dirname(__file__), 'demo_files', 'picket_fence', 'EPID-PF-LR.dcm')
self.load_image(im_open_path, filter=filter)
def load_image(self, file_path, filter=None):
"""Load the image
Parameters
----------
file_path : str
Path to the image file.
filter : int, None
If None (default), no filtering will be done to the image.
If an int, will perform median filtering over image of size *filter*.
"""
self.image = Image(file_path)
if isinstance(filter, int):
self.image.median_filter(size=filter)
self._check_for_noise()
self.image.check_inversion()
@classmethod
def from_image_UI(cls, filter=None):
"""Construct a PicketFence instance and load an image using a dialog box.
.. versionadded:: 0.6
"""
obj = cls()
obj.load_image_UI(filter=filter)
return obj
def load_image_UI(self, filter=None):
"""Load the image using a UI dialog box."""
path = get_filepath_UI()
self.load_image(path, filter=filter)
@classmethod
def from_multiple_images(cls, path_list):
"""Load and superimpose multiple images and instantiate a Starshot object.
.. versionadded:: 0.9
Parameters
----------
path_list : iterable
An iterable of path locations to the files to be loaded/combined.
"""
obj = cls()
obj.load_multiple_images(path_list)
return obj
def load_multiple_images(self, path_list):