本文整理匯總了Python中pylinac.core.image.Image.roll方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.roll方法的具體用法?Python Image.roll怎麽用?Python Image.roll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylinac.core.image.Image
的用法示例。
在下文中一共展示了Image.roll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PicketFence
# 需要導入模塊: from pylinac.core.image import Image [as 別名]
# 或者: from pylinac.core.image.Image import roll [as 別名]
#.........這裏部分代碼省略.........
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):
"""Roll the image to adjust for EPID sag."""
sag_pixels = int(round(sag * self.settings.dpmm))
direction = 'y' if self.orientation == orientations['UD'] else 'x'
self.image.roll(direction, sag_pixels)
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, num_pickets=None, sag_adjustment=0):
"""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 that a physicist should take an "action" to reduce the error,
but should not stop treatment.
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.
num_pickets : int, None
.. versionadded:: 0.8
The number of pickets in the image. A helper parameter to limit the total number of pickets,
only needed if analysis is catching things that aren't pickets.
sag_adjustment : float, int
示例2: PicketFence
# 需要導入模塊: from pylinac.core.image import Image [as 別名]
# 或者: from pylinac.core.image.Image import roll [as 別名]
#.........這裏部分代碼省略.........
def load_multiple_images(self, path_list):
"""Load and superimpose multiple images.
.. versionadded:: 0.9
Parameters
----------
path_list : iterable
An iterable of path locations to the files to be loaded/combined.
"""
self.image = Image.from_multiples(path_list, method='mean')
self._check_for_noise()
self.image.check_inversion()
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):
"""Roll the image to adjust for EPID sag."""
sag_pixels = int(round(sag * self.settings.dpmm))
direction = 'y' if self.orientation == orientations['UD'] else 'x'
self.image.roll(direction, sag_pixels)
def run_demo(self, tolerance=0.5, action_tolerance=0.25, interactive=False):
"""Run the Picket Fence demo using the demo image. See analyze() for parameter info."""
self.load_demo_image()
self.analyze(tolerance, action_tolerance=action_tolerance)
print(self.return_results())
self.plot_analyzed_image(interactive=interactive, leaf_error_subplot=True)
def analyze(self, tolerance=0.5, action_tolerance=None, hdmlc=False, num_pickets=None, sag_adjustment=0):
"""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 that a physicist should take an "action" to reduce the error,
but should not stop treatment.
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.
num_pickets : int, None
.. versionadded:: 0.8
The number of pickets in the image. A helper parameter to limit the total number of pickets,
only needed if analysis is catching more pickets than there really are.
sag_adjustment : float, int