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

Can i invert value of every pixel?

Ihor_Y_
Beginner
391 Views

I would like to invert value of every pixel in my image in-place. Image is allocated with ippiMalloc_32f_C1.

I mean if it was 2, it must become 0.5. So f(x) -> 1/x.

I would like to use only O(1) additional memory.

Thanks!

0 Kudos
1 Solution
Igor_A_Intel
Employee
391 Views

Hi Ihor,

just call the next function for each image row:

/* ////////////////////////////////////////////////////////////////////////////
//  Name:       ippsDivCRev
//  Purpose:    Divides a constant value by each element of a vector
//  Arguments:
//    val               Constant value used as a dividend in the operation
//    pSrc              Pointer to the source vector whose elements are used as divisors
//    pDst              Pointer to the destination vector
//    pSrcDst           Pointer to the source and destination vector for in-place operation
//    len               Number of elements in the vector
//    scaleFactor       Scale factor
//  Return:
//    ippStsNullPtrErr  At least one of the pointers is NULL
//    ippStsSizeErr     Vector length is less than 1
//    ippStsDivByZero   Warning status if any element of vector is zero. IF the dividend is zero
//                      than result is NaN, if the dividend is not zero than result is Infinity
//                      with correspondent sign. Execution is not aborted.
//                      For the integer operation zero instead of NaN and the corresponding
//                      bound values instead of Infinity
//    ippStsNoErr       No error
//  Note:
//    DivCRev(v,X,Y)  :    Y = v / X
//    DivCRev(v,X)    :    X = v / X
*/
IPPAPI(IppStatus, ippsDivCRev_16u_I, (                    Ipp16u val, Ipp16u* pSrcDst, int len))
IPPAPI(IppStatus, ippsDivCRev_16u,   (const Ipp16u* pSrc, Ipp16u val, Ipp16u* pDst,    int len))
IPPAPI(IppStatus, ippsDivCRev_32f_I, (                    Ipp32f val, Ipp32f* pSrcDst, int len))
IPPAPI(IppStatus, ippsDivCRev_32f,   (const Ipp32f* pSrc, Ipp32f val, Ipp32f* pDst,    int len))
 

regards, Igor

View solution in original post

0 Kudos
1 Reply
Igor_A_Intel
Employee
392 Views

Hi Ihor,

just call the next function for each image row:

/* ////////////////////////////////////////////////////////////////////////////
//  Name:       ippsDivCRev
//  Purpose:    Divides a constant value by each element of a vector
//  Arguments:
//    val               Constant value used as a dividend in the operation
//    pSrc              Pointer to the source vector whose elements are used as divisors
//    pDst              Pointer to the destination vector
//    pSrcDst           Pointer to the source and destination vector for in-place operation
//    len               Number of elements in the vector
//    scaleFactor       Scale factor
//  Return:
//    ippStsNullPtrErr  At least one of the pointers is NULL
//    ippStsSizeErr     Vector length is less than 1
//    ippStsDivByZero   Warning status if any element of vector is zero. IF the dividend is zero
//                      than result is NaN, if the dividend is not zero than result is Infinity
//                      with correspondent sign. Execution is not aborted.
//                      For the integer operation zero instead of NaN and the corresponding
//                      bound values instead of Infinity
//    ippStsNoErr       No error
//  Note:
//    DivCRev(v,X,Y)  :    Y = v / X
//    DivCRev(v,X)    :    X = v / X
*/
IPPAPI(IppStatus, ippsDivCRev_16u_I, (                    Ipp16u val, Ipp16u* pSrcDst, int len))
IPPAPI(IppStatus, ippsDivCRev_16u,   (const Ipp16u* pSrc, Ipp16u val, Ipp16u* pDst,    int len))
IPPAPI(IppStatus, ippsDivCRev_32f_I, (                    Ipp32f val, Ipp32f* pSrcDst, int len))
IPPAPI(IppStatus, ippsDivCRev_32f,   (const Ipp32f* pSrc, Ipp32f val, Ipp32f* pDst,    int len))
 

regards, Igor

0 Kudos
Reply