Difference between revisions of "Function:CountInRange"

From CUVI Wiki
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
Counts the number of pixels within the given intensity range
Counts the number of pixels within the given intensity range
===Function===
====Function====
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus countInRange(CuviImage* image,
CuviStatus countInRange(const CuviImage& src,
                         Cuvi32u* count,
                         CuviScalar& count,
                         Cuvi32f rangeMin,
                         const CuviScalar& rangeMin,
                         Cuvi32f rangeMax,
                         const CuviScalar& rangeMax,
                         CuviStream* stream = NULL);
                         const CuviStream& stream = NULL);
</syntaxhighlight>
</syntaxhighlight>
|}
|}
===Parameters===


====Parameters====
{|
|style="font-size:75%;"|
{|class="wikitable"
{|class="wikitable"
|-
|-
Line 20: Line 22:
! Description
! Description
|-
|-
| image
| src
| CuviImage*
| const CuviImage&
| Input Image
| Input Image
|-
|-
| count
| count
| Cuvi32u*
| CuviScalar&
| Computed number of pixels within the given intensity range. Returns an array of 3 values in case of 3-channel image
| Computed number of pixels within the given intensity range.
|-
|-
| rangeMin
| rangeMin
| Cuvi64f*
| const CuviScalar&
| Lower limit of the intensity range
| Lower limit of the intensity range
|-
|-
| rangeMax
| rangeMax
| Cuvi64f*
| const CuviScalar&
| 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
 
|}
|}
|}


===Image Type Support===
====Image Type Support====
 
{|
|style="font-size:75%;"|
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 50: Line 53:
|-
|-
| 8uC1
| 8uC1
| Cuvi32u single value
| CuviScalar
|-
|-
| 8uC3
| 8uC3
| Cuvi32u three values
| CuviScalar
|-
| 32fC1
| CuviScalar
|-
| 32fC3
| CuviScalar
|}
|}
|}


===Sample===
====Sample====
{|
{|
|-
|-
Line 63: Line 73:




===Example===
====Example====
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">




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


Cuvi32u* count = new Cuvi32u[nChannels];
CuviScalar count;
Cuvi32f lowerBound = 25;
Cuvi32f upperBound = 100;


//Upload input data
const CuviScalar lowerBound(25.0, 10.0, 10.0);
gimg->upload(hostImg->imageData, hostImg->widthStep);
const CuviScalar upperBound(100.0, 200.0, 150.0);




//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>
|}
|}

Latest revision as of 10:29, 19 October 2022

Counts the number of pixels within the given intensity range

Function

CuviStatus countInRange(const CuviImage& src,
                        CuviScalar& count,
                        const CuviScalar& rangeMin,
                        const CuviScalar& rangeMax,
                        const CuviStream& stream = NULL);

Parameters

Name Type Description
src const CuviImage& Input Image
count CuviScalar& Computed number of pixels within the given intensity range.
rangeMin const CuviScalar& Lower limit of the intensity range
rangeMax const CuviScalar& Upper limit of the intensity range
stream const CuviStream& GPU stream ID for execution

Image Type Support

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

Sample

Count.PNG


Example

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

CuviScalar count;

const CuviScalar lowerBound(25.0, 10.0, 10.0);
const CuviScalar upperBound(100.0, 200.0, 150.0);


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