ImageDev

Rotate2d

Applies a rotation of a given angle on a two-dimensional image arround a given point or the center of the image.

Access to parameter description


<b> Figure 1.</b> The angle corresponds to this convention for defining the orientation
Figure 1. The angle corresponds to this convention for defining the orientation

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > rotate2d( std::shared_ptr< iolink::ImageView > inputImage, double rotationAngle, Rotate2d::CenterMode centerMode, iolink::Vector2d rotationCenter, Rotate2d::InterpolationType interpolationType, bool outputResizing, double paddingValue, std::shared_ptr< iolink::ImageView > outputImage = NULL );

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 angle of the rotation in degrees. Float64 Any value 90
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 rotation center coordinates. This parameter is ignored in IMAGE_CENTER mode. Vector2d Any value {0.f, 0.f}
input
interpolationType
The interpolation mode. Method used to calculate the intensity of each pixel in the result image.
NEAREST_NEIGHBOR Assign the gray level of the nearest pixel.
LINEAR Assign the bilinear interpolation from the four nearest pixels.
Enumeration NEAREST_NEIGHBOR
input
outputResizing
Resize the output image to make all input data visible in the output image if set to True. Preserve the input dimension if set to False. Bool true
input
paddingValue
The background value for pixels with no correpondant point in the input image. Float64 Any value 0
output
outputImage
The output image. Its type is forced to the same values as the input. Its dimensions are identical to or greater than the input image, according to the outputResizing parameter. Image nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

Rotate2d rotate2dAlgo;
rotate2dAlgo.setInputImage( polystyrene );
rotate2dAlgo.setRotationAngle( 40.5 );
rotate2dAlgo.setCenterMode( Rotate2d::CenterMode::IMAGE_CENTER );
rotate2dAlgo.setRotationCenter( {15.5, 32} );
rotate2dAlgo.setInterpolationType( Rotate2d::InterpolationType::NEAREST_NEIGHBOR );
rotate2dAlgo.setOutputResizing( true );
rotate2dAlgo.setPaddingValue( 0 );
rotate2dAlgo.execute();

std::cout << "outputImage:" << rotate2dAlgo.outputImage()->toString();

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = rotate2d( polystyrene, 40.5, Rotate2d::CenterMode::IMAGE_CENTER, {15.5, 32}, Rotate2d::InterpolationType::NEAREST_NEIGHBOR, true, 0 );

std::cout << "outputImage:" << result->toString();