Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6632 Discussions

How to apply the signum function to an image

Kadir_Kirtac
Beginner
138 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
138 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

Reply