Difference between revisions of "Function:BitConversion"

From CUVI Wiki
 
Line 5: Line 5:
|style="font-size:150%;"|
|style="font-size:150%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus bitConversion(CuviImage* srcImage,
CuviStatus bitConversion(const CuviImage& src,
                         CuviImage* dstImage,
                         CuviImage& dst,
                         CuviStream* stream = NULL);
                         const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 18: Line 18:
! Description
! Description
|-
|-
| srcImage
| src
| CuviImage*
| const CuviImage&
| Input Image
| Input Image
|-
|-
| dstImage
| dst
| CuviImage*
| CuviImage&
| Output Image
| Output Image
|-
|-
| stream  
| stream  
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution


Line 66: Line 66:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">


//Using bit Conversion in C
CuviImage gimg = cuvi::io::loadImage(path);
CuviMat* gimg,*gout;


//Size of input and output should be same
CuviImage gout(gimg.size(),CUVI_DEPTH_16U, gimg.channels());
CuviSize size = cuviSize(img->width,img->height);


cuviCreateMat(&gimg,size,img->depth,img->nChannels);
cuviUploadData(gimg,img->imageData,img->widthStep);
//Telling that input image has a depth of 7-bit
//Telling that input image has a depth of 7-bit
gimg->dataBits = 7;
gimg.setDataBits(7);


cuviCreateMat(&gout,size,16,img->nChannels);
//Convert 7-bit image into 15-bit image
//Convert 7-bit image into 15-bit image
gout->dataBits = 15;
gout.setDataBits(15);
 


cuviBitConversion(gimg,gout);
cuvi::dataExchange::bitConversion(gimg,gout);


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

Latest revision as of 18:34, 18 April 2013

Converts image pixel values from one data type to another. It uses dataBits field of CuviImage to decide the number of bits of the destination image while the destination CuviImage decides the container. For example we want to convert an 8-bit input image to 15-bit image than the dataBits field of destination image will be 15 and container/datatype of destination image will be 16.

Function

CuviStatus bitConversion(const CuviImage& src,
                         CuviImage& dst,
                         const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src const CuviImage& Input Image
dst CuviImage& Output Image
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input Output
8u 8u
8u 16u
16u 16u
16u 8u

Sample

16-bit Image in 16-bit container
15-bit image in 16-bit container


Example

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

CuviImage gout(gimg.size(),CUVI_DEPTH_16U, gimg.channels());

//Telling that input image has a depth of 7-bit
gimg.setDataBits(7);

//Convert 7-bit image into 15-bit image
gout.setDataBits(15);

cuvi::dataExchange::bitConversion(gimg,gout);