Difference between revisions of "Function:Resize"

From CUVI Wiki
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
Resizes input image to fit into the output image size. The function used linear interpolation
Re-sizes input image to fit into the output image size.
===Function===
===Function===
{|
{|
|style="font-size:150%;"|
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus resize(CuviImage* srcImage,
CuviStatus resize(const CuviImage& src,
                   CuviImage* dstImage,  
                   CuviImage& dst,  
                   CuviStream* stream = NULL);
                   CuviInterpolationType inter = CUVI_INTER_LINEAR,
                  const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 20: Line 21:
! Description
! Description
|-
|-
| srcImage
| src
| CuviImage*
| const CuviImage&
| Input Image
| Input Image
|-
|-
| dstImage
| dst
| CuviImage*
| CuviImage&
| Output Image
| Output Image
|-
| inter
| CuviInterpolationType
| Type of interpolation to use for re-sizing. Supports:
{|
|CUVI_INTER_NN
|-
|CUVI_INTER_LINEAR
|-
|CUVI_INTER_CUBIC
|}
|-
|-
| stream
| stream
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution


|}
|}


===Image Type Support===
===Image Type Support===
Line 54: Line 64:
| 16uC3
| 16uC3
| 16uC3
| 16uC3
|-
| 32fC1
| 32fC1
|-
| 32fC3
| 32fC3
|}
|}


Line 75: Line 91:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">


//Input size
CuviImage gimg = cuvi::io::loadImage(path);
CuviSize size = cuviSize(img->width,img->height);
 
//Defining Output size
const Cuvi32f xScale = 0.5f, yScale = 0.7f;
CuviSize sizeOut = cuviSize(img->width*0.5,img->height*0.7);
 
const Cuvi32s newWidth = static_cast<Cuvi32s>(gimg.width() * xScale);
const Cuvi32s newHeight = static_cast<Cuvi32s>(gimg.height() * yScale);


CuviImage gout(newWidth,newHeight,gimg.type());
CuviImage* gimg = new CuviImage(size,img->depth,img->nChannels);
CuviImage* gout = new CuviImage(sizeOut,img->depth,img->nChannels);


gimg->upload(img->imageData,img->widthStep);


//Resizing input image to fit output container  
//Re-sizing input image to fit output container using bicubic interpolation
cuvi::geometryTransforms::resize(gimg,gout);
cuvi::geometryTransforms::resize(gimg,gout, CUVI_INTER_CUBIC);


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

Latest revision as of 15:10, 16 June 2014

Re-sizes input image to fit into the output image size.

Function

CuviStatus resize(const CuviImage& src,
                  CuviImage& dst, 
                  CuviInterpolationType inter = CUVI_INTER_LINEAR,
                  const CuviStream& stream = CuviStream());


Parameters

Name Type Description
src const CuviImage& Input Image
dst CuviImage& Output Image
inter CuviInterpolationType Type of interpolation to use for re-sizing. Supports:
CUVI_INTER_NN
CUVI_INTER_LINEAR
CUVI_INTER_CUBIC
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


Samples

Error creating thumbnail: Unable to save thumbnail to destination
Input Image (Width = W, Height = H)
Error creating thumbnail: Unable to save thumbnail to destination
Resized Image (width =0.78625*W, height= 0.78625*H)
Error creating thumbnail: Unable to save thumbnail to destination
Input Image (Width = W, Height = H)
Error creating thumbnail: Unable to save thumbnail to destination
Resized Image (width = 1.2*W, height= 1.75*H)


Example

CuviImage gimg = cuvi::io::loadImage(path);

const Cuvi32f xScale = 0.5f, yScale = 0.7f;

const Cuvi32s newWidth = static_cast<Cuvi32s>(gimg.width() * xScale);
const Cuvi32s newHeight = static_cast<Cuvi32s>(gimg.height() * yScale);

CuviImage gout(newWidth,newHeight,gimg.type());


//Re-sizing input image to fit output container using bicubic interpolation
cuvi::geometryTransforms::resize(gimg,gout, CUVI_INTER_CUBIC);