Difference between revisions of "Function:CountInRange"

From CUVI Wiki
Line 5: Line 5:
|style="font-size:150%;"|
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus countInRange(CuviImage* image,
CuviStatus countInRange(const CuviImage& image,
                         Cuvi32u* count,
                         Cuvi32u* count,
                         Cuvi32f rangeMin,
                         const Cuvi32f rangeMin,
                         Cuvi32f rangeMax,
                         const Cuvi32f rangeMax,
                         CuviStream* stream = NULL);
                         const CuviStream& stream = NULL);
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 21: Line 21:
|-
|-
| image
| image
| CuviImage*
| const CuviImage&
| Input Image
| Input Image
|-
|-
Line 29: Line 29:
|-
|-
| rangeMin
| rangeMin
| Cuvi64f*
| const Cuvi32f
| Lower limit of the intensity range
| Lower limit of the intensity range
|-
|-
| rangeMax
| rangeMax
| Cuvi64f*
| const Cuvi32f
| Upper limit of the intensity range
| Upper limit of the intensity range
|-
|-
| stream  
| stream  
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution


Line 69: Line 69:




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


Cuvi32u* count = new Cuvi32u[nChannels];
Cuvi32u* count = new Cuvi32u[gimg.channels()];
Cuvi32f lowerBound = 25;
Cuvi32f upperBound = 100;


//Upload input data
const Cuvi32f lowerBound = 25.0f;
gimg->upload(hostImg->imageData, hostImg->widthStep);
const Cuvi32f upperBound = 100.0f;




//Returns number of pixels within the given intensity range
//Returns number of pixels within the given intensity range
cuvi::arithmeticLogical::countInRange(gimg, count, lowerBound, upperBound);
cuvi::imageStatistics::countInRange(gimg, count, lowerBound, upperBound);


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

Revision as of 11:13, 18 April 2013

Counts the number of pixels within the given intensity range

Function

CuviStatus countInRange(const CuviImage& image,
                        Cuvi32u* count,
                        const Cuvi32f rangeMin,
                        const Cuvi32f rangeMax,
                        const CuviStream& stream = NULL);

Parameters

Name Type Description
image const CuviImage& Input Image
count Cuvi32u* Computed number of pixels within the given intensity range. Returns an array of 3 values in case of 3-channel image
rangeMin const Cuvi32f Lower limit of the intensity range
rangeMax const Cuvi32f Upper limit of the intensity range
stream const CuviStream& GPU stream ID for execution

Image Type Support

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

Sample

Count.PNG


Example

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

Cuvi32u* count = new Cuvi32u[gimg.channels()];

const Cuvi32f lowerBound = 25.0f;
const Cuvi32f upperBound = 100.0f;


//Returns number of pixels within the given intensity range
cuvi::imageStatistics::countInRange(gimg, count, lowerBound, upperBound);