Difference between revisions of "Function:Rotate"

From CUVI Wiki
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
Rotates an image about origin (0,0) or center
Rotates an image about a specified anchor point
===Function===
===Function===
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus rotate(const CuviImage& src,  
 
CuviStatus rotate(const CuviImage& src,
                  CuviImage& dst,
                  const Cuvi32f angle,
                  const CuviPoint2D<int> anchor,
                  const CuviStream& stream = CuviStream());
 
CuviStatus rotate(const CuviImage& src,
                   CuviImage& dst,
                   CuviImage& dst,
                   const Cuvi32f angle,
                   const Cuvi32f angle,
                   const CuviRotationType type = CUVI_ROTATE_CENTER,
                   const CuviPoint2D<int> anchor,
                  const CuviRect& roi,
                   const CuviStream& stream = CuviStream());
                   const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}


 
====Parameters====
===Parameters===
{|
 
|style="font-size:75%;"|
{|class="wikitable"
{|class="wikitable"
|-
|-
Line 34: Line 45:
| Angle of rotation
| Angle of rotation
|-
|-
| type
| anchor
| const CuviRotationType
| const CuviPoint2D<int>
| Supports:
| Center point of rotation
{|
|-
|CUVI_ROTATE_CENTER
| roi
|-
| const CuviRect&
|CUVI_ROTATE_ORIGIN
| Region of Interest
|}
|-
|-
| stream
| stream
Line 47: Line 57:
| GPU stream ID for execution
| GPU stream ID for execution


|}
|}
|}


 
====Image Type Support====
 
{|
===Image Type Support===
|style="font-size:75%;"|
 
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 75: Line 85:
| 32fC3
| 32fC3
| 32fC3
| 32fC3
|}
|}
|}


===Sample===
===Sample===
[[File:rotate_in.png|none|frame|Input Image]]
<br/>
[[File:rotate_out.png|none|frame|Resultant Image]]
<br/>
====Code Example====
{|
{|
|-
|style="font-size:100%;"|
|[[File:Rotatein.jpg|frame|Input Image]]
<syntaxhighlight lang="cpp">
|[[File:RotateOutput_45deg.jpg|frame|Rotated at 45 degrees about center]]
 
|}
 
CuviImage src, dst;
 
CuviStatus s = CUVI_SUCCESS;
s = src.create(ipath, CUVI_LOAD_IMAGE_COLOR);


if (s != CUVI_SUCCESS) printf("\nImage load Error: %d", s);


//Define point of rotation within image or ROI
CuviPoint2D<int> anchor(200, 0);


===Example===
//Define (optional) ROI
{|
CuviRect roi(50, 100, 200, 150);
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">


CuviImage gimg = cuvi::io::loadImage(path), gout;
//Perform Rotation
s = cuvi::geometryTransforms::rotate(src, dst, 1.44, anchor, roi);


//function call
cuvi::io::saveImage(dst, opath);
cuvi::geometryTransforms::rotate(gimg, gout, 45.0f);


</syntaxhighlight>
</syntaxhighlight>
|}
|}

Latest revision as of 16:20, 18 October 2022

Rotates an image about a specified anchor point

Function

CuviStatus rotate(const CuviImage& src,
                  CuviImage& dst,
                  const Cuvi32f angle,
                  const CuviPoint2D<int> anchor,
                  const CuviStream& stream = CuviStream());

CuviStatus rotate(const CuviImage& src,
                  CuviImage& dst,
                  const Cuvi32f angle,
                  const CuviPoint2D<int> anchor,
                  const CuviRect& roi,
                  const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src const CuviImage& Input image
dst CuviImage& Output image
angle const Cuvi32f Angle of rotation
anchor const CuviPoint2D<int> Center point of rotation
roi const CuviRect& Region of Interest
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input Output
8uC1 8uC1
8uC3 8uC3
16uC1 16uC1
16uC3 16uC3
32fC1 32fC1
32fC3 32fC3

Sample

Error creating thumbnail: Unable to save thumbnail to destination
Input Image


Error creating thumbnail: Unable to save thumbnail to destination
Resultant Image


Code Example

CuviImage src, dst;

CuviStatus s = CUVI_SUCCESS;
s = src.create(ipath, CUVI_LOAD_IMAGE_COLOR);

if (s != CUVI_SUCCESS)	printf("\nImage load Error: %d", s);

//Define point of rotation within image or ROI
CuviPoint2D<int> anchor(200, 0);

//Define (optional) ROI
CuviRect roi(50, 100, 200, 150);

//Perform Rotation
s = cuvi::geometryTransforms::rotate(src, dst, 1.44, anchor, roi);

cuvi::io::saveImage(dst, opath);