Difference between revisions of "Function:Sum"

From CUVI Wiki
Line 5: Line 5:
|style="font-size:150%;"|
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus sum(CuviImage* image,
CuviStatus sum(const CuviImage& src,
               Cuvi64f* sum,
               Cuvi64f* sum,
               CuviStream* stream = NULL);
               const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 18: Line 18:
! Description
! Description
|-
|-
| image
| src
| CuviImage*
| const CuviImage&
| Input Image
| Input Image
|-
|-
Line 27: Line 27:
|-
|-
| stream  
| stream  
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution


Line 59: Line 59:




CuviImage* gimg = new CuviImage(size, depth, nChannels);
CuviImage gimg = cuvi::io::loadImage(path);


Cuvi64f* sum = new Cuvi64f[nChannels];
Cuvi64f* sum = new Cuvi64f[gimg.channels()];
 
//Upload input data
gimg->upload(hostImg->imageData, hostImg->widthStep);




//Sum of all pixel values
//Sum of all pixel values
cuvi::arithmeticLogical::sum(gimg, sum);
cuvi::imageStatistics::sum(gimg, sum);


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

Revision as of 17:23, 19 April 2013

Computes the sum of all pixel values in the image

Function

CuviStatus sum(const CuviImage& src,
               Cuvi64f* sum,
               const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src const CuviImage& Input Image
sum Cuvi64f* Sum of all pixel values of the image
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input Output
8uC1 Cuvi64f single value
8uC3 Cuvi64f three values

Sample

Error creating thumbnail: Unable to save thumbnail to destination


Example

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

Cuvi64f* sum = new Cuvi64f[gimg.channels()];


//Sum of all pixel values	
cuvi::imageStatistics::sum(gimg, sum);