Difference between revisions of "Function:ChannelSplit"

From CUVI Wiki
(Created page with "__NOTOC__ Splits a three channel image into R, G and B channels ===Function=== {| |style="font-size:150%;"| <syntaxhighlight lang="cpp"> CuviStatus channelSplit(CuviImage* sr...")
 
 
(8 intermediate revisions by 2 users not shown)
Line 4: Line 4:
===Function===
===Function===
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus channelSplit(CuviImage* srcImage,
CuviStatus channelSplit(const CuviImage& src,
                         CuviImage* dstRed,
                         CuviImage& red,
                         CuviImage* dstGreen,
                         CuviImage& green,
                         CuviImage* dstBlue,
                         CuviImage& blue,
                         CuviStream* stream = NULL);
                         const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}
===Parameters===


====Parameters====
{|
|style="font-size:75%;"|
{|class="wikitable"
{|class="wikitable"
|-
|-
Line 22: Line 24:
|-
|-
| src
| src
| CuviImage*
| const CuviImage&
| 3-channel input Image
| 3-channel input Image
|-
|-
| dstRed
| red
| CuviImage*
| CuviImage&
| Output red channel image
| Output red channel image
|-
|-
| dstGreen
| green
| CuviImage*
| CuviImage&
| Output green channel image
| Output green channel image
|-
|-
| dstBlue
| blue
| CuviImage*
| CuviImage&
| Output blue channel image
| Output blue channel image
|-
|-
| 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 55: Line 58:
| 16uC3
| 16uC3
| 16uC1 x 3
| 16uC1 x 3
|-
| 32fC3
| 32fC1 x 3
|}
|}
===Sample===
{|
|-
|[[File:Splitin.jpg|frame|Input Image]]
|[[File:Splitred.jpg|frame|Red Channel]]
|[[File:Splitgreen.jpg|frame|Green Channel]]
|[[File:Splitblue.jpg|frame|Blue Channel]]
|}
|}


====Sample====
[[File:Splitin.jpg|none|frame|Input Image]]
<br/>
[[File:Splitred.jpg|none|frame|Red Channel]]
<br/>
[[File:Splitgreen.jpg|none|frame|Green Channel]]
<br/>
[[File:Splitblue.jpg|none|frame|Blue Channel]]
<br/>


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


//A single color image
//A single color image
CuviImage *gimg = new CuviImage(_size,img->depth,img->nChannels);
CuviImage gimg = cuvi::io::loadImage(path,CUVI_LOAD_IMAGE_COLOR);


//Three single channel images for storing output
//Three single channel images for storing output
CuviImage *gr = new CuviImage(_size,img->depth,1);
CuviImage gr, gg, gb;
CuviImage *gg = new CuviImage(_size,img->depth,1);
CuviImage *gb = new CuviImage(_size,img->depth,1);
 
//Populate the GPU image with pixel data
gimg->upload(img->imageData,img->widthStep);


//Split into R, G and B channels
//Split into R, G and B channels
CuviStatus st = cuvi::ColorOperations::channelSplit(gimg,gr,gg,gb);
CuviStatus st = cuvi::colorOperations::channelSplit(gimg,gr,gg,gb);


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

Latest revision as of 20:46, 18 October 2022

Splits a three channel image into R, G and B channels

Function

CuviStatus channelSplit(const CuviImage& src,
                        CuviImage& red,
                        CuviImage& green,
                        CuviImage& blue,
                        const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src const CuviImage& 3-channel input Image
red CuviImage& Output red channel image
green CuviImage& Output green channel image
blue CuviImage& Output blue channel image
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input Output
8uC3 8uC1 x 3
16uC3 16uC1 x 3
32fC3 32fC1 x 3

Sample

Error creating thumbnail: Unable to save thumbnail to destination
Input Image


Error creating thumbnail: Unable to save thumbnail to destination
Red Channel


Error creating thumbnail: Unable to save thumbnail to destination
Green Channel


Error creating thumbnail: Unable to save thumbnail to destination
Blue Channel


Example

//A single color image
CuviImage gimg = cuvi::io::loadImage(path,CUVI_LOAD_IMAGE_COLOR);

//Three single channel images for storing output
CuviImage gr, gg, gb;

//Split into R, G and B channels
CuviStatus st = cuvi::colorOperations::channelSplit(gimg,gr,gg,gb);