Processing math: 100%
ImageDev

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, (α, β, γ).
This rotation can be seen as a composition of three elemental rotations:
<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
<b> (d) </b>
(d)
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 Z1, (c) second rotation, 90 degrees around X2, (d) third rotation, 45 degrees around Z3.


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.

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
Figure 2. Example of rotation on a 512x512x370 image, with (α, β, γ) = (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

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 );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
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}
input
centerMode
The way to define the rotation center
IMAGE_CENTER The rotation center is the center of the input image.
OTHER The rotation center is user-defined. It can be set with the rotationCenter parameter.
Enumeration IMAGE_CENTER
input
rotationCenter
The coordinates of the rotation center. This parameter is ignored in IMAGE_CENTER mode. Vector3d Any value {0.f, 0.f, 0.f}
input
interpolationType
The interpolation mode. Method used to calculate the intensity of each voxel in the result image.
NEAREST_NEIGHBOR Assign the gray level of the nearest voxel.
LINEAR Assign the bilinear interpolation from the nearest voxels.
Enumeration NEAREST_NEIGHBOR
input
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
input
paddingValue
The background value for output voxels which are outside the input image domain. Float64 Any value 0
output
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

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();

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();