16s to 16u conversion

16s to 16u conversion

is there a simple way to convert a 16s image to 16u , without going creating temporary 32simage and adding 32768 to each pixel ?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hello,

IPP v7.0 contain appropriate convertion functions in image processing domain

IPPAPI ( IppStatus, ippiConvert_16s16u_C1Rs,
(const Ipp16s* pSrc, int srcStep, Ipp16u* pDst, int dstStep,
IppiSize roi))

Although, it is implemented asdst[n] = (src[n]>0)?(Ipp16u)src[n]:0; that might be not what you are looking for

Regards,
Vladimir

yeah witht aht conversion i would lose all the pixels with negative value , definetly not what i want :)

Best Reply

Hi!
Forrange shift (16s => 16u) you can use function ippiXorC_16u_C1IR:
ippiXorC_16u_C1IR(0x8000, (Ipp16u *)pSrcDst, srcDstStep, roiSize).
Data are converted:
-32768 -> 0,
-32767 -> 1,
...
-1 -> 32767,
0 -> 32768,
1 -> 32769,
...
32767 -> 65536.
For processing of images with 3, 4 channels use similar functions with suffixesC3, C4.
I hope you are finding it.

Login to leave a comment.