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


Python SimpleITK.sitkUInt8方法代码示例

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


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

示例1: write_mask

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import sitkUInt8 [as 别名]
def write_mask(
        mask_sitk,
        path_to_file,
        compress=True,
        verbose=True,
        description=None,
    ):
        info = "Write mask to %s" % path_to_file
        if compress:
            mask_sitk = sitk.Cast(mask_sitk, sitk.sitkUInt8)
            info += " (uint8)"
        if verbose:
            ph.print_info("%s ... " % info, newline=False)
        header_update = DataWriter._get_header_update(description=description)

        sitkh.write_nifti_image_sitk(
            mask_sitk, path_to_file, header_update=header_update)
        if verbose:
            print("done") 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:21,代码来源:data_writer.py

示例2: preparetraindata

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import sitkUInt8 [as 别名]
def preparetraindata():
    for i in range(0, 131, 1):
        seg = sitk.ReadImage("D:\Data\LIST\src_data\segmentation-" + str(i) + ".nii", sitk.sitkUInt8)
        segimg = sitk.GetArrayFromImage(seg)
        src = load_itk("D:\Data\LIST\src_data\\volume-" + str(i) + ".nii")
        srcimg = sitk.GetArrayFromImage(src)

        seg_liverimage = segimg.copy()
        seg_liverimage[segimg > 0] = 255

        seg_tumorimage = segimg.copy()
        seg_tumorimage[segimg == 1] = 0
        seg_tumorimage[segimg == 2] = 255
        gen_image_mask(srcimg, seg_liverimage, i, shape=(16, 256, 256), numberxy=5, numberz=10)
	# gen_image_mask(srcimg, seg_tumorimage, i, shape=(16, 256, 256), numberxy=5, numberz=10) 
开发者ID:junqiangchen,项目名称:LiTS---Liver-Tumor-Segmentation-Challenge,代码行数:17,代码来源:getPatchImageAndMask.py

示例3: run

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import sitkUInt8 [as 别名]
def run(self):

        # create zero image
        coverage_sitk = sitk.Image(self._reconstruction_sitk) * 0

        for i, stack in enumerate(self._stacks):
            print("Slices of stack %d/%d ... " % (i + 1, len(self._stacks)))

            # Add each individual slice contribution
            for slice in stack.get_slices():
                coverage_sitk = self._add_slice_contribution(
                    slice, coverage_sitk)

        # Cast to unsigned integer
        self._coverage_sitk = sitk.Cast(coverage_sitk, sitk.sitkUInt8)

    ##
    # Adds a slice contribution.
    # \date       2019-02-23 21:27:12+0000
    #
    # \param      slice          Slice as sl.Slice object
    # \param      coverage_sitk  sitk.Image reflecting the current iteration of
    #                            slice coverage
    #
    # \return     Updated slice contribution, sitk.Image
    # 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:28,代码来源:slice_coverage.py

示例4: _compute_volume

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import sitkUInt8 [as 别名]
def _compute_volume(file_path):
        mask_sitk = sitkh.read_nifti_image_sitk(str(file_path), sitk.sitkUInt8)

        # Compute mask volume
        mask_nda = sitk.GetArrayFromImage(mask_sitk)
        spacing = np.array(mask_sitk.GetSpacing())
        volume = np.sum(mask_nda) * spacing.prod()

        return volume 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:11,代码来源:target_stack_estimator.py

示例5: background_to_zero

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import sitkUInt8 [as 别名]
def background_to_zero(in_file, background_file, out_file):
    sitk.WriteImage(sitk.Mask(sitk.ReadImage(in_file), sitk.ReadImage(background_file, sitk.sitkUInt8) == 0),
                    out_file)
    return out_file 
开发者ID:ellisdg,项目名称:3DUnetCNN,代码行数:6,代码来源:preprocess.py

示例6: _run_bet_for_brain_stripping

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import sitkUInt8 [as 别名]
def _run_bet_for_brain_stripping(self, debug=0):

        filename_out = "image"

        self._dir_tmp = ph.create_directory(self._dir_tmp, delete_files=True)

        path_to_image = os.path.join(
            self._dir_tmp, filename_out + ".nii.gz")
        path_to_res = os.path.join(
            self._dir_tmp, filename_out + "_bet.nii.gz")
        path_to_res_mask = os.path.join(
            self._dir_tmp, filename_out + "_bet_mask.nii.gz")
        path_to_res_skull = os.path.join(
            self._dir_tmp, filename_out + "_bet_skull.nii.gz")

        sitkh.write_nifti_image_sitk(self._sitk, path_to_image)

        bet = nipype.interfaces.fsl.BET()
        bet.inputs.in_file = path_to_image
        bet.inputs.out_file = path_to_res

        options = ""
        if not self._compute_brain_image:
            options += "-n "

        if self._compute_brain_mask:
            options += "-m "

        if self._compute_skull_image:
            options += "-s "

        options += self._bet_options
        bet.inputs.args = options

        if debug:
            print(bet.cmdline)
        bet.run()

        if self._compute_brain_image:
            self._sitk_brain_image = sitkh.read_nifti_image_sitk(
                path_to_res, sitk.sitkFloat64)

        if self._compute_brain_mask:
            self._sitk_brain_mask = sitkh.read_nifti_image_sitk(
                path_to_res_mask, sitk.sitkUInt8)

        if self._compute_skull_image:
            self._sitk_skull_image = sitkh.read_nifti_image_sitk(
                path_to_res_skull) 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:51,代码来源:brain_stripping.py


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