Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

How to apply the signum function to an image

Kadir_Kirtac
Beginner
353 Views
Hello, say I have an Ipp32s* image array. I want to apply the signum function, which will return -1 for negative pixel values, 1 for positive pixel values, and zero for zero-valued image pixels? I couldn't find a specific IPP function for signum.
0 Kudos
1 Reply
alexey_stetsenko
Beginner
353 Views

It could be done like this:

Ipp32s*pSrc; // source image

Ipp32s*pDst; // result image

ippsThreshold_LT_32s_I(pSrc, pDst, len, -1); // replace all values < -1 with -1

ippsThreshold_GT_32s_I(pDst, len, 1); // replace all values > 1 with 1

or if original image doesn't need anymore:

Ipp32s*pSrcDst; // source and result

ippsThreshold_LT_32s_I(pSrcDst, len, -1); // replace all values < -1 with -1

ippsThreshold_GT_32s_I(pSrcDst, len, 1); // replace all values > 1 with 1

0 Kudos
Reply