Rotate3d
Applies a rotation on a three-dimensional image around a user-defined point or the center of the image.
Access to parameter description
For an introduction: section 3D Rotations.
This algorithm performs a rotation of an image defined by the proper Euler angles ZXZ, ($\alpha$, $\beta$, $\gamma$).
This rotation can be seen as a composition of three elemental rotations:
Figure 1. Decomposition of a (45, 90, 45) degrees rotation into its three elemental rotations,
with the original X(red), Y (green), and Z (blue) axes:
(a) the input image, (b) first rotation, 45 degrees around $Z_1$, (c) second rotation, 90 degrees around $X_2$, (d) third rotation, 45 degrees around $Z_3$.
If the dimensions of the output image are the same as those of the input, the destination pixels may be outside the image, and these pixels are then ignored. An output resizing option automatically modifies the dimensions of the image to make all the input data visible in the output image. This option is enabled by default.
On the other hand, some pixels in the output image may not have a corresponding pixel in the input image. In this case, a user-defined padding value is assigned to these pixels.
Figure 2. Example of rotation on a 512x512x370 image, with ($\alpha$, $\beta$, $\gamma$)
= (0, 45, 0) degrees and X-axis (red), Y-axis (green), and Z-axis (blue):
(a) the input image, (b) rotation without output resizing (512x512x370 image), (c) rotation with output resizing (512x623x623 image).
See also
Access to parameter description
For an introduction: section 3D Rotations.
This algorithm performs a rotation of an image defined by the proper Euler angles ZXZ, ($\alpha$, $\beta$, $\gamma$).
This rotation can be seen as a composition of three elemental rotations:
- The image rotates by $\alpha$, around the original Z-axis $Z_1$.
- The first result rotates by $\beta$, around the new X-axis $X_2$.
- The second result rotates by $\gamma$, around the new Z-axis $Z_3$.
(a) |
(b) |
(c) |
(d) |
(a) the input image, (b) first rotation, 45 degrees around $Z_1$, (c) second rotation, 90 degrees around $X_2$, (d) third rotation, 45 degrees around $Z_3$.
If the dimensions of the output image are the same as those of the input, the destination pixels may be outside the image, and these pixels are then ignored. An output resizing option automatically modifies the dimensions of the image to make all the input data visible in the output image. This option is enabled by default.
On the other hand, some pixels in the output image may not have a corresponding pixel in the input image. In this case, a user-defined padding value is assigned to these pixels.
(a) |
(b) |
(c) |
(a) the input image, (b) rotation without output resizing (512x512x370 image), (c) rotation with output resizing (512x623x623 image).
See also
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > rotate3d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector3d rotationAngle, Rotate3d::CenterMode centerMode, iolink::Vector3d rotationCenter, Rotate3d::InterpolationType interpolationType, bool outputResizing, double paddingValue, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype. rotate_3d(input_image: idt.ImageType, rotation_angle: Union[Iterable[int], Iterable[float]] = [0, 0, 0], center_mode: Rotate3d.CenterMode = Rotate3d.CenterMode.IMAGE_CENTER, rotation_center: Union[Iterable[int], Iterable[float]] = [0, 0, 0], interpolation_type: Rotate3d.InterpolationType = Rotate3d.InterpolationType.NEAREST_NEIGHBOR, output_resizing: bool = True, padding_value: float = 0, output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype. public static IOLink.ImageView Rotate3d( IOLink.ImageView inputImage, double[] rotationAngle = null, Rotate3d.CenterMode centerMode = ImageDev.Rotate3d.CenterMode.IMAGE_CENTER, double[] rotationCenter = null, Rotate3d.InterpolationType interpolationType = ImageDev.Rotate3d.InterpolationType.NEAREST_NEIGHBOR, bool outputResizing = true, double paddingValue = 0, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |||||
rotationAngle |
The three Euler angles, in degrees, defining the rotation to apply. It must follow the proper Euler angles ZXZ convention. | Vector3d | Any value | {0.f, 0.f, 0.f} | |||||
centerMode |
The way to define the rotation center
|
Enumeration | IMAGE_CENTER | ||||||
rotationCenter |
The coordinates of the rotation center. This parameter is ignored in IMAGE_CENTER mode. | Vector3d | Any value | {0.f, 0.f, 0.f} | |||||
interpolationType |
The interpolation mode. Method used to calculate the intensity of each voxel in the result image.
|
Enumeration | NEAREST_NEIGHBOR | ||||||
outputResizing |
The output shape policy. If set to True, the output image will be resized to ensure that all input data is visible. Otherwise, the output shape will remain the same as the input shape. | Bool | true | ||||||
paddingValue |
The background value for output voxels which are outside the input image domain. | Float64 | Any value | 0 | |||||
outputImage |
The output image. Its type is forced to the same values as the input. Its dimensions are identical or greater than the input image, according to the outputResizing parameter. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
input_image |
The input image. | image | Binary, Label, Grayscale or Multispectral | None | |||||
rotation_angle |
The three Euler angles, in degrees, defining the rotation to apply. It must follow the proper Euler angles ZXZ convention. | vector3d | Any value | [0, 0, 0] | |||||
center_mode |
The way to define the rotation center
|
enumeration | IMAGE_CENTER | ||||||
rotation_center |
The coordinates of the rotation center. This parameter is ignored in IMAGE_CENTER mode. | vector3d | Any value | [0, 0, 0] | |||||
interpolation_type |
The interpolation mode. Method used to calculate the intensity of each voxel in the result image.
|
enumeration | NEAREST_NEIGHBOR | ||||||
output_resizing |
The output shape policy. If set to True, the output image will be resized to ensure that all input data is visible. Otherwise, the output shape will remain the same as the input shape. | bool | True | ||||||
padding_value |
The background value for output voxels which are outside the input image domain. | float64 | Any value | 0 | |||||
output_image |
The output image. Its type is forced to the same values as the input. Its dimensions are identical or greater than the input image, according to the outputResizing parameter. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | null | |||||
rotationAngle |
The three Euler angles, in degrees, defining the rotation to apply. It must follow the proper Euler angles ZXZ convention. | Vector3d | Any value | {0f, 0f, 0f} | |||||
centerMode |
The way to define the rotation center
|
Enumeration | IMAGE_CENTER | ||||||
rotationCenter |
The coordinates of the rotation center. This parameter is ignored in IMAGE_CENTER mode. | Vector3d | Any value | {0f, 0f, 0f} | |||||
interpolationType |
The interpolation mode. Method used to calculate the intensity of each voxel in the result image.
|
Enumeration | NEAREST_NEIGHBOR | ||||||
outputResizing |
The output shape policy. If set to True, the output image will be resized to ensure that all input data is visible. Otherwise, the output shape will remain the same as the input shape. | Bool | true | ||||||
paddingValue |
The background value for output voxels which are outside the input image domain. | Float64 | Any value | 0 | |||||
outputImage |
The output image. Its type is forced to the same values as the input. Its dimensions are identical or greater than the input image, according to the outputResizing parameter. | Image | null |
Object Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); Rotate3d rotate3dAlgo; rotate3dAlgo.setInputImage( foam ); rotate3dAlgo.setRotationAngle( {0.0, 90.0, 0.0} ); rotate3dAlgo.setCenterMode( Rotate3d::CenterMode::IMAGE_CENTER ); rotate3dAlgo.setRotationCenter( {0.0, 0.0, 0.0} ); rotate3dAlgo.setInterpolationType( Rotate3d::InterpolationType::NEAREST_NEIGHBOR ); rotate3dAlgo.setOutputResizing( true ); rotate3dAlgo.setPaddingValue( 0 ); rotate3dAlgo.execute(); std::cout << "outputImage:" << rotate3dAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) rotate_3d_algo = imagedev.Rotate3d() rotate_3d_algo.input_image = foam rotate_3d_algo.rotation_angle = [0.0, 90.0, 0.0] rotate_3d_algo.center_mode = imagedev.Rotate3d.IMAGE_CENTER rotate_3d_algo.rotation_center = [0.0, 0.0, 0.0] rotate_3d_algo.interpolation_type = imagedev.Rotate3d.NEAREST_NEIGHBOR rotate_3d_algo.output_resizing = True rotate_3d_algo.padding_value = 0 rotate_3d_algo.execute() print("output_image:", str(rotate_3d_algo.output_image))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); Rotate3d rotate3dAlgo = new Rotate3d { inputImage = foam, rotationAngle = new double[]{0.0, 90.0, 0.0}, centerMode = Rotate3d.CenterMode.IMAGE_CENTER, rotationCenter = new double[]{0.0, 0.0, 0.0}, interpolationType = Rotate3d.InterpolationType.NEAREST_NEIGHBOR, outputResizing = true, paddingValue = 0 }; rotate3dAlgo.Execute(); Console.WriteLine( "outputImage:" + rotate3dAlgo.outputImage.ToString() );
Function Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto result = rotate3d( foam, {0.0, 90.0, 0.0}, Rotate3d::CenterMode::IMAGE_CENTER, {0.0, 0.0, 0.0}, Rotate3d::InterpolationType::NEAREST_NEIGHBOR, true, 0 ); std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) result = imagedev.rotate_3d(foam, [0.0, 90.0, 0.0], imagedev.Rotate3d.IMAGE_CENTER, [0.0, 0.0, 0.0], imagedev.Rotate3d.NEAREST_NEIGHBOR, True, 0) print("output_image:", str(result))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); IOLink.ImageView result = Processing.Rotate3d( foam, new double[]{0.0, 90.0, 0.0}, Rotate3d.CenterMode.IMAGE_CENTER, new double[]{0.0, 0.0, 0.0}, Rotate3d.InterpolationType.NEAREST_NEIGHBOR, true, 0 ); Console.WriteLine( "outputImage:" + result.ToString() );