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


Python SimpleITK.AffineTransform方法代码示例

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


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

示例1: get_flip_transform

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get_flip_transform(dim, flip_axes):
        """
        Returns the sitk transform based on the given parameters.
        :param dim: The dimension.
        :param flip_axes: List of flip indizes for each dimension. A True entry indicates a dimension to flip.
        :return: The sitk.AffineTransform().
        """
        assert len(flip_axes) == dim, 'flip_axes must have length that is equal to dimension.'

        # a flip is implemented by scaling the image axis by -1.0
        scale_factors = [-1.0 if f else 1.0 for f in flip_axes]

        t = sitk.AffineTransform(dim)
        t.Scale(scale_factors)

        return t 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:18,代码来源:flip.py

示例2: get

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get(self, **kwargs):
        """
        Returns the sitk transform based on the given parameters.
        :param kwargs: Must contain either 'image', or 'input_size' and 'input_spacing', which define the input image physical space.
        :return: The sitk.AffineTransform().
        """
        input_size, input_spacing, _, _ = self.get_image_size_spacing_direction_origin(**kwargs)
        current_scale = []
        for i in range(self.dim):
            if self.output_size[i] is None or self.output_spacing[i] is None:
                continue
            else:
                current_scale.append((input_size[i] * input_spacing[i]) / (self.output_size[i] * self.output_spacing[i]))
        max_scale = max(current_scale)
        current_scale = []
        for i in range(self.dim):
            if i in self.ignore_dim:
                current_scale.append(1.0)
            else:
                current_scale.append(max_scale)
        return self.get_scale_transform(self.dim, current_scale) 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:23,代码来源:scale.py

示例3: get

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get(self, **kwargs):
        """
        Returns the sitk transform based on the given parameters.
        :param kwargs: Not used.
        :return: The sitk.AffineTransform().
        """
        if self.dim == 2:
            self.current_angles = [float_uniform(-self.random_angles[0], self.random_angles[0])]
        elif self.dim == 3:
            # rotate by same random angle in each dimension
            if len(self.random_angles) == 1:
                angle = float_uniform(-self.random_angles[0], self.random_angles[0])
                self.current_angles = [angle] * self.dim
            else:
                # rotate by individual angle in each dimension
                self.current_angles = [float_uniform(-self.random_angles[i], self.random_angles[i])
                                       for i in range(self.dim)]
        return self.get_rotation_transform(self.dim, self.current_angles) 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:20,代码来源:rotation.py

示例4: _matrix_to_itk_transform

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def _matrix_to_itk_transform(matrix, dimensions=3):
    matrix = _to_itk_convention(matrix)
    rotation = matrix[:dimensions, :dimensions].ravel().tolist()
    translation = matrix[:dimensions, 3].tolist()
    transform = sitk.AffineTransform(rotation, translation)
    return transform 
开发者ID:fepegar,项目名称:torchio,代码行数:8,代码来源:io.py

示例5: get_filename

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get_filename(self):
        return self._filename

    # Get history history of affine transforms, i.e. encoded spatial
    #  position+orientation of slice, and rigid motion estimates of slice
    #  obtained in the course of the registration/reconstruction process
    #  \return list of sitk.AffineTransform and sitk.Euler3DTransform objects 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:9,代码来源:stack.py

示例6: __init__

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def __init__(self):
        DataReader.__init__(self)
        self._transforms_sitk = None

        # Third line in *.tfm file contains information on the transform type
        self._transform_type = {
            "Euler3DTransform_double_3_3": sitk.Euler3DTransform,
            "AffineTransform_double_3_3": sitk.AffineTransform,
        } 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:11,代码来源:data_reader.py

示例7: get_directory

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get_directory(self):
        return self._dir_input

    # Get current affine transformation defining the spatial position in
    #  physical space of slice
    #  \return affine transformation, sitk.AffineTransform object 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:8,代码来源:slice.py

示例8: _get_TPP_transform

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def _get_TPP_transform(self, slice_sitk):

        origin_3D_sitk = np.array(slice_sitk.GetOrigin())
        direction_3D_sitk = np.array(slice_sitk.GetDirection())
        T_PP = sitk.AffineTransform(3)
        T_PP.SetMatrix(direction_3D_sitk)
        T_PP.SetTranslation(origin_3D_sitk)
        T_PP = sitk.AffineTransform(T_PP.GetInverse())

        return T_PP 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:12,代码来源:intra_stack_registration.py

示例9: _new_affine_transform_sitk

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def _new_affine_transform_sitk(self):
        return sitk.AffineTransform(2) 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:4,代码来源:intra_stack_registration.py

示例10: _new_affine_transform_itk

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def _new_affine_transform_itk(self):
        return itk.AffineTransform.D2.New()

    ##
    # Perform motion correction based on performed registration to get motion
    # corrected stack and associated slice transforms.
    # \date       2016-11-21 20:11:53+0000
    #
    # \param      self  The object
    # \post       self._stack_corrected updated
    # \post       self._slice_transforms_sitk updated
    # 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:14,代码来源:intra_stack_registration.py

示例11: _run

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

        ph.print_title("Volume-to-Volume Registration")

        for i in range(0, len(self._stacks)):
            txt = "Volume-to-Volume Registration -- " \
                "Stack %d/%d" % (i + 1, len(self._stacks))
            if self._verbose:
                ph.print_subtitle(txt)
            else:
                ph.print_info(txt)

            if self._robust:
                transform_initializer = tinit.TransformInitializer(
                    fixed=self._reference,
                    moving=self._stacks[i],
                    similarity_measure="NCC",
                    refine_pca_initializations=True,
                )
                transform_initializer.run()
                transform_sitk = transform_initializer.get_transform_sitk()
                transform_sitk = sitk.AffineTransform(
                    transform_sitk.GetInverse())

            else:
                self._registration_method.set_moving(self._reference)
                self._registration_method.set_fixed(self._stacks[i])
                self._registration_method.run()
                transform_sitk = self._registration_method.get_registration_transform_sitk()

            # Update position of stack
            self._stacks[i].update_motion_correction(transform_sitk)


##
# Class to perform Slice-To-Volume registration
# \date       2017-08-08 02:30:03+0100
# 
开发者ID:gift-surg,项目名称:NiftyMIC,代码行数:40,代码来源:volumetric_reconstruction_pipeline.py

示例12: get

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get(self, **kwargs):
        """
        Returns the sitk transform based on the given parameters.
        :param kwargs: Not used.
        :return: The sitk.AffineTransform().
        """
        return self.get_flip_transform(self.dim, self.current_flip_axes) 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:9,代码来源:flip.py

示例13: get_translate_transform

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get_translate_transform(self, dim, offset):
        """
        Returns the sitk transform based on the given parameters.
        :param dim: The dimension.
        :param offset: List of offsets for each dimension.
        :return: The sitk.AffineTransform().
        """
        assert len(offset) == dim, 'Length of offset must be equal to dim.'

        t = sitk.AffineTransform(dim)
        offset_with_used_dimensions_only = [o if used else 0 for used, o in zip(self.used_dimensions, offset)]
        t.Translate(offset_with_used_dimensions_only)

        return t 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:16,代码来源:translation.py

示例14: get

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get(self, **kwargs):
        """
        Returns the sitk transform based on the given parameters.
        :param kwargs: Not used.
        :return: The sitk.AffineTransform().
        """
        return self.get_translate_transform(self.dim, self.current_offset) 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:9,代码来源:translation.py

示例15: get_input_center

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import AffineTransform [as 别名]
def get_input_center(self, **kwargs):
        """
        Returns the input center based on either the parameters defined by the initializer or by **kwargs.
        The function uses the result of self.get_image_size_spacing_direction_origin(**kwargs) to define the output_center for each entry of output_size and output_spacing that is None.
        :param kwargs: Must contain either 'image', or 'input_size' and 'input_spacing', which define the input image physical space.
        :return: The sitk.AffineTransform().
        """
        input_size, input_spacing, input_direction, input_origin = self.get_image_size_spacing_direction_origin(**kwargs)
        # -1 is important, as it is always the center pixel.
        input_size_half = [(input_size[i] - 1) * 0.5 for i in range(self.dim)]
        return self.index_to_physical_point(input_size_half, input_origin, input_spacing, input_direction) 
开发者ID:christianpayer,项目名称:MedicalDataAugmentationTool,代码行数:13,代码来源:translation.py


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