Difference between revisions of "Function:Mean"

From CUVI Wiki
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
Computes the mean of image pixel values
Computes the mean of image pixel values. Each channel is processed individually.
===Function===
===Function===
{|
{|
|style="font-size:150%;"|
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus mean(CuviImage* image,
CuviStatus mean(const CuviImage& src,
                 Cuvi64f* mean,
                 CuviScalar& mean,
                 CuviStream* stream = NULL);
                 const CuviStream& stream = CuviStream());


</syntaxhighlight>
</syntaxhighlight>
Line 19: Line 19:
! Description
! Description
|-
|-
| image
| src
| CuviImage*
| const CuviImage&
| Input Image
| Input Image
|-
|-
| mean
| mean
| Cuvi64f*
| CuviScalar&
| Mean of all pixel values in the image
| Mean of all pixel values in the image
|-
|-
| stream  
| stream  
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution


Line 41: Line 41:
|-
|-
| 8uC1
| 8uC1
| Cuvi64f single value
| CuviScalar
|-
|-
| 8uC3
| 8uC3
| Cuvi64f three values
| CuviScalar
|-
| 16uC1
| CuviScalar
|-
| 16uC3
| CuviScalar
|-
| 32fC1
| CuviScalar
|-
| 32fC3
| CuviScalar
|}
|}


Line 50: Line 62:
{|
{|
|-
|-
|[[File:Mean.PNG]]
|[[File:Mean2.PNG]]
|}
|}


Line 60: Line 72:




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


//Upload input data
CuviScalar mean;
gimg->upload(hostImg->imageData, hostImg->widthStep);




//Returns mean of all pixel values in the image
//Returns mean of all pixel values in the image
cuvi::arithmeticLogical::mean(gimg, &mean);
cuvi::imageStatistics::mean(gimg, mean);


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

Revision as of 19:03, 12 June 2014

Computes the mean of image pixel values. Each channel is processed individually.

Function

CuviStatus mean(const CuviImage& src,
                CuviScalar& mean,
                const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src const CuviImage& Input Image
mean CuviScalar& Mean of all pixel values in the image
stream const CuviStream& GPU stream ID for execution

Image Type Support

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

Sample

Error creating thumbnail: Unable to save thumbnail to destination


Example

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

CuviScalar mean;


//Returns mean of all pixel values in the image	
cuvi::imageStatistics::mean(gimg, mean);