Difference between revisions of "Function:Multiply"

From CUVI Wiki
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
Multiplies two images
Multiplies image with another image or constant value(s).
===Function===
====Function====
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus multiply(CuviImage* srcImage1,
CuviStatus multiply(const CuviImage& src1,
                     CuviImage* srcImage2,
                     const CuviImage& src2,
                     CuviImage* dstImage,
                     CuviImage& dst,
                     CuviStream* stream = NULL);
                     const CuviStream& stream = CuviStream());
 
CuviStatus multiply(const CuviImage& src,
                    const CuviScalar& values,
                    CuviImage& dst,
                    const CuviStream& stream = CuviStream());
 
CuviStatus multiply(const CuviImage& src,
                    const Cuvi64f value,
                    CuviImage& dst,
                    const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}
===Parameters===


====Parameters====
{|
|style="font-size:75%;"|
{|class="wikitable"
{|class="wikitable"
|-
|-
Line 19: Line 31:
! Description
! Description
|-
|-
| srcImage1
| src1
| CuviImage*
| const CuviImage&
| First Input Image
| First Input Image
|-
|-
| srcImage2
| src2
| CuviImage*
| const CuviImage&
| Second Input Image
| Second Input Image
|-
|-
| dstImage
| dst
| CuviImage*
| CuviImage&
| Resultant Image
| Resultant 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 48: Line 61:
| 8u
| 8u
| 8u
| 8u
|-
| 16u
| 16u
| 16u
|-
| 32f
| 32f
| 32f
|-
| 8u
| 8u
| 16u
|-
|-
| 8u
| 8u
| 8u
| 8u
| 32f
|-
| 16u
| 16u
| 16u
| 32f
|-
|-
| 8u
| 16u
| 16u
| 16u
| 16u
|-
| 16u
| 8u
| 16u
| 16u
|-
|-
| 8u
| 32f
| 32f
| 32f
|-
| 32f
| 32f
| 8u
| 32f
|-
| 8u
| 16u
| 32f
|-
| 16u
| 8u
| 32f
| 32f
|}
===Sample===
{|
|-
|-
|[[File:MultiplyIn1.png|frame|First Input Image (8-bit)]]
| 16u
|[[File:MultiplyIn2.png|frame|Second Input Image (8-bit)]]
| 32f
| 32f
|-
|-
|[[File:MultiplyOut.png|frame| Resultant Image (16-bit)]]
| 32f
| 16u
| 32f
|}
|}
|}


===Example===
====Sample====
 
[[File:MultiplyIn1.png|none|frame|First Input Image (8-bit)]]
<br/>
[[File:MultiplyIn2.png|none|frame|Second Input Image (8-bit)]]
<br/>
[[File:MultiplyOut.png|none|frame| Resultant Image (16-bit)]]
<br/>
 
====Example====
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">


CuviImage* gimg1 = new CuviImage(size,depth,nChannels);
CuviImage gimg1 = cuvi::io::loadImage(path);
CuviImage* gimg2 = new CuviImage(size,depth,nChannels);
CuviImage gimg2 = cuvi::io::loadImage(path);
CuviImage* gout = new CuviImage(size,depth2,nChannels);


//Upload input data
CuviImage gout;
gimg1->upload(img1->imageData,img1->widthStep);
gimg2->upload(img2->imageData,img2->widthStep);


//Add
//Multiply
cuvi::arithmeticLogical::multiply(gimg1,gimg2,gout);
cuvi::arithmeticLogical::multiply(gimg1,gimg2,gout);


//Multiply with a constant value
gout *= 4;
//Multiply each channel with a different value
gout *= CuviScalar(3,5,6);
</syntaxhighlight>
</syntaxhighlight>
|}
|}

Latest revision as of 20:19, 18 October 2022

Multiplies image with another image or constant value(s).

Function

CuviStatus multiply(const CuviImage& src1,
                    const CuviImage& src2,
                    CuviImage& dst,
                    const CuviStream& stream = CuviStream());

CuviStatus multiply(const CuviImage& src,
                    const CuviScalar& values,
                    CuviImage& dst,
                    const CuviStream& stream = CuviStream());

CuviStatus multiply(const CuviImage& src,
                    const Cuvi64f value,
                    CuviImage& dst,
                    const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src1 const CuviImage& First Input Image
src2 const CuviImage& Second Input Image
dst CuviImage& Resultant Image
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input 1 Input 2 Output
8u 8u 8u
16u 16u 16u
32f 32f 32f
8u 8u 16u
8u 8u 32f
16u 16u 32f
8u 16u 16u
16u 8u 16u
8u 32f 32f
32f 8u 32f
8u 16u 32f
16u 8u 32f
16u 32f 32f
32f 16u 32f

Sample

Error creating thumbnail: Unable to save thumbnail to destination
First Input Image (8-bit)


Error creating thumbnail: Unable to save thumbnail to destination
Second Input Image (8-bit)


Error creating thumbnail: Unable to save thumbnail to destination
Resultant Image (16-bit)


Example

CuviImage gimg1 = cuvi::io::loadImage(path);
CuviImage gimg2 = cuvi::io::loadImage(path);

CuviImage gout;

//Multiply
cuvi::arithmeticLogical::multiply(gimg1,gimg2,gout);

//Multiply with a constant value
gout *= 4;

//Multiply each channel with a different value
gout *= CuviScalar(3,5,6);