当前位置: 首页>>代码示例>>Python>>正文


Python Image.load方法代码示例

本文整理汇总了Python中pylinac.core.image.Image.load方法的典型用法代码示例。如果您正苦于以下问题:Python Image.load方法的具体用法?Python Image.load怎么用?Python Image.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylinac.core.image.Image的用法示例。


在下文中一共展示了Image.load方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_all

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def test_all(self):
     futures = []
     start = time.time()
     with concurrent.futures.ProcessPoolExecutor() as exec:
         for pdir, sdir, files in os.walk(self.image_bank_dir):
             for file in files:
                 filepath = osp.join(pdir, file)
                 try:
                     Image.load(filepath)
                 except:
                     pass
                 else:
                     future = exec.submit(run_star, filepath)
                     futures.append(future)
         for future in concurrent.futures.as_completed(futures):
             print(future.result())
     end = time.time() - start
     print('Processing of {} files took {}s'.format(len(futures), end))
开发者ID:darcymason,项目名称:pylinac,代码行数:20,代码来源:_test_all_starshots.py

示例2: load_image

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
    def load_image(self, filepath):
        """Load the image via the file path.

        Parameters
        ----------
        filepath : str
            Path to the file to be loaded.
        """
        self.image = Image.load(filepath)
开发者ID:darcymason,项目名称:pylinac,代码行数:11,代码来源:starshot.py

示例3: _find_bb

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
    def _find_bb(self):
        """Find the BB within the radiation field. Iteratively searches for a circle-like object
        by lowering a low-pass threshold value until found.

        Returns
        -------
        Point
            The weighted-pixel value location of the BB.
        """

        def is_boxlike(array):
            """Whether the binary object's dimensions are symmetric, i.e. box-like"""
            ymin, ymax, xmin, xmax = get_bounding_box(array)
            y = abs(ymax - ymin)
            x = abs(xmax - xmin)
            if x > max(y * 1.05, y+3) or x < min(y * 0.95, y-3):
                return False
            return True

        # get initial starting conditions
        hmin = np.percentile(self.array, 5)
        hmax = self.array.max()
        spread = hmax - hmin
        max_thresh = hmax

        # search for the BB by iteratively lowering the low-pass threshold value until the BB is found.
        found = False
        while not found:
            try:
                lower_thresh = hmax - spread / 2
                t = np.where((max_thresh > self) & (self >= lower_thresh), 1, 0)
                labeled_arr, num_roi = ndimage.measurements.label(t)
                roi_sizes, bin_edges = np.histogram(labeled_arr, bins=num_roi + 1)
                bw_node_cleaned = np.where(labeled_arr == np.argsort(roi_sizes)[-3], 1, 0)
                expected_fill_ratio = np.pi / 4
                actual_fill_ratio = get_filled_area_ratio(bw_node_cleaned)
                if (expected_fill_ratio * 1.1 < actual_fill_ratio) or (actual_fill_ratio < expected_fill_ratio * 0.9):
                    raise ValueError
                if not is_boxlike(bw_node_cleaned):
                    raise ValueError
            except (IndexError, ValueError):
                max_thresh -= 0.05 * spread
                if max_thresh < hmin:
                    raise ValueError("Unable to locate the BB")
            else:
                found = True

        # determine the center of mass of the BB
        inv_img = Image.load(self.array)
        inv_img.invert()
        x_arr = np.abs(np.average(bw_node_cleaned, weights=inv_img, axis=0))
        x_com = SingleProfile(x_arr).fwxm_center(interpolate=True)
        y_arr = np.abs(np.average(bw_node_cleaned, weights=inv_img, axis=1))
        y_com = SingleProfile(y_arr).fwxm_center(interpolate=True)
        return Point(x_com, y_com)
开发者ID:darcymason,项目名称:pylinac,代码行数:57,代码来源:winston_lutz.py

示例4: __init__

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def __init__(self, filepath=None):
     """
     Parameters
     ----------
     filepath : None, str
         If None, image must be loaded later.
         If a str, path to the image file.
     """
     if filepath is not None and is_valid_file(filepath):
         self.image = Image.load(filepath)
     else:
         self.image = np.zeros((1,1))
开发者ID:darcymason,项目名称:pylinac,代码行数:14,代码来源:flatsym.py

示例5: load_image

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
    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.load(file_path)
        if isinstance(filter, int):
            self.image.median_filter(size=filter)
        self._check_for_noise()
        self.image.check_inversion()
开发者ID:darcymason,项目名称:pylinac,代码行数:18,代码来源:picketfence.py

示例6: load_image

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
    def load_image(self, file_path, im_type=None):
        """Load the image directly by the file path.

        Parameters
        ----------
        file_path : str, file-like object
            The path to the DICOM image or I/O stream.
        im_type : {'open', 'mlcs', None}
            Specifies what image type is being loaded in. If None, will try to determine the type from the name.
            The name must have 'open' or 'dmlc' in the name.
        """
        img = Image.load(file_path)
        if im_type is not None:
            if _is_open_type(im_type):
                self.image_open = img
            elif _is_dmlc_type(im_type):
                self.image_dmlc = img
        else:
            # try to guess type by the name
            imtype = self._try_to_guess_image_type(osp.basename(file_path))
            if imtype is not None:
                self.load_image(file_path, imtype)
            else:
                raise ValueError("Image type was not given nor could it be determined from the path name. Please enter and image type.")
开发者ID:darcymason,项目名称:pylinac,代码行数:26,代码来源:vmat.py

示例7: load_demo_image

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def load_demo_image(self):
     """Load the demo image."""
     demo_file = osp.join(osp.dirname(__file__), 'demo_files', 'flatsym', 'flatsym_demo.dcm')
     self.image = Image.load(demo_file)
开发者ID:darcymason,项目名称:pylinac,代码行数:6,代码来源:flatsym.py

示例8: setUpClass

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def setUpClass(cls):
     image = Image.load(cls.image_file_location)
     cls.profile = cls.klass(cls.center_point, cls.radius, image.array)
开发者ID:vandonova,项目名称:amazon_art,代码行数:5,代码来源:test_profile.py

示例9: setUp

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def setUp(self):
     self.img = Image.load(tif_path)
     self.dcm = Image.load(dcm_path)
     array = np.arange(42).reshape(6, 7)
     self.arr = Image.load(array)
开发者ID:darcymason,项目名称:pylinac,代码行数:7,代码来源:test_image.py

示例10: test_nonsense

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def test_nonsense(self):
     with self.assertRaises(TypeError):
         Image.load('blahblah')
开发者ID:darcymason,项目名称:pylinac,代码行数:5,代码来源:test_image.py

示例11: test_array

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def test_array(self):
     arr = np.arange(36).reshape(6, 6)
     img = Image.load(arr)
     self.assertIsInstance(img, ArrayImage)
开发者ID:darcymason,项目名称:pylinac,代码行数:6,代码来源:test_image.py

示例12: test_file

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def test_file(self):
     img = Image.load(tif_path)
     self.assertIsInstance(img, FileImage)
开发者ID:darcymason,项目名称:pylinac,代码行数:5,代码来源:test_image.py

示例13: test_dicom

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def test_dicom(self):
     img = Image.load(dcm_path)
     self.assertIsInstance(img, DicomImage)
开发者ID:darcymason,项目名称:pylinac,代码行数:5,代码来源:test_image.py

示例14: setUpClass

# 需要导入模块: from pylinac.core.image import Image [as 别名]
# 或者: from pylinac.core.image.Image import load [as 别名]
 def setUpClass(cls):
     cls.dcm = Image.load(dcm_path)
开发者ID:darcymason,项目名称:pylinac,代码行数:4,代码来源:test_image.py


注:本文中的pylinac.core.image.Image.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。