Difference between revisions of "Function:Subtract"

From CUVI Wiki
Line 95: Line 95:
gimg2->upload(img2->imageData,img2->widthStep);
gimg2->upload(img2->imageData,img2->widthStep);


//Divide
//Subtract two images
cuvi::arithmeticLogical::subtract(gimg1,gimg2,gout);
cuvi::arithmeticLogical::subtract(gimg1,gimg2,gout);


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

Revision as of 19:20, 2 May 2012

Subtracts pixel values of second image from the first image

Function

CuviStatus subtract(CuviImage* srcImage1,
                    CuviImage* srcImage2,
                    CuviImage* dstImage,
                    CuviStream* stream =  NULL);

Parameters

Name Type Description
srcImage1 CuviImage* First Image
srcImage2 CuviImage* Second Image
dstImage CuviImage* Resultant Image
stream CuviStream* GPU stream ID for execution

Image Type Support

Input 1 Input 2 Output
8uC1 8uC1 8uC1
8uC3 8uC3 8uC3
16uC1 16uC1 16uC1
16uC3 16uC3 16uC3
32fC1 32fC1 32fC1
32fC3 32fC3 32fC3


Sample

Error creating thumbnail: Unable to save thumbnail to destination
First Image
Error creating thumbnail: Unable to save thumbnail to destination
Second Image
Error creating thumbnail: Unable to save thumbnail to destination
Result


Example

CuviImage* gimg1 = new CuviImage(size,img1->depth,img1->nChannels);
CuviImage* gimg2 = new CuviImage(size,img2->depth,img2->nChannels);
CuviImage* gout = new CuviImage(size,img2->depth,img2->nChannels);

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

//Subtract two images
cuvi::arithmeticLogical::subtract(gimg1,gimg2,gout);