Rotates an input image by given angle using :py:class:`monai.networks.layers.AffineTransform`. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information. Args: angle: Rotation angle(s) in radians. should a float
| 910 | |
| 911 | |
| 912 | class Rotate(InvertibleTransform, LazyTransform): |
| 913 | """ |
| 914 | Rotates an input image by given angle using :py:class:`monai.networks.layers.AffineTransform`. |
| 915 | |
| 916 | This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>` |
| 917 | for more information. |
| 918 | |
| 919 | Args: |
| 920 | angle: Rotation angle(s) in radians. should a float for 2D, three floats for 3D. |
| 921 | keep_size: If it is True, the output shape is kept the same as the input. |
| 922 | If it is False, the output shape is adapted so that the |
| 923 | input array is contained completely in the output. Default is True. |
| 924 | mode: {``"bilinear"``, ``"nearest"``} |
| 925 | Interpolation mode to calculate output values. Defaults to ``"bilinear"``. |
| 926 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 927 | padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} |
| 928 | Padding mode for outside grid values. Defaults to ``"border"``. |
| 929 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 930 | align_corners: Defaults to False. |
| 931 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 932 | dtype: data type for resampling computation. Defaults to ``float32``. |
| 933 | If None, use the data type of input data. To be compatible with other modules, |
| 934 | the output data type is always ``float32``. |
| 935 | lazy: a flag to indicate whether this transform should execute lazily or not. |
| 936 | Defaults to False |
| 937 | """ |
| 938 | |
| 939 | backend = [TransformBackends.TORCH] |
| 940 | |
| 941 | def __init__( |
| 942 | self, |
| 943 | angle: Sequence[float] | float, |
| 944 | keep_size: bool = True, |
| 945 | mode: str = GridSampleMode.BILINEAR, |
| 946 | padding_mode: str = GridSamplePadMode.BORDER, |
| 947 | align_corners: bool = False, |
| 948 | dtype: DtypeLike | torch.dtype = torch.float32, |
| 949 | lazy: bool = False, |
| 950 | ) -> None: |
| 951 | LazyTransform.__init__(self, lazy=lazy) |
| 952 | self.angle = angle |
| 953 | self.keep_size = keep_size |
| 954 | self.mode: str = mode |
| 955 | self.padding_mode: str = padding_mode |
| 956 | self.align_corners = align_corners |
| 957 | self.dtype = dtype |
| 958 | |
| 959 | def __call__( |
| 960 | self, |
| 961 | img: torch.Tensor, |
| 962 | mode: str | None = None, |
| 963 | padding_mode: str | None = None, |
| 964 | align_corners: bool | None = None, |
| 965 | dtype: DtypeLike | torch.dtype = None, |
| 966 | lazy: bool | None = None, |
| 967 | ) -> torch.Tensor: |
| 968 | """ |
| 969 | Args: |
no outgoing calls
searching dependent graphs…