Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Kadir_Kirtac
Beginner
89 Views

How to apply the signum function to an image

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
89 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