Difference between revisions of "Function:ImageGradients"

From CUVI Wiki
 
Line 5: Line 5:
|style="font-size:150%;"|
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus imageGradients(CuviImage* srcImage,
CuviStatus imageGradients(const CuviImage& src,
                           CuviImage* dstX,
                           CuviImage& gradX,
                           CuviImage* dstY,
                           CuviImage& gradY,
                           CuviGradientKernelType type = CUVI_GRADIENT_SOBEL_3x3,
                           const CuviGradientKernelType type = CUVI_GRADIENT_SOBEL_3x3,
                           CuviStream* stream = NULL);
                           const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 22: Line 22:
! Description
! Description
|-
|-
| srcImage
| src
| CuviImage*
| const CuviImage&
| Input image
| Input image
|-
|-
| dstX
| gradX
| CuviImage*
| CuviImage&
| Horizontal image gradient
| Horizontal image gradient
|-
|-
| dstY
| gradY
| CuviImage*
| CuviImage&
| Vertical image gradient
| Vertical image gradient
|-
|-
| type  
| type  
| CuviGradientKernelType
| const CuviGradientKernelType
| Supports:  
| Supports:  
{|
{|
Line 48: Line 48:
|-
|-
| stream
| stream
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution


Line 86: Line 86:


//Container for input Image
//Container for input Image
CuviImage* gimg = new CuviImage(size,depth,nChannels);
CuviImage gimg = cuvi::io::loadImage(path);


//Containers for gradients
//Containers for gradients
CuviImage* gX = new CuviImage(size,32,nChannels);
CuviImage gX, gY;
CuviImage* gY = new CuviImage(size,32,nChannels);
 
//Populating GPU input image
gimg->upload(hostImg->imageData, hostImg->widthStep);




//function call
//function call
cuvi::computerVision::imageGradients(gimg,gX,gY,CUVI_GRADIENT_CENTRAL_DIFFERENCE);
cuvi::imageFiltering::imageGradients(gimg,gX,gY,CUVI_GRADIENT_CENTRAL_DIFFERENCE);


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

Latest revision as of 20:27, 18 April 2013

Calculates X and Y gradients of image

Function

CuviStatus imageGradients(const CuviImage& src,
                          CuviImage& gradX,
                          CuviImage& gradY,
                          const CuviGradientKernelType type = CUVI_GRADIENT_SOBEL_3x3,
                          const CuviStream& stream = CuviStream());


Parameters

Name Type Description
src const CuviImage& Input image
gradX CuviImage& Horizontal image gradient
gradY CuviImage& Vertical image gradient
type const CuviGradientKernelType Supports:
CUVI_GRADIENT_CENTRAL_DIFFERENCE
CUVI_GRADIENT_SOBEL_3x3
CUVI_GRADIENT_SOBEL_5x5
CUVI_GRADIENT_SCHARR_3x3
stream const CuviStream& GPU stream ID for execution


Image Type Support

Input Output
8uC1 32fC1
8uC3 32fC3

Sample

Error creating thumbnail: Unable to save thumbnail to destination
Input Image
Error creating thumbnail: Unable to save thumbnail to destination
Sobel X, 3x3
Error creating thumbnail: Unable to save thumbnail to destination
Sobel Y, 3x3


Example

//Container for input Image
CuviImage gimg = cuvi::io::loadImage(path);

//Containers for gradients
CuviImage gX, gY;


//function call
cuvi::imageFiltering::imageGradients(gimg,gX,gY,CUVI_GRADIENT_CENTRAL_DIFFERENCE);